Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Jul 21, 2024
1 parent 17b3b2b commit 5936e1a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/test_gui/test_gui_guimain.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from novelwriter.gui.projtree import GuiProjectTree
from novelwriter.tools.welcome import GuiWelcome

from tests.mocked import causeOSError
from tests.tools import NWD_IGNORE, XML_IGNORE, C, buildTestProject, cmpFiles

KEY_DELAY = 1
Expand Down Expand Up @@ -651,7 +652,7 @@ def testGuiMain_Viewing(qtbot, monkeypatch, nwGUI, projPath, mockRnd):


@pytest.mark.gui
def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd):
def testGuiMain_Features(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
"""Test various features of the main window."""
buildTestProject(nwGUI, projPath)
assert SHARED.focusMode is False
Expand All @@ -672,6 +673,7 @@ def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd):

# Enable focus mode
nwGUI.toggleFocusMode()
assert SHARED.focusMode is True
assert nwGUI.treePane.isVisible() is False
assert nwGUI.mainStatus.isVisible() is False
assert nwGUI.mainMenu.isVisible() is False
Expand All @@ -680,12 +682,19 @@ def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd):

# Disable focus mode
nwGUI.toggleFocusMode()
assert SHARED.focusMode is False
assert nwGUI.treePane.isVisible() is True
assert nwGUI.mainStatus.isVisible() is True
assert nwGUI.mainMenu.isVisible() is True
assert nwGUI.sideBar.isVisible() is True
assert nwGUI.splitView.isVisible() is True

# Closing editor disables focus mode
nwGUI.toggleFocusMode()
assert SHARED.focusMode is True
nwGUI.closeDocument()
assert SHARED.focusMode is False

# Full Screen Mode
# ================

Expand All @@ -702,6 +711,17 @@ def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd):
nwGUI.sideBar.mSettings.show()
nwGUI.sideBar.mSettings.hide()

# Document Open Errors
# ====================

# Cannot edit a folder
assert nwGUI.openDocument(C.hChapterDir) is False

# Handle I/O error
with monkeypatch.context() as mp:
mp.setattr("builtins.open", causeOSError)
assert nwGUI.openDocument(C.hChapterDoc) is False

# qtbot.stop()


Expand Down

0 comments on commit 5936e1a

Please sign in to comment.