Fix dialog test method and make appropriate changes to the project load tool
This commit is contained in:
+18
-6
@@ -125,7 +125,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Open | QDialogButtonBox.Cancel)
|
||||||
self.buttonBox.accepted.connect(self._doOpenRecent)
|
self.buttonBox.accepted.connect(self._doOpenRecent)
|
||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self._doCancel)
|
||||||
|
|
||||||
self.newButton = self.buttonBox.addButton("New", QDialogButtonBox.ActionRole)
|
self.newButton = self.buttonBox.addButton("New", QDialogButtonBox.ActionRole)
|
||||||
self.newButton.clicked.connect(self._doNewProject)
|
self.newButton.clicked.connect(self._doNewProject)
|
||||||
@@ -153,7 +153,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
"""Close the dialog window with a recent project selected.
|
"""Close the dialog window with a recent project selected.
|
||||||
"""
|
"""
|
||||||
logger.verbose("GuiProjectLoad open button clicked")
|
logger.verbose("GuiProjectLoad open button clicked")
|
||||||
self._saveDialogState()
|
self._saveSettings()
|
||||||
|
|
||||||
selItems = self.listBox.selectedItems()
|
selItems = self.listBox.selectedItems()
|
||||||
if selItems:
|
if selItems:
|
||||||
@@ -194,11 +194,12 @@ class GuiProjectLoad(QDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _doClose(self):
|
def _doCancel(self):
|
||||||
"""Close the dialog window without doing anything.
|
"""Close the dialog window without doing anything.
|
||||||
"""
|
"""
|
||||||
logger.verbose("GuiProjectLoad close button clicked")
|
logger.verbose("GuiProjectLoad close button clicked")
|
||||||
self._saveDialogState()
|
self.openPath = None
|
||||||
|
self.openState = self.NONE_STATE
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ class GuiProjectLoad(QDialog):
|
|||||||
"""Create a new project.
|
"""Create a new project.
|
||||||
"""
|
"""
|
||||||
logger.verbose("GuiProjectLoad new project button clicked")
|
logger.verbose("GuiProjectLoad new project button clicked")
|
||||||
self._saveDialogState()
|
self._saveSettings()
|
||||||
self.openPath = None
|
self.openPath = None
|
||||||
self.openState = self.NEW_STATE
|
self.openState = self.NEW_STATE
|
||||||
self.accept()
|
self.accept()
|
||||||
@@ -230,11 +231,22 @@ class GuiProjectLoad(QDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Events
|
||||||
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, theEvent):
|
||||||
|
"""Capture the user closing the dialog so we can save settings.
|
||||||
|
"""
|
||||||
|
self._saveSettings()
|
||||||
|
theEvent.accept()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
def _saveDialogState(self):
|
def _saveSettings(self):
|
||||||
"""Save the changes made to the dialog.
|
"""Save the changes made to the dialog.
|
||||||
"""
|
"""
|
||||||
colWidths = [0, 0, 0]
|
colWidths = [0, 0, 0]
|
||||||
|
|||||||
+38
-5
@@ -114,7 +114,12 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, nwR
|
|||||||
projEdit._doSave()
|
projEdit._doSave()
|
||||||
|
|
||||||
# Open again, and check project settings
|
# Open again, and check project settings
|
||||||
projEdit = GuiProjectSettings(nwGUI, nwGUI.theProject)
|
nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiProjectSettings") is not None, timeout=1000)
|
||||||
|
|
||||||
|
projEdit = getGuiItem("GuiProjectSettings")
|
||||||
|
assert isinstance(projEdit, GuiProjectSettings)
|
||||||
|
|
||||||
qtbot.addWidget(projEdit)
|
qtbot.addWidget(projEdit)
|
||||||
assert projEdit.tabMain.editName.text() == "Project Name"
|
assert projEdit.tabMain.editName.text() == "Project Name"
|
||||||
assert projEdit.tabMain.editTitle.text() == "Project Title"
|
assert projEdit.tabMain.editTitle.text() == "Project Title"
|
||||||
@@ -582,8 +587,13 @@ def testBuildTool(qtbot, yesToAll, nwTempBuild, nwLipsum, nwRef, nwTemp):
|
|||||||
nwBuild._doClose()
|
nwBuild._doClose()
|
||||||
|
|
||||||
# Re-open build dialog from cahce
|
# Re-open build dialog from cahce
|
||||||
nwBuild = GuiBuildNovel(nwGUI, nwGUI.theProject)
|
nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiBuildNovel") is not None, timeout=1000)
|
||||||
|
|
||||||
|
nwBuild = getGuiItem("GuiBuildNovel")
|
||||||
|
assert isinstance(nwBuild, GuiBuildNovel)
|
||||||
|
|
||||||
|
assert nwBuild.viewCachedDoc()
|
||||||
assert nwBuild.htmlText == htmlText
|
assert nwBuild.htmlText == htmlText
|
||||||
assert nwBuild.htmlStyle == htmlStyle
|
assert nwBuild.htmlStyle == htmlStyle
|
||||||
assert nwBuild.nwdText == nwdText
|
assert nwBuild.nwdText == nwdText
|
||||||
@@ -659,7 +669,11 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
|
|||||||
# Split By Scene
|
# Split By Scene
|
||||||
assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
|
assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
nwSplit = GuiDocSplit(nwGUI, nwGUI.theProject)
|
nwGUI.mainMenu.aSplitDoc.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiDocSplit") is not None, timeout=1000)
|
||||||
|
|
||||||
|
nwSplit = getGuiItem("GuiDocSplit")
|
||||||
|
assert isinstance(nwSplit, GuiDocSplit)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
nwSplit.splitLevel.setCurrentIndex(2)
|
nwSplit.splitLevel.setCurrentIndex(2)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
@@ -691,7 +705,11 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
|
|||||||
# Split By Section
|
# Split By Section
|
||||||
assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
|
assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
nwSplit = GuiDocSplit(nwGUI, nwGUI.theProject)
|
nwGUI.mainMenu.aSplitDoc.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiDocSplit") is not None, timeout=1000)
|
||||||
|
|
||||||
|
nwSplit = getGuiItem("GuiDocSplit")
|
||||||
|
assert isinstance(nwSplit, GuiDocSplit)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
nwSplit.splitLevel.setCurrentIndex(3)
|
nwSplit.splitLevel.setCurrentIndex(3)
|
||||||
qtbot.wait(stepDelay)
|
qtbot.wait(stepDelay)
|
||||||
@@ -945,6 +963,7 @@ def testLoadProject(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp):
|
|||||||
assert nwGUI.openProject(nwMinimal)
|
assert nwGUI.openProject(nwMinimal)
|
||||||
assert nwGUI.closeProject()
|
assert nwGUI.closeProject()
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *args: None)
|
monkeypatch.setattr(GuiProjectLoad, "exec_", lambda *args: None)
|
||||||
monkeypatch.setattr(GuiProjectLoad, "result", lambda *args: QDialog.Accepted)
|
monkeypatch.setattr(GuiProjectLoad, "result", lambda *args: QDialog.Accepted)
|
||||||
nwGUI.mainMenu.aOpenProject.activate(QAction.Trigger)
|
nwGUI.mainMenu.aOpenProject.activate(QAction.Trigger)
|
||||||
@@ -954,36 +973,50 @@ def testLoadProject(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp):
|
|||||||
assert isinstance(nwLoad, GuiProjectLoad)
|
assert isinstance(nwLoad, GuiProjectLoad)
|
||||||
nwLoad.show()
|
nwLoad.show()
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
recentCount = nwLoad.listBox.topLevelItemCount()
|
recentCount = nwLoad.listBox.topLevelItemCount()
|
||||||
assert recentCount > 0
|
assert recentCount > 0
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
selItem = nwLoad.listBox.topLevelItem(0)
|
selItem = nwLoad.listBox.topLevelItem(0)
|
||||||
selPath = selItem.data(nwLoad.C_NAME, Qt.UserRole)
|
selPath = selItem.data(nwLoad.C_NAME, Qt.UserRole)
|
||||||
assert isinstance(selItem, QTreeWidgetItem)
|
assert isinstance(selItem, QTreeWidgetItem)
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
nwLoad.selPath.setText("")
|
nwLoad.selPath.setText("")
|
||||||
nwLoad.listBox.setCurrentItem(selItem)
|
nwLoad.listBox.setCurrentItem(selItem)
|
||||||
nwLoad._doSelectRecent()
|
nwLoad._doSelectRecent()
|
||||||
assert nwLoad.selPath.text() == selPath
|
assert nwLoad.selPath.text() == selPath
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Open), Qt.LeftButton)
|
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Open), Qt.LeftButton)
|
||||||
assert nwLoad.openPath == selPath
|
assert nwLoad.openPath == selPath
|
||||||
assert nwLoad.openState == nwLoad.OPEN_STATE
|
assert nwLoad.openState == nwLoad.OPEN_STATE
|
||||||
|
|
||||||
# Just create a new project load from scratch for the rest of the test
|
# Just create a new project load from scratch for the rest of the test
|
||||||
del nwLoad
|
del nwLoad
|
||||||
nwLoad = GuiProjectLoad(nwGUI)
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
|
nwGUI.mainMenu.aOpenProject.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiProjectLoad") is not None, timeout=1000)
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
|
nwLoad = getGuiItem("GuiProjectLoad")
|
||||||
|
assert isinstance(nwLoad, GuiProjectLoad)
|
||||||
nwLoad.show()
|
nwLoad.show()
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Cancel), Qt.LeftButton)
|
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Cancel), Qt.LeftButton)
|
||||||
assert nwLoad.openPath is None
|
assert nwLoad.openPath is None
|
||||||
assert nwLoad.openState == nwLoad.NONE_STATE
|
assert nwLoad.openState == nwLoad.NONE_STATE
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
nwLoad.show()
|
nwLoad.show()
|
||||||
qtbot.mouseClick(nwLoad.newButton, Qt.LeftButton)
|
qtbot.mouseClick(nwLoad.newButton, Qt.LeftButton)
|
||||||
assert nwLoad.openPath is None
|
assert nwLoad.openPath is None
|
||||||
assert nwLoad.openState == nwLoad.NEW_STATE
|
assert nwLoad.openState == nwLoad.NEW_STATE
|
||||||
|
|
||||||
|
qtbot.wait(stepDelay)
|
||||||
nwLoad.show()
|
nwLoad.show()
|
||||||
nwLoad._keyPressDelete()
|
nwLoad._keyPressDelete()
|
||||||
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
|
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
|
||||||
|
|||||||
Reference in New Issue
Block a user