From bd430d61e3540a51d3018e29a526be4f8f87c774 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Wed, 19 Aug 2020 22:33:33 +0200
Subject: [PATCH 1/5] Added test for the project load dialog
---
tests/test_gui.py | 55 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 52 insertions(+), 3 deletions(-)
diff --git a/tests/test_gui.py b/tests/test_gui.py
index d6ac126b..5c656a6b 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -9,13 +9,16 @@ from nwtools import cmpFiles
from os import path
from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QAction
+from PyQt5.QtWidgets import QAction, QDialogButtonBox
from nw.gui import (
GuiProjectSettings, GuiItemEditor, GuiAbout, GuiBuildNovel,
- GuiDocMerge, GuiDocSplit, GuiWritingStats, GuiProjectWizard
+ GuiDocMerge, GuiDocSplit, GuiWritingStats, GuiProjectWizard,
+ GuiProjectLoad
+)
+from nw.constants import (
+ nwItemType, nwItemLayout, nwItemClass, nwDocAction, nwUnicode
)
-from nw.constants import nwItemType, nwItemLayout, nwItemClass, nwDocAction, nwUnicode
keyDelay = 2
stepDelay = 20
@@ -1064,3 +1067,49 @@ def testInsertMenu(qtbot, nwTempGUI, nwFuncTemp, nwTemp):
# qtbot.stopForInteraction()
nwGUI.closeMain()
+
+@pytest.mark.gui
+def testLoadProject(qtbot, nwTempGUI, nwTemp):
+ nwGUI = nw.main(["--testmode", "--config=%s" % nwTempGUI, "--data=%s" % nwTemp])
+ qtbot.addWidget(nwGUI)
+ nwGUI.show()
+ qtbot.waitForWindowShown(nwGUI)
+ qtbot.wait(stepDelay)
+
+ nwLoad = GuiProjectLoad(nwGUI)
+ nwLoad.show()
+
+ recentCount = nwLoad.listBox.topLevelItemCount()
+ assert recentCount > 1
+
+ selItem = nwLoad.listBox.topLevelItem(1)
+ selPath = selItem.data(nwLoad.C_NAME, Qt.UserRole)
+
+ nwLoad.selPath.setText("")
+ nwLoad.listBox.setCurrentItem(selItem)
+ assert nwLoad.selPath.text() == selPath
+
+ qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Open), Qt.LeftButton)
+ assert nwLoad.openPath == selPath
+ assert nwLoad.openState == nwLoad.OPEN_STATE
+
+ del nwLoad
+ nwLoad = GuiProjectLoad(nwGUI)
+ nwLoad.show()
+
+ qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Cancel), Qt.LeftButton)
+ assert nwLoad.openPath is None
+ assert nwLoad.openState == nwLoad.NONE_STATE
+
+ nwLoad.show()
+ qtbot.mouseClick(nwLoad.newButton, Qt.LeftButton)
+ assert nwLoad.openPath is None
+ assert nwLoad.openState == nwLoad.NEW_STATE
+
+ nwLoad.show()
+ nwLoad._keyPressDelete()
+ assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
+ del nwLoad
+
+ # qtbot.stopForInteraction()
+ nwGUI.closeMain()
From d9b092b5933430b44bd7da43a01e99a074cca7ea Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Wed, 19 Aug 2020 22:50:37 +0200
Subject: [PATCH 2/5] Fixed bug where word and paragraph count was swapped in
outline details panel
---
nw/gui/outlinedetails.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py
index 9e53653f..6360a321 100644
--- a/nw/gui/outlinedetails.py
+++ b/nw/gui/outlinedetails.py
@@ -249,8 +249,8 @@ class GuiOutlineDetails(QScrollArea):
self.itemValue.setText(nwItem.itemStatus)
self.cCValue.setText("{:n}".format(checkInt(novIdx["cCount"], 0)))
- self.wCValue.setText("{:n}".format(checkInt(novIdx["pCount"], 0)))
- self.pCValue.setText("{:n}".format(checkInt(novIdx["wCount"], 0)))
+ self.wCValue.setText("{:n}".format(checkInt(novIdx["wCount"], 0)))
+ self.pCValue.setText("{:n}".format(checkInt(novIdx["pCount"], 0)))
self.synopValue.setText(novIdx["synopsis"])
From 7941cbbd34953c1fa8aec4f44ade2ac52ae0bec5 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Wed, 19 Aug 2020 23:55:23 +0200
Subject: [PATCH 3/5] Added test for outline panel
---
tests/lipsum/nwProject.nwx | 2 +-
tests/test_gui.py | 67 +++++++++++++++++++++++++++++++++++---
2 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/tests/lipsum/nwProject.nwx b/tests/lipsum/nwProject.nwx
index ebfbde69..d6a58a7a 100644
--- a/tests/lipsum/nwProject.nwx
+++ b/tests/lipsum/nwProject.nwx
@@ -48,7 +48,7 @@
True
-
- Lorem Ipusm
+ Lorem Ipsum
FILE
NOVEL
Finished
diff --git a/tests/test_gui.py b/tests/test_gui.py
index 5c656a6b..9f211dd9 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -8,8 +8,8 @@ import json
from nwtools import cmpFiles
from os import path
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QAction, QDialogButtonBox
+from PyQt5.QtCore import Qt, QPoint
+from PyQt5.QtWidgets import QAction, QDialogButtonBox, QTreeWidgetItem
from nw.gui import (
GuiProjectSettings, GuiItemEditor, GuiAbout, GuiBuildNovel,
@@ -17,7 +17,7 @@ from nw.gui import (
GuiProjectLoad
)
from nw.constants import (
- nwItemType, nwItemLayout, nwItemClass, nwDocAction, nwUnicode
+ nwItemType, nwItemLayout, nwItemClass, nwDocAction, nwUnicode, nwOutline
)
keyDelay = 2
@@ -1109,7 +1109,66 @@ def testLoadProject(qtbot, nwTempGUI, nwTemp):
nwLoad.show()
nwLoad._keyPressDelete()
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
- del nwLoad
+
+ nwLoad.close()
+ # qtbot.stopForInteraction()
+ nwGUI.closeMain()
+
+@pytest.mark.gui
+def testOutline(qtbot, nwTempBuild, nwLipsum, nwTemp):
+
+ nwGUI = nw.main(["--testmode", "--config=%s" % nwTempBuild, "--data=%s" % nwTemp])
+ qtbot.addWidget(nwGUI)
+ nwGUI.show()
+ qtbot.waitForWindowShown(nwGUI)
+ qtbot.wait(stepDelay)
+
+ assert nwGUI.openProject(nwLipsum)
+ nwGUI.mainConf.lastPath = nwTempBuild
+
+ nwGUI.rebuildIndex()
+ nwGUI.tabWidget.setCurrentIndex(nwGUI.idxTabProj)
+
+ assert nwGUI.projView.topLevelItemCount() > 0
+
+ # Context Menu
+ nwGUI.projView._headerRightClick(QPoint(1, 1))
+ nwGUI.projView.headerMenu.actionMap[nwOutline.CCOUNT].activate(QAction.Trigger)
+ nwGUI.projView.headerMenu.close()
+ qtbot.mouseClick(nwGUI.projView, Qt.LeftButton)
+
+ nwGUI.projView._loadHeaderState()
+ assert not nwGUI.projView.colHidden[nwOutline.CCOUNT]
+
+ # First Item
+ nwGUI.rebuildOutline()
+ selItem = nwGUI.projView.topLevelItem(0)
+ assert isinstance(selItem, QTreeWidgetItem)
+
+ nwGUI.projView.setCurrentItem(selItem)
+ assert nwGUI.projMeta.titleLabel.text() == "Title"
+ assert nwGUI.projMeta.titleValue.text() == "Lorem Ipsum"
+ assert nwGUI.projMeta.fileValue.text() == "Lorem Ipsum"
+ assert nwGUI.projMeta.itemValue.text() == "Finished"
+
+ assert nwGUI.projMeta.cCValue.text() == "122"
+ assert nwGUI.projMeta.wCValue.text() == "18"
+ assert nwGUI.projMeta.pCValue.text() == "2"
+
+ # Scene One
+ actItem = nwGUI.projView.topLevelItem(1)
+ chpItem = actItem.child(0)
+ selItem = chpItem.child(0)
+
+ nwGUI.projView.setCurrentItem(selItem)
+ assert nwGUI.projMeta.titleLabel.text() == "Scene"
+ assert nwGUI.projMeta.titleValue.text() == "Scene One"
+ assert nwGUI.projMeta.fileValue.text() == "Scene One"
+ assert nwGUI.projMeta.itemValue.text() == "Finished"
+
+ # Click POV Link
+ qtbot.mouseClick(nwGUI.projMeta.povKeyValue, Qt.LeftButton)
+ assert nwGUI.docViewer.theHandle == "4c4f28287af27"
# qtbot.stopForInteraction()
nwGUI.closeMain()
From d32451be1c52438bec0d0091c8ece60198aa9459 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 20 Aug 2020 00:02:56 +0200
Subject: [PATCH 4/5] Add a delay for loading the document view ite from
outline
---
tests/test_gui.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_gui.py b/tests/test_gui.py
index 9f211dd9..662a2f6b 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -1168,6 +1168,7 @@ def testOutline(qtbot, nwTempBuild, nwLipsum, nwTemp):
# Click POV Link
qtbot.mouseClick(nwGUI.projMeta.povKeyValue, Qt.LeftButton)
+ qtbot.wait(500)
assert nwGUI.docViewer.theHandle == "4c4f28287af27"
# qtbot.stopForInteraction()
From d1f570336945a7f5c63eb2a3440fb2dc1b9d367a Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Thu, 20 Aug 2020 00:11:05 +0200
Subject: [PATCH 5/5] Drop the mouseclick and just pass the value
---
tests/test_gui.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_gui.py b/tests/test_gui.py
index 662a2f6b..e512fbca 100644
--- a/tests/test_gui.py
+++ b/tests/test_gui.py
@@ -1167,8 +1167,8 @@ def testOutline(qtbot, nwTempBuild, nwLipsum, nwTemp):
assert nwGUI.projMeta.itemValue.text() == "Finished"
# Click POV Link
- qtbot.mouseClick(nwGUI.projMeta.povKeyValue, Qt.LeftButton)
- qtbot.wait(500)
+ assert nwGUI.projMeta.povKeyValue.text() == "Bod"
+ nwGUI.projMeta._tagClicked("#pov=Bod")
assert nwGUI.docViewer.theHandle == "4c4f28287af27"
# qtbot.stopForInteraction()