74 lines
2.2 KiB
Python
74 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""novelWriter Main GUI Outline Class Tester
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from PyQt5.QtCore import Qt, QPoint
|
|
from PyQt5.QtWidgets import QAction, QTreeWidgetItem, QMessageBox
|
|
|
|
from nw.constants import nwOutline
|
|
|
|
keyDelay = 2
|
|
typeDelay = 1
|
|
stepDelay = 20
|
|
|
|
@pytest.mark.gui
|
|
def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
|
|
"""Test the outline view.
|
|
"""
|
|
# Block message box
|
|
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
|
|
|
|
assert nwGUI.openProject(nwLipsum)
|
|
nwGUI.mainConf.lastPath = nwLipsum
|
|
|
|
nwGUI.rebuildIndex()
|
|
nwGUI.mainTabs.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() == "<b>Title</b>"
|
|
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() == "230"
|
|
assert nwGUI.projMeta.wCValue.text() == "40"
|
|
assert nwGUI.projMeta.pCValue.text() == "3"
|
|
|
|
# Scene One
|
|
actItem = nwGUI.projView.topLevelItem(1)
|
|
chpItem = actItem.child(0)
|
|
selItem = chpItem.child(0)
|
|
|
|
nwGUI.projView.setCurrentItem(selItem)
|
|
assert nwGUI.projMeta.titleLabel.text() == "<b>Scene</b>"
|
|
assert nwGUI.projMeta.titleValue.text() == "Scene One"
|
|
assert nwGUI.projMeta.fileValue.text() == "Scene One"
|
|
assert nwGUI.projMeta.itemValue.text() == "Finished"
|
|
|
|
# Click POV Link
|
|
assert nwGUI.projMeta.povKeyValue.text() == "<a href='#pov=Bod'>Bod</a>"
|
|
nwGUI.projMeta._tagClicked("#pov=Bod")
|
|
assert nwGUI.docViewer.theHandle == "4c4f28287af27"
|
|
|
|
# qtbot.stopForInteraction()
|
|
|
|
# END Test testGuiOutline_Main
|