Add new test for preferences dialog
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
[Meta]
|
||||
timestamp = 2023-12-29 14:09:13
|
||||
|
||||
[Main]
|
||||
theme = default
|
||||
syntax = default_light
|
||||
font = Cantarell
|
||||
fontsize = 12
|
||||
localisation = en_GB
|
||||
hidevscroll = True
|
||||
hidehscroll = True
|
||||
lastnotes = 0x0
|
||||
lastpath =
|
||||
|
||||
[Sizes]
|
||||
mainwindow = 1200, 650
|
||||
welcome = 800, 500
|
||||
preferences = 713, 614
|
||||
mainpane = 300, 800
|
||||
viewpane = 500, 150
|
||||
outlinepane = 500, 150
|
||||
|
||||
[Project]
|
||||
autosaveproject = 40
|
||||
autosavedoc = 20
|
||||
emphlabels = True
|
||||
backuppath = some/dir
|
||||
backuponclose = True
|
||||
askbeforebackup = True
|
||||
|
||||
[Editor]
|
||||
textfont = None
|
||||
textsize = 13
|
||||
width = 700
|
||||
margin = 45
|
||||
tabwidth = 45
|
||||
focuswidth = 900
|
||||
hidefocusfooter = True
|
||||
justify = True
|
||||
autoselect = False
|
||||
autoreplace = False
|
||||
repsquotes = True
|
||||
repdquotes = True
|
||||
repdash = True
|
||||
repdots = True
|
||||
autoscroll = True
|
||||
autoscrollpos = 30
|
||||
scrollpastend = True
|
||||
fmtsquoteopen = ‘
|
||||
fmtsquoteclose = ’
|
||||
fmtdquoteopen = “
|
||||
fmtdquoteclose = ”
|
||||
fmtpadbefore =
|
||||
fmtpadafter =
|
||||
fmtpadthin = False
|
||||
spellcheck = en
|
||||
showtabsnspaces = True
|
||||
showlineendings = True
|
||||
showmultispaces = True
|
||||
wordcounttimer = 5.0
|
||||
incnoteswcount = True
|
||||
showfullpath = False
|
||||
highlightquotes = False
|
||||
allowopensquote = False
|
||||
allowopendquote = True
|
||||
highlightemph = False
|
||||
stopwhenidle = True
|
||||
useridletime = 300
|
||||
|
||||
[State]
|
||||
showviewerpanel = True
|
||||
showedittoolbar = False
|
||||
useshortcodes = False
|
||||
viewcomments = True
|
||||
viewsynopsis = True
|
||||
searchcase = False
|
||||
searchword = False
|
||||
searchregex = False
|
||||
searchloop = False
|
||||
searchnextfile = False
|
||||
searchmatchcap = False
|
||||
|
||||
@@ -22,191 +22,387 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from shutil import copyfile
|
||||
|
||||
from tools import cmpFiles, getGuiItem
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QDialog, QAction, QFileDialog, QFontDialog
|
||||
)
|
||||
from PyQt5.QtGui import QFontDatabase, QKeyEvent
|
||||
from PyQt5.QtCore import QEvent, Qt
|
||||
from PyQt5.QtWidgets import QDialogButtonBox, QFileDialog, QFontDialog
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||
from novelwriter.constants import nwConst, nwUnicode
|
||||
from novelwriter.dialogs.preferences import GuiPreferences
|
||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||
|
||||
KEY_DELAY = 1
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, tstPaths):
|
||||
"""Test the preferences dialog."""
|
||||
monkeypatch.setattr(GuiPreferences, "exec_", lambda *a: None)
|
||||
monkeypatch.setattr(GuiPreferences, "result", lambda *a: QDialog.Accepted)
|
||||
"""Test the preferences dialog loading."""
|
||||
monkeypatch.setattr(SHARED._spelling, "listDictionaries", lambda: [("en", "English [en]")])
|
||||
|
||||
nwGUI.mainMenu.aPreferences.activate(QAction.Trigger)
|
||||
qtbot.waitUntil(lambda: getGuiItem("GuiPreferences") is not None, timeout=1000)
|
||||
nwPrefs = getGuiItem("GuiPreferences")
|
||||
assert isinstance(nwPrefs, GuiPreferences)
|
||||
nwPrefs.show()
|
||||
# Load GUI with standard values
|
||||
prefs = GuiPreferences(nwGUI)
|
||||
prefs.show()
|
||||
|
||||
# General Settings
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabGeneral = nwPrefs.tabGeneral
|
||||
nwPrefs._tabBox.setCurrentWidget(tabGeneral)
|
||||
# Check Languages
|
||||
languages = [prefs.guiLocale.itemData(i) for i in range(prefs.guiLocale.count())]
|
||||
assert len(languages) > 0
|
||||
assert "en_GB" in languages
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert tabGeneral.showFullPath.isChecked()
|
||||
qtbot.mouseClick(tabGeneral.showFullPath, Qt.LeftButton)
|
||||
assert not tabGeneral.showFullPath.isChecked()
|
||||
# Check GUI Themes
|
||||
themes = [prefs.guiTheme.itemData(i) for i in range(prefs.guiTheme.count())]
|
||||
assert len(themes) >= 5
|
||||
assert "default" in themes
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabGeneral.hideVScroll.isChecked()
|
||||
qtbot.mouseClick(tabGeneral.hideVScroll, Qt.LeftButton)
|
||||
assert tabGeneral.hideVScroll.isChecked()
|
||||
# Check GUI Syntax
|
||||
syntax = [prefs.guiSyntax.itemData(i) for i in range(prefs.guiSyntax.count())]
|
||||
assert len(syntax) >= 10
|
||||
assert "default_dark" in syntax
|
||||
assert "default_light" in syntax
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabGeneral.hideHScroll.isChecked()
|
||||
qtbot.mouseClick(tabGeneral.hideHScroll, Qt.LeftButton)
|
||||
assert tabGeneral.hideHScroll.isChecked()
|
||||
# Check Spell Checking
|
||||
spelling = [prefs.spellLanguage.itemData(i) for i in range(prefs.spellLanguage.count())]
|
||||
assert len(spelling) == 1
|
||||
assert spelling == ["en"]
|
||||
|
||||
# Check font button
|
||||
monkeypatch.setattr(QFontDialog, "getFont", lambda font, obj: (font, True))
|
||||
qtbot.mouseClick(tabGeneral.fontButton, Qt.LeftButton)
|
||||
prefs.close()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabGeneral.guiFontSize.setValue(12)
|
||||
# Check Fallback Values
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(CONFIG, "hasEnchant", False)
|
||||
prefs = GuiPreferences(nwGUI)
|
||||
prefs.show()
|
||||
|
||||
# Projects Settings
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabProjects = nwPrefs.tabProjects
|
||||
nwPrefs._tabBox.setCurrentWidget(tabProjects)
|
||||
tabProjects.backupPath = "no/where"
|
||||
# Check Spell Checking
|
||||
spelling = [prefs.spellLanguage.itemData(i) for i in range(prefs.spellLanguage.count())]
|
||||
assert len(spelling) == 1
|
||||
assert spelling == [""]
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabProjects.backupOnClose.isChecked()
|
||||
qtbot.mouseClick(tabProjects.backupOnClose, Qt.LeftButton)
|
||||
assert tabProjects.backupOnClose.isChecked()
|
||||
|
||||
# Check Browse button
|
||||
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: "")
|
||||
assert not tabProjects._backupFolder()
|
||||
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: "some/dir")
|
||||
qtbot.mouseClick(tabProjects.backupGetPath, Qt.LeftButton)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabProjects.autoSaveDoc.setValue(20)
|
||||
tabProjects.autoSaveProj.setValue(40)
|
||||
|
||||
# Document Settings
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabDocs = nwPrefs.tabDocs
|
||||
nwPrefs._tabBox.setCurrentWidget(tabDocs)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
qtbot.mouseClick(tabDocs.fontButton, Qt.LeftButton)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabDocs.textSize.setValue(13)
|
||||
tabDocs.textWidth.setValue(700)
|
||||
tabDocs.focusWidth.setValue(900)
|
||||
tabDocs.textMargin.setValue(45)
|
||||
tabDocs.tabWidth.setValue(45)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabDocs.hideFocusFooter.isChecked()
|
||||
qtbot.mouseClick(tabDocs.hideFocusFooter, Qt.LeftButton)
|
||||
assert tabDocs.hideFocusFooter.isChecked()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabDocs.doJustify.isChecked()
|
||||
qtbot.mouseClick(tabDocs.doJustify, Qt.LeftButton)
|
||||
assert tabDocs.doJustify.isChecked()
|
||||
|
||||
# Editor Settings
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabEditor = nwPrefs.tabEditor
|
||||
nwPrefs._tabBox.setCurrentWidget(tabEditor)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabEditor.showTabsNSpaces.isChecked()
|
||||
qtbot.mouseClick(tabEditor.showTabsNSpaces, Qt.LeftButton)
|
||||
assert tabEditor.showTabsNSpaces.isChecked()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabEditor.showLineEndings.isChecked()
|
||||
qtbot.mouseClick(tabEditor.showLineEndings, Qt.LeftButton)
|
||||
assert tabEditor.showLineEndings.isChecked()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabEditor.autoScroll.isChecked()
|
||||
qtbot.mouseClick(tabEditor.autoScroll, Qt.LeftButton)
|
||||
assert tabEditor.autoScroll.isChecked()
|
||||
|
||||
# Syntax Settings
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabSyntax = nwPrefs.tabSyntax
|
||||
nwPrefs._tabBox.setCurrentWidget(tabSyntax)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert tabSyntax.highlightQuotes.isChecked()
|
||||
qtbot.mouseClick(tabSyntax.highlightQuotes, Qt.LeftButton)
|
||||
assert not tabSyntax.highlightQuotes.isChecked()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert tabSyntax.highlightEmph.isChecked()
|
||||
qtbot.mouseClick(tabSyntax.highlightEmph, Qt.LeftButton)
|
||||
assert not tabSyntax.highlightEmph.isChecked()
|
||||
|
||||
# Automation Settings
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabAuto = nwPrefs.tabAuto
|
||||
nwPrefs._tabBox.setCurrentWidget(tabAuto)
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert tabAuto.autoSelect.isChecked()
|
||||
qtbot.mouseClick(tabAuto.autoSelect, Qt.LeftButton)
|
||||
assert not tabAuto.autoSelect.isChecked()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert tabAuto.doReplace.isChecked()
|
||||
qtbot.mouseClick(tabAuto.doReplace, Qt.LeftButton)
|
||||
assert not tabAuto.doReplace.isChecked()
|
||||
|
||||
qtbot.wait(KEY_DELAY)
|
||||
assert not tabAuto.doReplaceSQuote.isEnabled()
|
||||
assert not tabAuto.doReplaceDQuote.isEnabled()
|
||||
assert not tabAuto.doReplaceDash.isEnabled()
|
||||
assert not tabAuto.doReplaceDots.isEnabled()
|
||||
|
||||
# Quotation Style
|
||||
qtbot.wait(KEY_DELAY)
|
||||
tabQuote = nwPrefs.tabQuote
|
||||
nwPrefs._tabBox.setCurrentWidget(tabQuote)
|
||||
|
||||
monkeypatch.setattr(GuiQuoteSelect, "selectedQuote", "'")
|
||||
monkeypatch.setattr(GuiQuoteSelect, "exec_", lambda *a: QDialog.Accepted)
|
||||
qtbot.mouseClick(tabQuote.btnDoubleStyleC, Qt.LeftButton)
|
||||
|
||||
# Save and Check Config
|
||||
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
||||
|
||||
assert CONFIG.saveConfig()
|
||||
projFile = tstPaths.cnfDir / "novelwriter.conf"
|
||||
testFile = tstPaths.outDir / "guiPreferences_novelwriter.conf"
|
||||
compFile = tstPaths.refDir / "guiPreferences_novelwriter.conf"
|
||||
copyfile(projFile, testFile)
|
||||
ignTuple = (
|
||||
"timestamp", "font", "lastnotes", "localisation", "geometry",
|
||||
"preferences", "projcols", "mainpane", "docpane", "viewpane",
|
||||
"outlinepane", "textfont", "textsize", "lastpath", "backuppath"
|
||||
)
|
||||
assert cmpFiles(testFile, compFile, ignoreStart=ignTuple)
|
||||
|
||||
# Clean up
|
||||
nwGUI.closeMain()
|
||||
prefs.close()
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
# END Test testDlgPreferences_Main
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI):
|
||||
"""Test the preferences dialog actions."""
|
||||
monkeypatch.setattr(SHARED._spelling, "listDictionaries", lambda: [("en", "English [en]")])
|
||||
monkeypatch.setattr(GuiPreferences, "deleteLater", lambda *a: None)
|
||||
prefs = GuiPreferences(nwGUI)
|
||||
prefs.show()
|
||||
|
||||
# Check Navigation
|
||||
vBar = prefs.mainForm.verticalScrollBar()
|
||||
old = -1
|
||||
with qtbot.waitSignal(vBar.valueChanged) as value:
|
||||
prefs.sidebar.button(0).click()
|
||||
assert value.args[0] > old
|
||||
old = value.args[0]
|
||||
with qtbot.waitSignal(vBar.valueChanged) as value:
|
||||
prefs.sidebar.button(1).click()
|
||||
assert value.args[0] > old
|
||||
old = value.args[0]
|
||||
with qtbot.waitSignal(vBar.valueChanged) as value:
|
||||
prefs.sidebar.button(2).click()
|
||||
assert value.args[0] > old
|
||||
old = value.args[0]
|
||||
|
||||
# Check Search
|
||||
prefs.searchText.setText("Display language")
|
||||
with qtbot.waitSignal(vBar.valueChanged) as value:
|
||||
prefs._gotoSearch()
|
||||
assert value.args[0] < old
|
||||
|
||||
# Check Apply Button
|
||||
prefs.show()
|
||||
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
|
||||
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Apply).click()
|
||||
assert signal.args == [False, False, False, False]
|
||||
|
||||
# Check Save Button
|
||||
prefs.show()
|
||||
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
|
||||
with qtbot.waitSignal(prefs.finished) as status:
|
||||
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Save).click()
|
||||
assert signal.args == [False, False, False, False]
|
||||
assert status.args == [nwConst.DLG_FINISHED]
|
||||
|
||||
# Check Close Button
|
||||
prefs.show()
|
||||
with qtbot.waitSignal(prefs.finished) as status:
|
||||
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Close).click()
|
||||
assert status.args == [nwConst.DLG_FINISHED]
|
||||
|
||||
# Close Using Escape Key
|
||||
prefs.show()
|
||||
with qtbot.waitSignal(prefs.finished) as status:
|
||||
event = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Escape, Qt.KeyboardModifier.NoModifier)
|
||||
prefs.keyPressEvent(event)
|
||||
assert status.args == [nwConst.DLG_FINISHED]
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
# END Test testDlgPreferences_Actions
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
|
||||
"""Test the preferences dialog settings."""
|
||||
spelling = [("en", "English [en]"), ("de", "Deutch [de]")]
|
||||
|
||||
monkeypatch.setattr(SHARED._spelling, "listDictionaries", lambda: spelling)
|
||||
monkeypatch.setattr(GuiPreferences, "deleteLater", lambda *a: None)
|
||||
|
||||
prefs = GuiPreferences(nwGUI)
|
||||
prefs.show()
|
||||
|
||||
# Mock Font
|
||||
class MockFont:
|
||||
|
||||
def family(self):
|
||||
return "TestFont"
|
||||
|
||||
def pointSize(self):
|
||||
return 42
|
||||
|
||||
# Appearance
|
||||
prefs.guiLocale.setCurrentIndex(prefs.guiLocale.findData("en_US"))
|
||||
prefs.guiTheme.setCurrentIndex(prefs.guiTheme.findData("default_dark"))
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QFontDialog, "getFont", lambda *a: (MockFont(), True))
|
||||
prefs.guiFontButton.click()
|
||||
prefs.guiFontSize.stepDown() # Should change it to 41
|
||||
prefs.hideVScroll.setChecked(True)
|
||||
prefs.hideHScroll.setChecked(True)
|
||||
|
||||
assert CONFIG.guiLocale != "en_US"
|
||||
assert CONFIG.guiTheme != "default_dark"
|
||||
assert CONFIG.guiFont != "TestFont"
|
||||
assert CONFIG.guiFontSize < 42
|
||||
assert CONFIG.hideVScroll is False
|
||||
assert CONFIG.hideHScroll is False
|
||||
|
||||
# Document Style
|
||||
prefs.guiSyntax.setCurrentIndex(prefs.guiSyntax.findData("default_dark"))
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QFontDialog, "getFont", lambda *a: (MockFont(), True))
|
||||
prefs.textFontButton.click()
|
||||
prefs.textSize.stepDown() # Should change it to 41
|
||||
prefs.emphLabels.setChecked(False)
|
||||
prefs.showFullPath.setChecked(False)
|
||||
prefs.incNotesWCount.setChecked(False)
|
||||
|
||||
assert CONFIG.guiSyntax != "default_dark"
|
||||
assert CONFIG.textFont != "testFont"
|
||||
assert CONFIG.textSize < 42
|
||||
assert CONFIG.emphLabels is True
|
||||
assert CONFIG.showFullPath is True
|
||||
assert CONFIG.incNotesWCount is True
|
||||
|
||||
# Auto Save
|
||||
prefs.autoSaveDoc.stepUp()
|
||||
prefs.autoSaveProj.stepUp()
|
||||
|
||||
assert CONFIG.autoSaveDoc == 30
|
||||
assert CONFIG.autoSaveProj == 60
|
||||
|
||||
# Project Backup
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QFileDialog, "getExistingDirectory", lambda *a, **k: str(tstPaths.testDir))
|
||||
prefs.backupGetPath.click()
|
||||
assert prefs.backupPath == str(tstPaths.testDir)
|
||||
prefs.backupOnClose.setChecked(True)
|
||||
assert prefs.askBeforeBackup.isEnabled() is True
|
||||
prefs.askBeforeBackup.setChecked(False)
|
||||
|
||||
assert CONFIG._backupPath != tstPaths.testDir
|
||||
assert CONFIG.backupOnClose is False
|
||||
assert CONFIG.askBeforeBackup is True
|
||||
|
||||
# Session Timer
|
||||
prefs.stopWhenIdle.setChecked(False)
|
||||
prefs.userIdleTime.stepUp()
|
||||
|
||||
assert CONFIG.stopWhenIdle is True
|
||||
assert CONFIG.userIdleTime == 300
|
||||
|
||||
# Text Flow
|
||||
prefs.textWidth.stepDown()
|
||||
prefs.focusWidth.stepDown()
|
||||
prefs.hideFocusFooter.setChecked(True)
|
||||
prefs.doJustify.setChecked(True)
|
||||
prefs.textMargin.stepUp()
|
||||
prefs.tabWidth.stepUp()
|
||||
|
||||
assert CONFIG.textWidth == 700
|
||||
assert CONFIG.focusWidth == 800
|
||||
assert CONFIG.hideFocusFooter is False
|
||||
assert CONFIG.doJustify is False
|
||||
assert CONFIG.textMargin == 40
|
||||
assert CONFIG.tabWidth == 40
|
||||
|
||||
# Text Editing
|
||||
prefs.spellLanguage.setCurrentIndex(prefs.spellLanguage.findData("de"))
|
||||
prefs.autoSelect.setChecked(False)
|
||||
prefs.showTabsNSpaces.setChecked(True)
|
||||
prefs.showLineEndings.setChecked(True)
|
||||
|
||||
assert CONFIG.spellLanguage != "de"
|
||||
assert CONFIG.autoSelect is True
|
||||
assert CONFIG.showTabsNSpaces is False
|
||||
assert CONFIG.showLineEndings is False
|
||||
|
||||
# Editor Scrolling
|
||||
prefs.scrollPastEnd.setChecked(False)
|
||||
prefs.autoScroll.setChecked(True)
|
||||
prefs.autoScrollPos.stepUp()
|
||||
|
||||
assert CONFIG.scrollPastEnd is True
|
||||
assert CONFIG.autoScroll is False
|
||||
assert CONFIG.autoScrollPos == 30
|
||||
|
||||
# Text Highlighting
|
||||
prefs.allowOpenSQuote.setChecked(True)
|
||||
prefs.allowOpenDQuote.setChecked(False)
|
||||
prefs.highlightQuotes.setChecked(False)
|
||||
prefs.highlightEmph.setChecked(False)
|
||||
prefs.showMultiSpaces.setChecked(False)
|
||||
|
||||
assert prefs.allowOpenSQuote.isEnabled() is False
|
||||
assert prefs.allowOpenDQuote.isEnabled() is False
|
||||
|
||||
assert CONFIG.highlightQuotes is True
|
||||
assert CONFIG.allowOpenSQuote is False
|
||||
assert CONFIG.allowOpenDQuote is True
|
||||
assert CONFIG.highlightEmph is True
|
||||
assert CONFIG.showMultiSpaces is True
|
||||
|
||||
# Text Automation
|
||||
prefs.doReplaceSQuote.setChecked(False)
|
||||
prefs.doReplaceDQuote.setChecked(False)
|
||||
prefs.doReplaceDash.setChecked(False)
|
||||
prefs.doReplaceDots.setChecked(False)
|
||||
prefs.doReplace.setChecked(False)
|
||||
prefs.fmtPadBefore.setText("!?:")
|
||||
prefs.fmtPadAfter.setText("¡¿")
|
||||
prefs.fmtPadThin.setChecked(True)
|
||||
|
||||
assert prefs.doReplaceSQuote.isEnabled() is False
|
||||
assert prefs.doReplaceDQuote.isEnabled() is False
|
||||
assert prefs.doReplaceDash.isEnabled() is False
|
||||
assert prefs.doReplaceDots.isEnabled() is False
|
||||
assert prefs.fmtPadThin.isEnabled() is False
|
||||
|
||||
assert CONFIG.doReplace is True
|
||||
assert CONFIG.doReplaceSQuote is True
|
||||
assert CONFIG.doReplaceDQuote is True
|
||||
assert CONFIG.doReplaceDash is True
|
||||
assert CONFIG.doReplaceDots is True
|
||||
assert CONFIG.fmtPadBefore == ""
|
||||
assert CONFIG.fmtPadAfter == ""
|
||||
assert CONFIG.fmtPadThin is False
|
||||
|
||||
# Quotation Style
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_LSAQUO, True))
|
||||
prefs.btnSingleStyleO.click()
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_RSAQUO, True))
|
||||
prefs.btnSingleStyleC.click()
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_LAQUO, True))
|
||||
prefs.btnDoubleStyleO.click()
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_RAQUO, True))
|
||||
prefs.btnDoubleStyleC.click()
|
||||
|
||||
assert CONFIG.fmtSQuoteOpen == nwUnicode.U_LSQUO
|
||||
assert CONFIG.fmtSQuoteClose == nwUnicode.U_RSQUO
|
||||
assert CONFIG.fmtDQuoteOpen == nwUnicode.U_LDQUO
|
||||
assert CONFIG.fmtDQuoteClose == nwUnicode.U_RDQUO
|
||||
|
||||
# Save Settings
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QFontDatabase, "families", lambda *a: ["TestFont"])
|
||||
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
|
||||
prefs.buttonBox.button(QDialogButtonBox.StandardButton.Apply).click()
|
||||
assert signal.args == [True, True, True, True]
|
||||
|
||||
# Check Settings
|
||||
# ==============
|
||||
|
||||
# Appearance
|
||||
assert CONFIG.guiLocale == "en_US"
|
||||
assert CONFIG.guiTheme == "default_dark"
|
||||
assert CONFIG.guiFont == "TestFont"
|
||||
assert CONFIG.guiFontSize == 41
|
||||
assert CONFIG.hideVScroll is True
|
||||
assert CONFIG.hideHScroll is True
|
||||
|
||||
# Document Style
|
||||
assert CONFIG.guiSyntax == "default_dark"
|
||||
assert CONFIG.textFont == "TestFont"
|
||||
assert CONFIG.textSize == 41
|
||||
assert CONFIG.emphLabels is False
|
||||
assert CONFIG.showFullPath is False
|
||||
assert CONFIG.incNotesWCount is False
|
||||
|
||||
# Auto Save
|
||||
assert CONFIG.autoSaveDoc == 31
|
||||
assert CONFIG.autoSaveProj == 61
|
||||
|
||||
# Project Backup
|
||||
assert CONFIG._backupPath == tstPaths.testDir
|
||||
assert CONFIG.backupOnClose is True
|
||||
assert CONFIG.askBeforeBackup is False
|
||||
|
||||
# Session Timer
|
||||
assert CONFIG.stopWhenIdle is False
|
||||
assert CONFIG.userIdleTime == 330
|
||||
|
||||
# Text Flow
|
||||
assert CONFIG.textWidth == 690
|
||||
assert CONFIG.focusWidth == 790
|
||||
assert CONFIG.hideFocusFooter is True
|
||||
assert CONFIG.doJustify is True
|
||||
assert CONFIG.textMargin == 41
|
||||
assert CONFIG.tabWidth == 41
|
||||
|
||||
# Text Editing
|
||||
assert CONFIG.spellLanguage == "de"
|
||||
assert CONFIG.autoSelect is False
|
||||
assert CONFIG.showTabsNSpaces is True
|
||||
assert CONFIG.showLineEndings is True
|
||||
|
||||
# Editor Scrolling
|
||||
assert CONFIG.scrollPastEnd is False
|
||||
assert CONFIG.autoScroll is True
|
||||
assert CONFIG.autoScrollPos == 31
|
||||
|
||||
# Text Highlighting
|
||||
assert CONFIG.highlightQuotes is False
|
||||
assert CONFIG.allowOpenSQuote is True
|
||||
assert CONFIG.allowOpenDQuote is False
|
||||
assert CONFIG.highlightEmph is False
|
||||
assert CONFIG.showMultiSpaces is False
|
||||
|
||||
# Text Automation
|
||||
assert CONFIG.doReplace is False
|
||||
assert CONFIG.doReplaceSQuote is False
|
||||
assert CONFIG.doReplaceDQuote is False
|
||||
assert CONFIG.doReplaceDash is False
|
||||
assert CONFIG.doReplaceDots is False
|
||||
assert CONFIG.fmtPadBefore == "!?:"
|
||||
assert CONFIG.fmtPadAfter == "¡¿"
|
||||
assert CONFIG.fmtPadThin is True
|
||||
|
||||
# Quotation Style
|
||||
assert CONFIG.fmtSQuoteOpen == nwUnicode.U_LSAQUO
|
||||
assert CONFIG.fmtSQuoteClose == nwUnicode.U_RSAQUO
|
||||
assert CONFIG.fmtDQuoteOpen == nwUnicode.U_LAQUO
|
||||
assert CONFIG.fmtDQuoteClose == nwUnicode.U_RAQUO
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
# END Test testDlgPreferences_Settings
|
||||
|
||||
Reference in New Issue
Block a user