From 8ff54ceaa48680014800ba577e8c59b55e7e3bac Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Thu, 18 Jun 2020 22:36:36 +0200 Subject: [PATCH] Added some more checks in the gui tests for writing documents --- tests/reference/gui/3_nwProject.nwx | 16 ++++++++-------- tests/test_gui.py | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/reference/gui/3_nwProject.nwx b/tests/reference/gui/3_nwProject.nwx index 7ae01352..038ee8f2 100644 --- a/tests/reference/gui/3_nwProject.nwx +++ b/tests/reference/gui/3_nwProject.nwx @@ -1,5 +1,5 @@ - + New Project @@ -11,9 +11,9 @@ True False True - None + 31489056e0916 None - 0 + 59 %title% @@ -41,14 +41,14 @@ ROOT NOVEL New - False + True New Chapter FOLDER NOVEL New - False + True Just a Page @@ -57,9 +57,9 @@ Note False PAGE - 0 - 0 - 0 + 331 + 59 + 2 0 diff --git a/tests/test_gui.py b/tests/test_gui.py index 1a18ec99..fb98c1eb 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -127,6 +127,11 @@ def testMainWindows(qtbot, nwTempGUI, nwRef, nwTemp): nwGUI.treeView.newTreeItem(nwItemType.FILE, None) 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 nwGUI.setFocus(2) for c in "# Main Location": @@ -359,6 +364,7 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp): # Create new, save, open project nwGUI.theProject.projTree.setSeed(42) assert nwGUI.newProject(nwTempGUI, True) + assert nwGUI.openDocument("31489056e0916") itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916") qtbot.addWidget(itemEdit) @@ -375,7 +381,6 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp): itemEdit.editExport.setChecked(False) assert not itemEdit.editExport.isChecked() - itemEdit._doSave() 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.editStatus.currentData() == "Note" assert itemEdit.editLayout.currentData() == nwItemLayout.PAGE - 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) assert nwGUI.saveProject() qtbot.wait(stepDelay)