Add editor spell checking test coverage
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
%%~name: New Scene
|
%%~name: New Scene
|
||||||
%%~path: 000000000000d/000000000000f
|
%%~path: 000000000000d/000000000000f
|
||||||
%%~kind: NOVEL/DOCUMENT
|
%%~kind: NOVEL/DOCUMENT
|
||||||
%%~hash: fd5dc2f0c9767cb124b1bf2300d7a33b7780045e
|
%%~hash: 2a863dc53e09b0b1b0294ae7ea001853dddd596d
|
||||||
%%~date: 2023-08-25 18:08:01/2023-08-25 18:08:04
|
%%~date: 2023-10-17 20:52:56/2023-10-17 20:53:01
|
||||||
# Novel
|
# Novel
|
||||||
|
|
||||||
## Chapter
|
## Chapter
|
||||||
@@ -54,3 +54,5 @@ But don’t add a double space : See?
|
|||||||
|
|
||||||
>>‘Right-aligned text’
|
>>‘Right-aligned text’
|
||||||
|
|
||||||
|
Some text with tesst in it.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<novelWriterXML appVersion="2.0.7" hexVersion="0x020007f0" fileVersion="1.5" fileRevision="1" timeStamp="2023-06-03 18:23:02">
|
<novelWriterXML appVersion="2.2-alpha1" hexVersion="0x020200a1" fileVersion="1.5" fileRevision="1" timeStamp="2023-10-17 20:52:34">
|
||||||
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="3" autoCount="2" editTime="3">
|
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="3" autoCount="2" editTime="4">
|
||||||
<name>New Project</name>
|
<name>New Project</name>
|
||||||
<title>New Novel</title>
|
<title>New Novel</title>
|
||||||
<author>Jane Doe</author>
|
<author>Jane Doe</author>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<entry key="i000007" count="0" red="50" green="200" blue="0">Main</entry>
|
<entry key="i000007" count="0" red="50" green="200" blue="0">Main</entry>
|
||||||
</importance>
|
</importance>
|
||||||
</settings>
|
</settings>
|
||||||
<content items="11" novelWords="136" notesWords="27">
|
<content items="11" novelWords="142" notesWords="27">
|
||||||
<item handle="0000000000008" parent="None" root="0000000000008" order="0" type="ROOT" class="NOVEL">
|
<item handle="0000000000008" parent="None" root="0000000000008" order="0" type="ROOT" class="NOVEL">
|
||||||
<meta expanded="yes" />
|
<meta expanded="yes" />
|
||||||
<name status="s000000" import="i000004">Novel</name>
|
<name status="s000000" import="i000004">Novel</name>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<name status="s000000" import="i000004" active="yes">New Chapter</name>
|
<name status="s000000" import="i000004" active="yes">New Chapter</name>
|
||||||
</item>
|
</item>
|
||||||
<item handle="000000000000f" parent="000000000000d" root="0000000000008" order="1" type="FILE" class="NOVEL" layout="DOCUMENT">
|
<item handle="000000000000f" parent="000000000000d" root="0000000000008" order="1" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||||
<meta expanded="no" heading="H1" charCount="781" wordCount="129" paraCount="14" cursorPos="1010" />
|
<meta expanded="no" heading="H1" charCount="808" wordCount="135" paraCount="15" cursorPos="1026" />
|
||||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||||
</item>
|
</item>
|
||||||
<item handle="0000000000009" parent="None" root="0000000000009" order="1" type="ROOT" class="PLOT">
|
<item handle="0000000000009" parent="None" root="0000000000009" order="1" type="ROOT" class="PLOT">
|
||||||
|
|||||||
+161
-131
@@ -28,7 +28,7 @@ from tools import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import QDialog, QMessageBox, QInputDialog
|
from PyQt5.QtWidgets import QDialog, QMenu, QMessageBox, QInputDialog
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.enum import nwItemType, nwView, nwWidget
|
from novelwriter.enum import nwItemType, nwView, nwWidget
|
||||||
@@ -47,8 +47,7 @@ KEY_DELAY = 1
|
|||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiMain_ProjectBlocker(nwGUI):
|
def testGuiMain_ProjectBlocker(nwGUI):
|
||||||
"""Test the blocking of features when there's no project open.
|
"""Test the blocking of features when there's no project open."""
|
||||||
"""
|
|
||||||
# Test no-project blocking
|
# Test no-project blocking
|
||||||
assert nwGUI.closeProject() is True
|
assert nwGUI.closeProject() is True
|
||||||
assert nwGUI.saveProject() is False
|
assert nwGUI.saveProject() is False
|
||||||
@@ -254,20 +253,25 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
||||||
assert nwGUI.openSelectedItem()
|
assert nwGUI.openSelectedItem()
|
||||||
|
|
||||||
|
# Text Editor
|
||||||
|
# ===========
|
||||||
|
|
||||||
|
docEditor: GuiDocEditor = nwGUI.docEditor
|
||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI.switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Jane Doe":
|
for c in "# Jane Doe":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@tag: Jane":
|
for c in "@tag: Jane":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "This is a file about Jane.":
|
for c in "This is a file about Jane.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Add a Plot File
|
# Add a Plot File
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI.switchFocus(nwWidget.TREE)
|
||||||
@@ -278,18 +282,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI.switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Main Plot":
|
for c in "# Main Plot":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@tag: MainPlot":
|
for c in "@tag: MainPlot":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "This is a file detailing the main plot.":
|
for c in "This is a file detailing the main plot.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Add a World File
|
# Add a World File
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI.switchFocus(nwWidget.TREE)
|
||||||
@@ -299,24 +303,24 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
assert nwGUI.openSelectedItem()
|
assert nwGUI.openSelectedItem()
|
||||||
|
|
||||||
# Add Some Text
|
# Add Some Text
|
||||||
nwGUI.docEditor.replaceText("Hello World!")
|
docEditor.replaceText("Hello World!")
|
||||||
assert nwGUI.docEditor.getText() == "Hello World!"
|
assert docEditor.getText() == "Hello World!"
|
||||||
nwGUI.docEditor.replaceText("")
|
docEditor.replaceText("")
|
||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI.switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Main Location":
|
for c in "# Main Location":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@tag: Home":
|
for c in "@tag: Home":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "This is a file describing Jane's home.":
|
for c in "This is a file describing Jane's home.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Trigger autosaves before making more changes
|
# Trigger autosaves before making more changes
|
||||||
nwGUI._autoSaveDocument()
|
nwGUI._autoSaveDocument()
|
||||||
@@ -332,67 +336,67 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI.switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(nwGUI.docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Novel":
|
for c in "# Novel":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "## Chapter":
|
for c in "## Chapter":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "@pov: Jane":
|
for c in "@pov: Jane":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@plot: MainPlot":
|
for c in "@plot: MainPlot":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "### Scene":
|
for c in "### Scene":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "% How about a comment?":
|
for c in "% How about a comment?":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@pov: Jane":
|
for c in "@pov: Jane":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@plot: MainPlot":
|
for c in "@plot: MainPlot":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@location: Home":
|
for c in "@location: Home":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "#### Some Section":
|
for c in "#### Some Section":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "@char: Jane":
|
for c in "@char: Jane":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "This is a paragraph of nonsense text.":
|
for c in "This is a paragraph of nonsense text.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Don't allow Shift+Enter to insert a line separator (issue #1150)
|
# Don't allow Shift+Enter to insert a line separator (issue #1150)
|
||||||
for c in "This is another paragraph":
|
for c in "This is another paragraph":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Enter, modifier=Qt.ShiftModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Enter, modifier=Qt.ShiftModifier, delay=KEY_DELAY)
|
||||||
for c in "with a line separator in it.":
|
for c in "with a line separator in it.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Auto-Replace
|
# Auto-Replace
|
||||||
# ============
|
# ============
|
||||||
@@ -401,111 +405,137 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
"This is another paragraph of much longer nonsense text. "
|
"This is another paragraph of much longer nonsense text. "
|
||||||
"It is in fact 1 very very NONSENSICAL nonsense text! "
|
"It is in fact 1 very very NONSENSICAL nonsense text! "
|
||||||
):
|
):
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
for c in "We can also try replacing \"quotes\", even single 'quotes' are replaced. ":
|
for c in "We can also try replacing \"quotes\", even single 'quotes' are replaced. ":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
for c in "Isn't that nice? ":
|
for c in "Isn't that nice? ":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
for c in "We can hyphen-ate, make dashes -- and even longer dashes --- if we want. ":
|
for c in "We can hyphen-ate, make dashes -- and even longer dashes --- if we want. ":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
for c in "Ellipsis? Not a problem either ... ":
|
for c in "Ellipsis? Not a problem either ... ":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
for c in "How about three hyphens - -":
|
for c in "How about three hyphens - -":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Left, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Left, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Right, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Right, delay=KEY_DELAY)
|
||||||
for c in "- for long dash? It works too.":
|
for c in "- for long dash? It works too.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "\"Full line double quoted text.\"":
|
for c in "\"Full line double quoted text.\"":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "'Full line single quoted text.'":
|
for c in "'Full line single quoted text.'":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Insert spaces before and after quotes
|
# Insert spaces before and after quotes
|
||||||
nwGUI.docEditor._typPadBefore = "\u201d"
|
docEditor._typPadBefore = "\u201d"
|
||||||
nwGUI.docEditor._typPadAfter = "\u201c"
|
docEditor._typPadAfter = "\u201c"
|
||||||
|
|
||||||
for c in "Some \"double quoted text with spaces padded\".":
|
for c in "Some \"double quoted text with spaces padded\".":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
nwGUI.docEditor._typPadBefore = ""
|
docEditor._typPadBefore = ""
|
||||||
nwGUI.docEditor._typPadAfter = ""
|
docEditor._typPadAfter = ""
|
||||||
|
|
||||||
# Insert spaces before colon, but ignore tags and synopsis
|
# Insert spaces before colon, but ignore tags and synopsis
|
||||||
nwGUI.docEditor._typPadBefore = ":"
|
docEditor._typPadBefore = ":"
|
||||||
|
|
||||||
for c in "@object: NoSpaceAdded":
|
for c in "@object: NoSpaceAdded":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "% synopsis: No space before this colon.":
|
for c in "% synopsis: No space before this colon.":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "Add space before this colon: See?":
|
for c in "Add space before this colon: See?":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "But don't add a double space : See?":
|
for c in "But don't add a double space : See?":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
nwGUI.docEditor._typPadBefore = ""
|
docEditor._typPadBefore = ""
|
||||||
|
|
||||||
# Indent and Align
|
# Indent and Align
|
||||||
# ================
|
# ================
|
||||||
|
|
||||||
for c in "\t\"Tab-indented text\"":
|
for c in "\t\"Tab-indented text\"":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">\"Paragraph-indented text\"":
|
for c in ">\"Paragraph-indented text\"":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">>\"Right-aligned text\"":
|
for c in ">>\"Right-aligned text\"":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "\t'Tab-indented text'":
|
for c in "\t'Tab-indented text'":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">'Paragraph-indented text'":
|
for c in ">'Paragraph-indented text'":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">>'Right-aligned text'":
|
for c in ">>'Right-aligned text'":
|
||||||
qtbot.keyClick(nwGUI.docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
nwGUI.docEditor.wCounterDoc.run()
|
docEditor.wCounterDoc.run()
|
||||||
|
|
||||||
|
# Spell Checking
|
||||||
|
# ==============
|
||||||
|
|
||||||
|
for c in "Some text with tesst in it.":
|
||||||
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
|
currPos = docEditor.getCursorPosition()
|
||||||
|
assert docEditor._qDocument.spellErrorAtPos(currPos) == ("", -1, -1, [])
|
||||||
|
|
||||||
|
errPos = currPos - 13
|
||||||
|
word, cPos, cLen, suggest = docEditor._qDocument.spellErrorAtPos(errPos)
|
||||||
|
assert word == "tesst"
|
||||||
|
assert cPos == 15
|
||||||
|
assert cLen == 5
|
||||||
|
assert "test" in suggest
|
||||||
|
|
||||||
|
with monkeypatch.context() as mp:
|
||||||
|
mp.setattr(QMenu, "exec_", lambda *a: None)
|
||||||
|
docEditor.setCursorPosition(errPos)
|
||||||
|
docEditor._openSpellContext()
|
||||||
|
|
||||||
|
# Check Files
|
||||||
|
# ===========
|
||||||
|
|
||||||
# Save the document
|
# Save the document
|
||||||
assert nwGUI.docEditor.docChanged
|
assert docEditor.docChanged
|
||||||
assert nwGUI.saveDocument()
|
assert nwGUI.saveDocument()
|
||||||
assert not nwGUI.docEditor.docChanged
|
assert not docEditor.docChanged
|
||||||
nwGUI.rebuildIndex()
|
nwGUI.rebuildIndex()
|
||||||
|
|
||||||
# Open and view the edited document
|
# Open and view the edited document
|
||||||
|
|||||||
Reference in New Issue
Block a user