Skip to content

Commit 21685cf

Browse files
authored
Merge da7997f into 0d2b323
2 parents 0d2b323 + da7997f commit 21685cf

3 files changed

Lines changed: 187 additions & 2 deletions

File tree

tests/system/libraries/NotepadLib.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def _getTestCasePath(filename):
4949

5050
def exit_notepad(self):
5151
spy = _NvdaLib.getSpyLib()
52+
spy.emulateKeyPress('control+s')
5253
spy.emulateKeyPress('alt+f4')
53-
process.wait_for_process(self.notepadHandle, timeout="1 minute", on_timeout="continue")
54+
process.wait_for_process(self.notepadHandle, timeout="3 sec", on_timeout="continue")
5455

5556
def start_notepad(self, filePath):
5657
builtIn.log(f"starting notepad: {filePath}")
@@ -104,7 +105,7 @@ def _focusNotepad(self, startsWithTestCaseTitle: re.Pattern):
104105
f"{windowInformation}"
105106
)
106107

107-
def prepareNotepad(self, testCase: str) -> None:
108+
def prepareNotepad(self, testCase: str = "") -> None:
108109
"""
109110
Starts Notepad opening a file containing the plaintext sample.
110111
Different versions of notepad/windows have variations in how the title is presented.

tests/system/robot/windowsTests.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2021 NV Access Limited
3+
# This file may be used under the terms of the GNU General Public License, version 2 or later.
4+
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
5+
6+
"""Logic for testing NVDA interacting with the Windows system.
7+
"""
8+
import re as _re
9+
10+
# relative import not used for 'systemTestUtils' because the folder is added to the path for 'libraries'
11+
# imported methods start with underscore (_) so they don't get imported into robot files as keywords
12+
from SystemTestSpy import (
13+
_blockUntilConditionMet,
14+
_getLib,
15+
)
16+
17+
# Imported for type information
18+
import NvdaLib as _nvdaLib
19+
from NotepadLib import NotepadLib as _NotepadLib
20+
21+
_notepad: _NotepadLib = _getLib("NotepadLib")
22+
23+
EMOJI_PANNEL_PATTERNS = [
24+
_re.compile(r"level [0-9]+ ([A-z ]+) 1 of [0-9]+"),
25+
_re.compile(r"([A-z ]+) 1 of [0-9]+ level [0-9]+")
26+
]
27+
28+
29+
def _open_clipboard_history() -> str:
30+
return _nvdaLib.getSpeechAfterKey("leftWindows+v")
31+
32+
33+
def open_clipboard_history() -> str:
34+
"""
35+
Returns the last read item after opening the clipboard history.
36+
"""
37+
success, lastHistoryItem = _blockUntilConditionMet(
38+
getValue=_open_clipboard_history,
39+
giveUpAfterSeconds=2,
40+
intervalBetweenSeconds=0.2
41+
)
42+
if success:
43+
return lastHistoryItem
44+
raise AssertionError(f"Clipboard history not announced.")
45+
46+
47+
def copy_text():
48+
"""
49+
Expects an editable field to be focused.
50+
"""
51+
spy = _nvdaLib.getSpyLib()
52+
spy.emulateKeyPress("control+a")
53+
spy.emulateKeyPress("control+c")
54+
55+
56+
def read_clipboard_history(*expectedClipboardHistory: str):
57+
"""
58+
Expects the clipboard panel to already be open and focused on an editable field.
59+
"""
60+
spy = _nvdaLib.getSpyLib()
61+
spy.wait_for_speech_to_finish()
62+
for copyText in expectedClipboardHistory:
63+
spy.wait_for_specific_speech(copyText)
64+
spy.emulateKeyPress('rightArrow')
65+
66+
67+
def open_emoji_panel() -> str:
68+
"""
69+
Returns the first read emoji after opening the emoji panel.
70+
"""
71+
lastSpeech = _nvdaLib.getSpeechAfterKey("leftWindows+.")
72+
for pattern in EMOJI_PANNEL_PATTERNS:
73+
emojiMatch = _re.match(pattern, lastSpeech)
74+
if emojiMatch is not None:
75+
return emojiMatch.group(1)
76+
raise AssertionError(f"Emoji not announced. Last speech: '{lastSpeech}'")
77+
78+
79+
def search_emojis(emojiNameSearchStr: str):
80+
"""
81+
Types a string search with the emoji panel open.
82+
Expects the emoji panel to already be open and focused on an editable field.
83+
"""
84+
spy = _nvdaLib.getSpyLib()
85+
for c in emojiNameSearchStr:
86+
spy.emulateKeyPress(c, blockUntilProcessed=False)
87+
spy.wait_for_speech_to_finish()
88+
89+
90+
def read_emojis(*expectedEmojiNameList: str):
91+
"""
92+
Navigates the emoji panel and confirms the expected emoji list.
93+
Expects the emoji panel to already be open.
94+
"""
95+
spy = _nvdaLib.getSpyLib()
96+
for emojiName in expectedEmojiNameList:
97+
spy.wait_for_specific_speech(emojiName)
98+
spy.emulateKeyPress('rightArrow')
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2021 NV Access Limited
3+
# This file may be used under the terms of the GNU General Public License, version 2 or later.
4+
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
5+
6+
*** Settings ***
7+
Documentation Tests how NVDA interacts with various features of the Windows system
8+
Force Tags NVDA smoke test
9+
10+
# for start & quit in Test Setup and Test Test Teardown
11+
Library NvdaLib.py
12+
Library NotepadLib.py
13+
Library windowsTests.py
14+
Library ScreenCapLibrary
15+
16+
Test Setup start NVDA standard-dontShowWelcomeDialog.ini
17+
Test Teardown default teardown
18+
19+
*** Keywords ***
20+
default teardown
21+
${screenshotName}= create_preserved_test_output_filename failedTest.png
22+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
23+
quit NVDA
24+
25+
setup and open notepad
26+
start NVDA standard-dontShowWelcomeDialog.ini
27+
prepareNotepad
28+
29+
close notepad and teardown
30+
${screenshotName}= create_preserved_test_output_filename failedTest.png
31+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
32+
exit notepad
33+
quit NVDA
34+
35+
*** Test Cases ***
36+
emoji panel search
37+
[Documentation] Read emoji by navigating the emoji panel
38+
[Setup] setup and open notepad
39+
[Teardown] close notepad and teardown
40+
[Tags] emojiPanel excluded_from_build # AppVeyor's Windows build doesn't have an emoji panel with searching
41+
open emoji panel
42+
search emojis came
43+
read emojis camel two-hump camel camera
44+
45+
46+
emoji panel open
47+
[Documentation] Confirm that opening the emoji panel announces an emoji
48+
[Setup] setup and open notepad
49+
[Teardown] close notepad and teardown
50+
[Tags] emojiPanel
51+
${firstEmoji}= open emoji panel # set expected first emoji
52+
search emojis ${firstEmoji}
53+
read emojis ${firstEmoji}
54+
55+
56+
clipboard history
57+
[Documentation] Copy text and read from the clipboard history
58+
[Teardown] close notepad and teardown
59+
[Tags] clipboard
60+
prepareNotepad foo
61+
copy text
62+
exit notepad
63+
prepareNotepad lorem ipsum
64+
copy text
65+
exit notepad
66+
prepareNotepad bar
67+
copy text
68+
exit notepad
69+
prepareNotepad
70+
open clipboard history
71+
read clipboard history bar lorem ipsum foo
72+
73+
74+
toggle between emoji panel and clipboard history
75+
[Documentation] Toggle between clipboard history and emoji panel and ensure items are announced
76+
[Teardown] close notepad and teardown
77+
[Tags] emojiPanel clipboard
78+
prepareNotepad test toggle between
79+
copy text
80+
exit notepad
81+
prepareNotepad
82+
${firstEmoji}= open emoji panel
83+
open clipboard history
84+
read clipboard history test toggle between
85+
open emoji panel
86+
read emojis ${firstEmoji}

0 commit comments

Comments
 (0)