Update tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
[Meta]
|
||||
timestamp = 2024-11-03 21:45:08
|
||||
timestamp = 2024-12-29 17:30:10
|
||||
|
||||
[Main]
|
||||
font =
|
||||
@@ -71,6 +71,7 @@ useridletime = 300
|
||||
[State]
|
||||
showviewerpanel = True
|
||||
showedittoolbar = False
|
||||
showsessiontime = True
|
||||
viewcomments = True
|
||||
viewsynopsis = True
|
||||
searchcase = False
|
||||
|
||||
@@ -23,11 +23,13 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from PyQt5.QtCore import QEvent, QPoint, QPointF, Qt
|
||||
from PyQt5.QtGui import QKeyEvent, QWheelEvent
|
||||
from PyQt5.QtGui import QKeyEvent, QMouseEvent, QWheelEvent
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
|
||||
from novelwriter.extensions.modified import NComboBox, NDialog, NDoubleSpinBox, NSpinBox
|
||||
from novelwriter.types import QtModNone, QtRejected
|
||||
from novelwriter.extensions.modified import (
|
||||
NClickableLabel, NComboBox, NDialog, NDoubleSpinBox, NSpinBox
|
||||
)
|
||||
from novelwriter.types import QtModNone, QtMouseLeft, QtRejected
|
||||
|
||||
from tests.tools import SimpleDialog
|
||||
|
||||
@@ -139,3 +141,19 @@ def testExtModified_NDoubleSpinBox(qtbot, monkeypatch):
|
||||
assert event.ignored is True
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testExtModified_NClickableLabel(qtbot, monkeypatch):
|
||||
"""Test the NClickableLabel class."""
|
||||
widget = NClickableLabel()
|
||||
dialog = SimpleDialog(widget)
|
||||
dialog.show()
|
||||
|
||||
position = widget.rect().center()
|
||||
event = QMouseEvent(
|
||||
QEvent.Type.MouseButtonPress, position, QtMouseLeft, QtMouseLeft, QtModNone
|
||||
)
|
||||
|
||||
with qtbot.waitSignal(widget.mouseClicked):
|
||||
widget.mousePressEvent(event)
|
||||
|
||||
@@ -39,56 +39,68 @@ def testGuiStatusBar_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
newDoc.writeDocument("# A Note\n\n")
|
||||
nwGUI.rebuildIndex(beQuiet=True)
|
||||
|
||||
status = nwGUI.mainStatus
|
||||
|
||||
# Reference Time
|
||||
refTime = time.time()
|
||||
nwGUI.mainStatus.setRefTime(refTime)
|
||||
assert nwGUI.mainStatus._refTime == refTime
|
||||
status.setRefTime(refTime)
|
||||
assert status._refTime == refTime
|
||||
|
||||
# Project Status
|
||||
nwGUI.mainStatus.setProjectStatus(nwTrinary.NEUTRAL)
|
||||
assert nwGUI.mainStatus.projIcon.state == nwTrinary.NEUTRAL
|
||||
nwGUI.mainStatus.setProjectStatus(nwTrinary.NEGATIVE)
|
||||
assert nwGUI.mainStatus.projIcon.state == nwTrinary.NEGATIVE
|
||||
nwGUI.mainStatus.setProjectStatus(nwTrinary.POSITIVE)
|
||||
assert nwGUI.mainStatus.projIcon.state == nwTrinary.POSITIVE
|
||||
status.setProjectStatus(nwTrinary.NEUTRAL)
|
||||
assert status.projIcon.state == nwTrinary.NEUTRAL
|
||||
status.setProjectStatus(nwTrinary.NEGATIVE)
|
||||
assert status.projIcon.state == nwTrinary.NEGATIVE
|
||||
status.setProjectStatus(nwTrinary.POSITIVE)
|
||||
assert status.projIcon.state == nwTrinary.POSITIVE
|
||||
|
||||
# Document Status
|
||||
nwGUI.mainStatus.setDocumentStatus(nwTrinary.NEUTRAL)
|
||||
assert nwGUI.mainStatus.docIcon.state == nwTrinary.NEUTRAL
|
||||
nwGUI.mainStatus.setDocumentStatus(nwTrinary.NEGATIVE)
|
||||
assert nwGUI.mainStatus.docIcon.state == nwTrinary.NEGATIVE
|
||||
nwGUI.mainStatus.setDocumentStatus(nwTrinary.POSITIVE)
|
||||
assert nwGUI.mainStatus.docIcon.state == nwTrinary.POSITIVE
|
||||
status.setDocumentStatus(nwTrinary.NEUTRAL)
|
||||
assert status.docIcon.state == nwTrinary.NEUTRAL
|
||||
status.setDocumentStatus(nwTrinary.NEGATIVE)
|
||||
assert status.docIcon.state == nwTrinary.NEGATIVE
|
||||
status.setDocumentStatus(nwTrinary.POSITIVE)
|
||||
assert status.docIcon.state == nwTrinary.POSITIVE
|
||||
|
||||
# Idle Status
|
||||
CONFIG.stopWhenIdle = False
|
||||
nwGUI.mainStatus.setUserIdle(True)
|
||||
nwGUI.mainStatus.updateTime()
|
||||
assert nwGUI.mainStatus._userIdle is False
|
||||
assert nwGUI.mainStatus.timeText.text() == "00:00:00"
|
||||
status.setUserIdle(True)
|
||||
status.updateTime()
|
||||
assert status._userIdle is False
|
||||
assert status.timeText.text() == "00:00:00"
|
||||
|
||||
CONFIG.stopWhenIdle = True
|
||||
nwGUI.mainStatus.setUserIdle(True)
|
||||
nwGUI.mainStatus.updateTime(5)
|
||||
assert nwGUI.mainStatus._userIdle is True
|
||||
assert nwGUI.mainStatus.timeText.text() != "00:00:00"
|
||||
status.setUserIdle(True)
|
||||
status.updateTime(5)
|
||||
assert status._userIdle is True
|
||||
assert status.timeText.text() != "00:00:00"
|
||||
|
||||
nwGUI.mainStatus.setUserIdle(False)
|
||||
nwGUI.mainStatus.updateTime(5)
|
||||
assert nwGUI.mainStatus._userIdle is False
|
||||
assert nwGUI.mainStatus.timeText.text() != "00:00:00"
|
||||
status.setUserIdle(False)
|
||||
status.updateTime(5)
|
||||
assert status._userIdle is False
|
||||
assert status.timeText.text() != "00:00:00"
|
||||
|
||||
# Show/Hide Timer
|
||||
assert status.timeText.isVisible() is True
|
||||
assert CONFIG.showSessionTime is True
|
||||
status._onClickTimerLabel()
|
||||
assert status.timeText.isVisible() is False
|
||||
assert CONFIG.showSessionTime is False
|
||||
status._onClickTimerLabel()
|
||||
assert status.timeText.isVisible() is True
|
||||
assert CONFIG.showSessionTime is True
|
||||
|
||||
# Language
|
||||
nwGUI.mainStatus.setLanguage("None", "None")
|
||||
assert nwGUI.mainStatus.langText.text() == "None"
|
||||
nwGUI.mainStatus.setLanguage("en", "None")
|
||||
assert nwGUI.mainStatus.langText.text() == "American English"
|
||||
status.setLanguage("None", "None")
|
||||
assert status.langText.text() == "None"
|
||||
status.setLanguage("en", "None")
|
||||
assert status.langText.text() == "American English"
|
||||
|
||||
# Project Stats
|
||||
CONFIG.incNotesWCount = False
|
||||
nwGUI._lastTotalCount = 0
|
||||
nwGUI._updateStatusWordCount()
|
||||
assert nwGUI.mainStatus.statsText.text() == "Words: 9 (+9)"
|
||||
assert status.statsText.text() == "Words: 9 (+9)"
|
||||
|
||||
# Update again, but through time tick
|
||||
with monkeypatch.context() as mp:
|
||||
@@ -96,6 +108,6 @@ def testGuiStatusBar_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
CONFIG.incNotesWCount = True
|
||||
nwGUI._lastTotalCount = 0
|
||||
nwGUI._timeTick()
|
||||
assert nwGUI.mainStatus.statsText.text() == "Words: 11 (+11)"
|
||||
assert status.statsText.text() == "Words: 11 (+11)"
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
Reference in New Issue
Block a user