Skip to content

Commit dba5880

Browse files
authored
Merge a7d3f31 into cbf7407
2 parents cbf7407 + a7d3f31 commit dba5880

3 files changed

Lines changed: 180 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: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
from robot.libraries.BuiltIn import BuiltIn
9+
# relative import not used for 'systemTestUtils' because the folder is added to the path for 'libraries'
10+
# imported methods start with underscore (_) so they don't get imported into robot files as keywords
11+
from SystemTestSpy import (
12+
_getLib,
13+
)
14+
15+
# Imported for type information
16+
from robot.libraries.Process import Process as _ProcessLib
17+
from AssertsLib import AssertsLib as _AssertsLib
18+
import NvdaLib as _nvdaLib
19+
from NvdaLib import NvdaLib as _nvdaRobotLib
20+
_nvdaProcessAlias = _nvdaRobotLib.nvdaProcessAlias
21+
22+
builtIn: BuiltIn = BuiltIn()
23+
_process: _ProcessLib = _getLib("Process")
24+
_asserts: _AssertsLib = _getLib("AssertsLib")
25+
26+
27+
def open_clipboard_history() -> str:
28+
"""
29+
Returns the last read item after opening the clipboard history.
30+
"""
31+
spy = _nvdaLib.getSpyLib()
32+
spy.emulateKeyPress("leftWindows+v")
33+
spy.wait_for_speech_to_finish()
34+
return spy.get_last_speech()
35+
36+
37+
def write_and_copy_text(text: str):
38+
"""
39+
Expects an editable field to be focused.
40+
"""
41+
spy = _nvdaLib.getSpyLib()
42+
spy.emulateKeyPress("control+a")
43+
spy.emulateKeyPress("backspace")
44+
for c in text:
45+
spy.emulateKeyPress(c)
46+
spy.wait_for_speech_to_finish()
47+
spy.emulateKeyPress("control+a")
48+
spy.emulateKeyPress("control+x")
49+
spy.reset_all_speech_index()
50+
51+
52+
def read_clipboard_history(*expectedClipboardHistory: str):
53+
"""
54+
Expects the clipboard panel to already be open and focused on an editable field.
55+
"""
56+
spy = _nvdaLib.getSpyLib()
57+
spy.wait_for_speech_to_finish()
58+
for copyText in expectedClipboardHistory:
59+
spy.wait_for_specific_speech(copyText)
60+
spy.emulateKeyPress('rightArrow')
61+
62+
63+
def open_emoji_panel() -> str:
64+
"""
65+
Returns the first read emoji after opening the emoji panel.
66+
"""
67+
spy = _nvdaLib.getSpyLib()
68+
spy.emulateKeyPress("leftWindows+.")
69+
spy.wait_for_speech_to_finish()
70+
lastSpeech = spy.get_last_speech()
71+
try:
72+
return lastSpeech.split(" ")[1]
73+
except IndexError:
74+
raise AssertionError(f"Emoji not announced. Last speech: '{lastSpeech}'")
75+
76+
77+
def search_emojis(emojiNameSearchStr: str):
78+
"""
79+
Types a string search with the emoji panel open.
80+
Expects the emoji panel to already be open and focused on an editable field.
81+
"""
82+
spy = _nvdaLib.getSpyLib()
83+
for c in emojiNameSearchStr:
84+
spy.emulateKeyPress(c, blockUntilProcessed=False)
85+
spy.wait_for_speech_to_finish()
86+
87+
88+
def read_emojis(*expectedEmojiNameList: str):
89+
"""
90+
Navigates the emoji panel and confirms the expected emoji list.
91+
Expects the emoji panel to already be open.
92+
"""
93+
spy = _nvdaLib.getSpyLib()
94+
for emojiName in expectedEmojiNameList:
95+
spy.wait_for_specific_speech(emojiName)
96+
spy.emulateKeyPress('rightArrow')
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
# TODO: NVDA fails to announce emojis sometimes, as such the emojiPanel tag is excluded in robotArgs.robot
7+
# to be fixed with #11485
8+
9+
*** Settings ***
10+
Documentation Tests how NVDA interacts with various features of the Windows system
11+
Force Tags NVDA smoke test
12+
13+
# for start & quit in Test Setup and Test Test Teardown
14+
Library NvdaLib.py
15+
Library NotepadLib.py
16+
Library windowsTests.py
17+
Library ScreenCapLibrary
18+
19+
Test Setup start NVDA standard-dontShowWelcomeDialog.ini
20+
Test Teardown default teardown
21+
22+
*** Keywords ***
23+
default teardown
24+
${screenshotName}= create_preserved_test_output_filename failedTest.png
25+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
26+
quit NVDA
27+
28+
setup and open notepad
29+
start NVDA standard-dontShowWelcomeDialog.ini
30+
prepareNotepad
31+
32+
close notepad and teardown
33+
${screenshotName}= create_preserved_test_output_filename failedTest.png
34+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
35+
exit notepad
36+
quit NVDA
37+
38+
*** Test Cases ***
39+
emoji panel search
40+
[Documentation] Read emoji by navigating the emoji panel
41+
[Setup] setup and open notepad
42+
[Teardown] close notepad and teardown
43+
[Tags] emojiPanel excluded_from_build # AppVeyor's Windows build doesn't have an emoji panel with searching
44+
open emoji panel
45+
search emojis came
46+
read emojis camel two-hump camel camera
47+
48+
49+
emoji panel open
50+
[Documentation] Confirm that opening the emoji panel announces an emoji
51+
[Setup] setup and open notepad
52+
[Teardown] close notepad and teardown
53+
[Tags] emojiPanel
54+
${firstEmoji}= open emoji panel # set expected first emoji
55+
search emojis ${firstEmoji}
56+
read emojis ${firstEmoji}
57+
58+
59+
clipboard history
60+
[Documentation] Copy text and read from the clipboard history
61+
[Setup] setup and open notepad
62+
[Teardown] close notepad and teardown
63+
[Tags] clipboard
64+
write and copy text foo
65+
write and copy text lorem ipsum
66+
write and copy text bar
67+
open clipboard history
68+
read clipboard history bar lorem ipsum foo
69+
70+
71+
toggle between emoji panel and clipboard history
72+
[Documentation] Toggle between clipboard history and emoji panel and ensure items are announced
73+
[Setup] setup and open notepad
74+
[Teardown] close notepad and teardown
75+
[Tags] emojiPanel clipboard
76+
write and copy text test toggle between
77+
${firstEmoji}= open emoji panel
78+
open clipboard history
79+
read clipboard history test toggle between
80+
open emoji panel
81+
read emojis ${firstEmoji}

0 commit comments

Comments
 (0)