Clean up config file format, modify how projects are launched, and add broken theme setting handling
This commit is contained in:
@@ -21,15 +21,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from tools import C, cmpFiles, buildTestProject, XML_IGNORE, writeFile
|
||||
from shutil import copyfile
|
||||
|
||||
from tools import (
|
||||
C, cmpFiles, buildTestProject, XML_IGNORE, getGuiItem, writeFile
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QMessageBox, QInputDialog
|
||||
from PyQt5.QtWidgets import QDialog, QMessageBox, QInputDialog
|
||||
|
||||
from novelwriter.enum import nwItemType, nwView, nwWidget
|
||||
from novelwriter.tools import GuiProjectWizard
|
||||
from novelwriter.dialogs import GuiEditLabel
|
||||
from novelwriter.dialogs import GuiEditLabel, GuiAbout, GuiProjectLoad
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.gui.outline import GuiOutlineView
|
||||
from novelwriter.gui.projtree import GuiProjectTree
|
||||
@@ -62,7 +65,39 @@ def testGuiMain_ProjectBlocker(nwGUI):
|
||||
assert nwGUI.showProjectWordListDialog() is False
|
||||
assert nwGUI.showWritingStatsDialog() is False
|
||||
|
||||
# END Test testGuiMain_NoProject
|
||||
# END Test testGuiMain_ProjectBlocker
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
"""Test the handling of launch tasks.
|
||||
"""
|
||||
monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiProjectLoad, "result", lambda *a: QDialog.Accepted)
|
||||
nwGUI.mainConf.lastNotes = "0x0"
|
||||
|
||||
# Open Lipsum project
|
||||
nwGUI.postLaunchTasks(prjLipsum)
|
||||
nwGUI.closeProject()
|
||||
|
||||
# Check that release notes opened
|
||||
qtbot.waitUntil(lambda: getGuiItem("GuiAbout") is not None, timeout=1000)
|
||||
msgAbout = getGuiItem("GuiAbout")
|
||||
assert isinstance(msgAbout, GuiAbout)
|
||||
assert msgAbout.tabBox.currentWidget() == msgAbout.pageNotes
|
||||
msgAbout.accept()
|
||||
|
||||
# Check that project open dialog launches
|
||||
nwGUI.postLaunchTasks(None)
|
||||
qtbot.waitUntil(lambda: getGuiItem("GuiProjectLoad") is not None, timeout=1000)
|
||||
nwLoad = getGuiItem("GuiProjectLoad")
|
||||
assert isinstance(nwLoad, GuiProjectLoad)
|
||||
nwLoad.show()
|
||||
nwLoad.reject()
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
# END Test testGuiMain_Launch
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
|
||||
@@ -150,7 +150,10 @@ def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI, fncPath):
|
||||
|
||||
# Check handling of broken theme settings
|
||||
mainConf.guiTheme = "not_a_theme"
|
||||
availThemes = mainTheme._availThemes
|
||||
mainTheme._availThemes = {}
|
||||
assert mainTheme.loadTheme() is False
|
||||
mainTheme._availThemes = availThemes
|
||||
|
||||
# Check handling of unreadable file
|
||||
mainConf.guiTheme = "default"
|
||||
@@ -216,8 +219,11 @@ def testGuiTheme_Syntax(qtbot, monkeypatch, nwGUI, fncPath):
|
||||
assert mainTheme.listSyntax() == mainTheme._syntaxList
|
||||
|
||||
# Check handling of broken theme settings
|
||||
availSyntax = mainTheme._availSyntax
|
||||
mainTheme._availSyntax = {}
|
||||
mainConf.guiSyntax = "not_a_syntax"
|
||||
assert mainTheme.loadSyntax() is False
|
||||
mainTheme._availSyntax = availSyntax
|
||||
|
||||
# Check handling of unreadable file
|
||||
mainConf.guiSyntax = "default_light"
|
||||
|
||||
Reference in New Issue
Block a user