From 7a9124ca5848425027684c34a1c47ea46130fdfe Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 21 Sep 2020 22:25:22 +0200 Subject: [PATCH] Finished Search/Replace test --- .github/workflows/pytest_cov.yml | 5 +--- tests/test_gui.py | 41 +++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pytest_cov.yml b/.github/workflows/pytest_cov.yml index 850152dd..1969d200 100644 --- a/.github/workflows/pytest_cov.yml +++ b/.github/workflows/pytest_cov.yml @@ -32,10 +32,7 @@ jobs: pip install pytest-qt pip install codecov - name: Run Tests - run: | - export DISPLAY=':99.0' - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - xvfb-run pytest -v --cov=nw --timeout=60 + run: xvfb-run pytest -v --cov=nw --timeout=60 - name: Upload to Codecov uses: codecov/codecov-action@v1 diff --git a/tests/test_gui.py b/tests/test_gui.py index dca5da31..f437bc76 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -847,12 +847,41 @@ def testTextSearch(qtbot, nwLipsum, nwTemp): assert not nwGUI.docEditor.docSearch.toggleRegEx.isChecked() assert not nwGUI.docEditor.docSearch.isRegEx - # assert nwGUI.docEditor.setCursorPosition(0) - nwGUI.docEditor.docSearch.searchBox.setFocus(True) - assert nwGUI.docEditor.docSearch.cycleFocus(True) - assert nwGUI.docEditor.docSearch.replaceBox.hasFocus() - assert nwGUI.docEditor.docSearch.cycleFocus(True) - assert nwGUI.docEditor.docSearch.searchBox.hasFocus() + # Close Search and Select "est" Again + nwGUI.docEditor.docSearch.cancelSearch.activate(QAction.Trigger) + assert nwGUI.docEditor.setCursorPosition(618) + nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor) + theCursor = nwGUI.docEditor.textCursor() + assert theCursor.selectedText() == "est" + + # Activate Search Again + nwGUI.mainMenu.aFind.activate(QAction.Trigger) + assert nwGUI.docEditor.docSearch.isVisible() + assert nwGUI.docEditor.docSearch.getSearchText() == "est" + + # Enable Full Word Search + nwGUI.docEditor.docSearch.toggleWord.activate(QAction.Trigger) + assert nwGUI.docEditor.docSearch.toggleWord.isChecked() + assert nwGUI.docEditor.docSearch.isWholeWord + + # Only One Match + nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) + assert abs(nwGUI.docEditor.getCursorPosition() - 620) < 3 + nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) + assert abs(nwGUI.docEditor.getCursorPosition() - 620) < 3 + + # Enable Next Doc Search + nwGUI.docEditor.docSearch.toggleProject.activate(QAction.Trigger) + assert nwGUI.docEditor.docSearch.toggleProject.isChecked() + assert nwGUI.docEditor.docSearch.doNextFile + + # Next Match + nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) + assert nwGUI.docEditor.theHandle == "2426c6f0ca922" # Next document + nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) + assert abs(nwGUI.docEditor.getCursorPosition() - 620) < 3 + nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) + assert abs(nwGUI.docEditor.getCursorPosition() - 1127) < 3 # qtbot.stopForInteraction() nwGUI.closeMain()