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] 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()