Update Lipsum test project
This commit is contained in:
@@ -1615,7 +1615,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
origText = nwGUI.docEditor.getText()
|
||||
|
||||
# Select the Word "est"
|
||||
nwGUI.docEditor.setCursorPosition(630)
|
||||
nwGUI.docEditor.setCursorPosition(645)
|
||||
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor)
|
||||
cursor = nwGUI.docEditor.textCursor()
|
||||
assert cursor.selectedText() == "est"
|
||||
@@ -1628,11 +1628,11 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
# Find next by enter key
|
||||
monkeypatch.setattr(nwGUI.docEditor.docSearch.searchBox, "hasFocus", lambda: True)
|
||||
qtbot.keyClick(nwGUI.docEditor.docSearch.searchBox, Qt.Key_Return, delay=KEY_DELAY)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 1284) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 1299) < 3
|
||||
|
||||
# Find next by button
|
||||
qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 1498) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 1513) < 3
|
||||
|
||||
# Activate loop search
|
||||
nwGUI.docEditor.docSearch.toggleLoop.activate(QAction.Trigger)
|
||||
@@ -1641,7 +1641,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
# Find next by menu Search > Find Next
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 632) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 647) < 3
|
||||
|
||||
# Close search
|
||||
nwGUI.docEditor.docSearch.cancelSearch.activate(QAction.Trigger)
|
||||
@@ -1680,13 +1680,13 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
# Set valid RegEx
|
||||
nwGUI.docEditor.docSearch.setSearchText(r"\bSus")
|
||||
qtbot.mouseClick(nwGUI.docEditor.docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 208) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 223) < 3
|
||||
|
||||
# Find next and then prev
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 309) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 324) < 3
|
||||
nwGUI.mainMenu.aFindPrev.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 208) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 223) < 3
|
||||
|
||||
# Make RegEx case sensitive
|
||||
nwGUI.docEditor.docSearch.toggleCase.activate(QAction.Trigger)
|
||||
@@ -1695,11 +1695,11 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
# Find next/prev (one result)
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 611) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 626) < 3
|
||||
nwGUI.mainMenu.aFindPrev.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 611) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 626) < 3
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 611) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 626) < 3
|
||||
|
||||
# Trigger replace
|
||||
nwGUI.mainMenu.aReplace.activate(QAction.Trigger)
|
||||
@@ -1716,22 +1716,22 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
assert nwGUI.docEditor.docSearch.doMatchCap is True
|
||||
|
||||
# Replace "Sus" with "Foo" via menu
|
||||
nwGUI.docEditor.setCursorPosition(590)
|
||||
nwGUI.docEditor.setCursorPosition(605)
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
nwGUI.mainMenu.aReplaceNext.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[608:619] == "Foopendisse"
|
||||
assert nwGUI.docEditor.getText()[623:634] == "Foopendisse"
|
||||
|
||||
# Find next/prev to loop file
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 208) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 223) < 3
|
||||
nwGUI.mainMenu.aFindPrev.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 1790) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 1805) < 3
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 208) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 223) < 3
|
||||
|
||||
# Replace "sus" with "foo" via replace button
|
||||
qtbot.mouseClick(nwGUI.docEditor.docSearch.replaceButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
assert nwGUI.docEditor.getText()[205:213] == "foocipit"
|
||||
assert nwGUI.docEditor.getText()[220:228] == "foocipit"
|
||||
|
||||
# Revert last two replaces
|
||||
assert nwGUI.docEditor.docAction(nwDocAction.UNDO)
|
||||
@@ -1745,7 +1745,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
# Close search and select "est" again
|
||||
nwGUI.docEditor.docSearch.cancelSearch.activate(QAction.Trigger)
|
||||
nwGUI.docEditor.setCursorPosition(630)
|
||||
nwGUI.docEditor.setCursorPosition(645)
|
||||
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor)
|
||||
cursor = nwGUI.docEditor.textCursor()
|
||||
assert cursor.selectedText() == "est"
|
||||
@@ -1762,9 +1762,9 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
# Only one match
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 632) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 647) < 3
|
||||
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger)
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 632) < 3
|
||||
assert abs(nwGUI.docEditor.getCursorPosition() - 647) < 3
|
||||
|
||||
# Enable next doc search
|
||||
nwGUI.docEditor.docSearch.toggleProject.activate(QAction.Trigger)
|
||||
|
||||
@@ -46,146 +46,146 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
|
||||
# Split By Chapter
|
||||
assert nwGUI.openDocument("4c4f28287af27") is True
|
||||
nwGUI.docEditor.setCursorPosition(42)
|
||||
cleanText = nwGUI.docEditor.getText()[39:86]
|
||||
nwGUI.docEditor.setCursorPosition(57)
|
||||
cleanText = nwGUI.docEditor.getText()[54:101]
|
||||
|
||||
# Bold
|
||||
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger)
|
||||
fmtStr = "**Pellentesque** nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:90] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:105] == fmtStr
|
||||
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Italic
|
||||
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger)
|
||||
fmtStr = "_Pellentesque_ nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:88] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:103] == fmtStr
|
||||
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Strikethrough
|
||||
nwGUI.mainMenu.aFmtStrike.activate(QAction.Trigger)
|
||||
fmtStr = "~~Pellentesque~~ nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:90] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:105] == fmtStr
|
||||
nwGUI.mainMenu.aFmtStrike.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Should get us back to plain
|
||||
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger)
|
||||
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger)
|
||||
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger)
|
||||
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Double Quotes
|
||||
nwGUI.mainMenu.aFmtDQuote.activate(QAction.Trigger)
|
||||
fmtStr = "“Pellentesque” nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:88] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:103] == fmtStr
|
||||
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Single Quotes
|
||||
nwGUI.mainMenu.aFmtSQuote.activate(QAction.Trigger)
|
||||
fmtStr = "‘Pellentesque’ nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:88] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:103] == fmtStr
|
||||
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Block Formats
|
||||
# =============
|
||||
# cSpell:ignore Pellentesque erat nulla posuere commodo
|
||||
nwGUI.docEditor.setCursorPosition(42)
|
||||
nwGUI.docEditor.setCursorPosition(57)
|
||||
|
||||
# Header 1
|
||||
nwGUI.mainMenu.aFmtHead1.activate(QAction.Trigger)
|
||||
fmtStr = "# Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:88] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:103] == fmtStr
|
||||
|
||||
# Header 2
|
||||
nwGUI.mainMenu.aFmtHead2.activate(QAction.Trigger)
|
||||
fmtStr = "## Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:89] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:104] == fmtStr
|
||||
|
||||
# Header 3
|
||||
nwGUI.mainMenu.aFmtHead3.activate(QAction.Trigger)
|
||||
fmtStr = "### Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:90] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:105] == fmtStr
|
||||
|
||||
# Header 4
|
||||
nwGUI.mainMenu.aFmtHead4.activate(QAction.Trigger)
|
||||
fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:91] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:106] == fmtStr
|
||||
|
||||
# Title Format
|
||||
nwGUI.mainMenu.aFmtTitle.activate(QAction.Trigger)
|
||||
fmtStr = "#! Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:89] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:104] == fmtStr
|
||||
|
||||
# Unnumbered Chapter
|
||||
nwGUI.mainMenu.aFmtUnNum.activate(QAction.Trigger)
|
||||
fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:90] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:105] == fmtStr
|
||||
|
||||
# Clear Format
|
||||
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Comment On
|
||||
nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger)
|
||||
fmtStr = "% Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:88] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:103] == fmtStr
|
||||
|
||||
# Comment Off
|
||||
nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Check comment with no space before text
|
||||
nwGUI.docEditor.setCursorPosition(39)
|
||||
nwGUI.docEditor.setCursorPosition(54)
|
||||
assert nwGUI.docEditor.insertText("%")
|
||||
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:87] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:102] == fmtStr
|
||||
|
||||
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Undo/Redo
|
||||
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
|
||||
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
|
||||
assert nwGUI.docEditor.getText()[39:87] == fmtStr
|
||||
assert nwGUI.docEditor.getText()[54:102] == fmtStr
|
||||
nwGUI.mainMenu.aEditRedo.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:86] == cleanText
|
||||
assert nwGUI.docEditor.getText()[54:101] == cleanText
|
||||
|
||||
# Cut, Copy and Paste
|
||||
nwGUI.docEditor.setCursorPosition(39)
|
||||
nwGUI.docEditor.setCursorPosition(54)
|
||||
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor)
|
||||
|
||||
nwGUI.mainMenu.aEditCut.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:89] == (
|
||||
assert nwGUI.docEditor.getText()[54:104] == (
|
||||
" nec erat ut nulla posuere commodo. Curabitur nisi"
|
||||
)
|
||||
|
||||
nwGUI.mainMenu.aEditPaste.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:89] == (
|
||||
assert nwGUI.docEditor.getText()[54:104] == (
|
||||
"Pellentesque nec erat ut nulla posuere commodo. Cu"
|
||||
)
|
||||
|
||||
nwGUI.docEditor.setCursorPosition(39)
|
||||
nwGUI.docEditor.setCursorPosition(54)
|
||||
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor)
|
||||
|
||||
nwGUI.mainMenu.aEditCopy.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:89] == (
|
||||
assert nwGUI.docEditor.getText()[54:104] == (
|
||||
"Pellentesque nec erat ut nulla posuere commodo. Cu"
|
||||
)
|
||||
|
||||
nwGUI.docEditor.setCursorPosition(39)
|
||||
nwGUI.docEditor.setCursorPosition(54)
|
||||
nwGUI.mainMenu.aEditPaste.activate(QAction.Trigger)
|
||||
assert nwGUI.docEditor.getText()[39:89] == (
|
||||
assert nwGUI.docEditor.getText()[54:104] == (
|
||||
"PellentesquePellentesque nec erat ut nulla posuere"
|
||||
)
|
||||
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger)
|
||||
|
||||
# Select Paragraph/All
|
||||
nwGUI.docEditor.setCursorPosition(42)
|
||||
nwGUI.docEditor.setCursorPosition(57)
|
||||
nwGUI.mainMenu.aSelectPar.activate(QAction.Trigger)
|
||||
cursor = nwGUI.docEditor.textCursor()
|
||||
assert cursor.selectedText() == (
|
||||
@@ -198,10 +198,10 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
"nunc lacus, imperdiet nec posuere ac, interdum non lectus."
|
||||
)
|
||||
|
||||
nwGUI.docEditor.setCursorPosition(42)
|
||||
nwGUI.docEditor.setCursorPosition(57)
|
||||
nwGUI.mainMenu.aSelectAll.activate(QAction.Trigger)
|
||||
cursor = nwGUI.docEditor.textCursor()
|
||||
assert len(cursor.selectedText()) == 1895
|
||||
assert len(cursor.selectedText()) == 1910
|
||||
|
||||
# Clear the Text
|
||||
nwGUI.docEditor.clear()
|
||||
@@ -349,7 +349,7 @@ def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum):
|
||||
|
||||
# Editor Context Menu
|
||||
cursor = nwGUI.docEditor.textCursor()
|
||||
cursor.setPosition(112)
|
||||
cursor.setPosition(127)
|
||||
nwGUI.docEditor.setTextCursor(cursor)
|
||||
rect = nwGUI.docEditor.cursorRect()
|
||||
|
||||
@@ -376,7 +376,7 @@ def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum):
|
||||
assert nwGUI.viewDocument("4c4f28287af27")
|
||||
|
||||
cursor = nwGUI.docViewer.textCursor()
|
||||
cursor.setPosition(112)
|
||||
cursor.setPosition(127)
|
||||
nwGUI.docViewer.setTextCursor(cursor)
|
||||
rect = nwGUI.docViewer.cursorRect()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user