Added some more checks in the gui tests for writing documents

This commit is contained in:
Veronica K. B. Olsen
2020-06-18 22:36:36 +02:00
parent 70ce2b1226
commit 8ff54ceaa4
2 changed files with 22 additions and 10 deletions
+8 -8
View File
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.8.0rc1" hexVersion="0x000800c1" fileVersion="1.1" timeStamp="2020-06-05 21:07:51"> <novelWriterXML appVersion="0.9.0rc1" hexVersion="0x000900c1" fileVersion="1.1" timeStamp="2020-06-18 22:17:32">
<project> <project>
<name>New Project</name> <name>New Project</name>
<title></title> <title></title>
@@ -11,9 +11,9 @@
<doBackup>True</doBackup> <doBackup>True</doBackup>
<spellCheck>False</spellCheck> <spellCheck>False</spellCheck>
<autoOutline>True</autoOutline> <autoOutline>True</autoOutline>
<lastEdited>None</lastEdited> <lastEdited>31489056e0916</lastEdited>
<lastViewed>None</lastViewed> <lastViewed>None</lastViewed>
<lastWordCount>0</lastWordCount> <lastWordCount>59</lastWordCount>
<autoReplace/> <autoReplace/>
<titleFormat> <titleFormat>
<title>%title%</title> <title>%title%</title>
@@ -41,14 +41,14 @@
<type>ROOT</type> <type>ROOT</type>
<class>NOVEL</class> <class>NOVEL</class>
<status>New</status> <status>New</status>
<expanded>False</expanded> <expanded>True</expanded>
</item> </item>
<item handle="25fc0e7096fc6" order="0" parent="73475cb40a568"> <item handle="25fc0e7096fc6" order="0" parent="73475cb40a568">
<name>New Chapter</name> <name>New Chapter</name>
<type>FOLDER</type> <type>FOLDER</type>
<class>NOVEL</class> <class>NOVEL</class>
<status>New</status> <status>New</status>
<expanded>False</expanded> <expanded>True</expanded>
</item> </item>
<item handle="31489056e0916" order="0" parent="25fc0e7096fc6"> <item handle="31489056e0916" order="0" parent="25fc0e7096fc6">
<name>Just a Page</name> <name>Just a Page</name>
@@ -57,9 +57,9 @@
<status>Note</status> <status>Note</status>
<exported>False</exported> <exported>False</exported>
<layout>PAGE</layout> <layout>PAGE</layout>
<charCount>0</charCount> <charCount>331</charCount>
<wordCount>0</wordCount> <wordCount>59</wordCount>
<paraCount>0</paraCount> <paraCount>2</paraCount>
<cursorPos>0</cursorPos> <cursorPos>0</cursorPos>
</item> </item>
<item handle="44cb730c42048" order="1" parent="None"> <item handle="44cb730c42048" order="1" parent="None">
+14 -2
View File
@@ -127,6 +127,11 @@ def testMainWindows(qtbot, nwTempGUI, nwRef, nwTemp):
nwGUI.treeView.newTreeItem(nwItemType.FILE, None) nwGUI.treeView.newTreeItem(nwItemType.FILE, None)
assert nwGUI.openSelectedItem() assert nwGUI.openSelectedItem()
# Add Some Text
nwGUI.docEditor.replaceText("Hello World!")
assert nwGUI.docEditor.getText() == "Hello World!"
nwGUI.docEditor.replaceText("")
# Type something into the document # Type something into the document
nwGUI.setFocus(2) nwGUI.setFocus(2)
for c in "# Main Location": for c in "# Main Location":
@@ -359,6 +364,7 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):
# Create new, save, open project # Create new, save, open project
nwGUI.theProject.projTree.setSeed(42) nwGUI.theProject.projTree.setSeed(42)
assert nwGUI.newProject(nwTempGUI, True) assert nwGUI.newProject(nwTempGUI, True)
assert nwGUI.openDocument("31489056e0916")
itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916") itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916")
qtbot.addWidget(itemEdit) qtbot.addWidget(itemEdit)
@@ -375,7 +381,6 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):
itemEdit.editExport.setChecked(False) itemEdit.editExport.setChecked(False)
assert not itemEdit.editExport.isChecked() assert not itemEdit.editExport.isChecked()
itemEdit._doSave() itemEdit._doSave()
itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916") itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916")
@@ -383,9 +388,16 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):
assert itemEdit.editName.text() == "Just a Page" assert itemEdit.editName.text() == "Just a Page"
assert itemEdit.editStatus.currentData() == "Note" assert itemEdit.editStatus.currentData() == "Note"
assert itemEdit.editLayout.currentData() == nwItemLayout.PAGE assert itemEdit.editLayout.currentData() == nwItemLayout.PAGE
itemEdit._doClose() itemEdit._doClose()
# Check that the header is updated
nwGUI.docEditor.updateDocTitle("31489056e0916")
assert nwGUI.docEditor.docHeader.theTitle.text() == "Novel New Chapter Just a Page"
assert not nwGUI.docEditor.setCursorLine("where?")
assert nwGUI.docEditor.setCursorLine(2)
qtbot.wait(stepDelay)
assert nwGUI.docEditor.getCursorPosition() == 9
qtbot.wait(stepDelay) qtbot.wait(stepDelay)
assert nwGUI.saveProject() assert nwGUI.saveProject()
qtbot.wait(stepDelay) qtbot.wait(stepDelay)