Skip to content

Commit 7a878df

Browse files
authored
Merge faf01ff into c9bb993
2 parents c9bb993 + faf01ff commit 7a878df

3 files changed

Lines changed: 188 additions & 0 deletions

File tree

tests/system/robot/windowsTests.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
18+
from AssertsLib import AssertsLib as _AssertsLib
19+
import NvdaLib as _nvdaLib
20+
from NvdaLib import NvdaLib as _nvdaRobotLib
21+
_nvdaProcessAlias = _nvdaRobotLib.nvdaProcessAlias
22+
23+
builtIn: BuiltIn = BuiltIn()
24+
_process: _ProcessLib = _getLib("Process")
25+
_asserts: _AssertsLib = _getLib("AssertsLib")
26+
27+
28+
def open_clipboard_history() -> str:
29+
"""
30+
Returns the last read item after opening the clipboard history.
31+
"""
32+
spy = _nvdaLib.getSpyLib()
33+
spy.emulateKeyPress("leftWindows+v")
34+
spy.wait_for_speech_to_finish()
35+
return spy.get_last_speech()
36+
37+
38+
def write_and_copy_text(text: str):
39+
"""
40+
Expects an editable field to be focused.
41+
"""
42+
spy = _nvdaLib.getSpyLib()
43+
spy.emulateKeyPress("control+a")
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+
50+
51+
def read_clipboard_history(*expectedClipboardHistory: str):
52+
"""
53+
Expects the clipboard panel to already be open and focused on an editable field.
54+
"""
55+
spy = _nvdaLib.getSpyLib()
56+
spy.wait_for_speech_to_finish()
57+
for copyText in expectedClipboardHistory:
58+
spy.wait_for_specific_speech(copyText)
59+
spy.emulateKeyPress('rightArrow')
60+
61+
62+
def open_emoji_panel() -> str:
63+
"""
64+
Returns the first read emoji after opening the emoji panel.
65+
"""
66+
spy = _nvdaLib.getSpyLib()
67+
spy.emulateKeyPress("leftWindows+.")
68+
spy.wait_for_speech_to_finish()
69+
lastSpeech = spy.get_last_speech()
70+
try:
71+
return lastSpeech.split(" ")[1]
72+
except IndexError:
73+
raise AssertionError(f"Emoji not announced. Last speech: '{lastSpeech}'")
74+
75+
76+
def search_emojis(emojiNameSearchStr: str):
77+
"""
78+
Types a string search with the emoji panel open.
79+
Expects the emoji panel to already be open and focused on an editable field.
80+
"""
81+
spy = _nvdaLib.getSpyLib()
82+
for c in emojiNameSearchStr:
83+
spy.emulateKeyPress(c, blockUntilProcessed=False)
84+
spy.wait_for_speech_to_finish()
85+
86+
87+
def read_emojis(*expectedEmojiNameList: str):
88+
"""
89+
Navigates the emoji panel and confirms the expected emoji list.
90+
Expects the emoji panel to already be open.
91+
"""
92+
spy = _nvdaLib.getSpyLib()
93+
for emojiName in expectedEmojiNameList:
94+
spy.wait_for_specific_speech(emojiName)
95+
spy.emulateKeyPress('rightArrow')
96+
97+
98+
def open_windows_search():
99+
spy = _nvdaLib.getSpyLib()
100+
spy.emulateKeyPress("leftWindows+s")
101+
spy.wait_for_speech_to_finish()
102+
103+
104+
def close_windows_search():
105+
spy = _nvdaLib.getSpyLib()
106+
spy.emulateKeyPress("escape") # escape any focus or close the win search bar
107+
spy.emulateKeyPress("escape") # ensure the win search bar is closed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 windowsTests.py
16+
Library ScreenCapLibrary
17+
18+
Test Setup start NVDA standard-dontShowWelcomeDialog.ini
19+
Test Teardown default teardown
20+
21+
*** Keywords ***
22+
default teardown
23+
${screenshotName}= create_preserved_test_output_filename failedTest.png
24+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
25+
quit NVDA
26+
27+
setup and open windows search
28+
start NVDA standard-dontShowWelcomeDialog.ini
29+
open windows search
30+
31+
close windows search and teardown
32+
${screenshotName}= create_preserved_test_output_filename failedTest.png
33+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
34+
close windows search
35+
quit NVDA
36+
37+
*** Test Cases ***
38+
emoji panel search
39+
[Documentation] Read emoji by navigating the emoji panel
40+
[Setup] setup and open windows search
41+
[Teardown] close windows search and teardown
42+
[Tags] emojiPanel excluded_from_build # AppVeyor's Windows build doesn't have an emoji panel with searching
43+
open emoji panel
44+
search emojis came
45+
read emojis camel two-hump camel camera
46+
47+
48+
emoji panel open
49+
[Documentation] Confirm that opening the emoji panel announces an emoji
50+
[Setup] setup and open windows search
51+
[Teardown] close windows search and teardown
52+
[Tags] emojiPanel
53+
${firstEmoji}= open emoji panel # set expected first emoji
54+
search emojis ${firstEmoji}
55+
read emojis ${firstEmoji}
56+
57+
58+
clipboard history
59+
[Documentation] Copy text and read from the clipboard history
60+
[Setup] setup and open windows search
61+
[Teardown] close windows search and teardown
62+
[Tags] clipboard
63+
write and copy text foo
64+
write and copy text lorem ipsum
65+
write and copy text bar
66+
open clipboard history
67+
read clipboard history bar lorem ipsum foo
68+
69+
70+
toggle between emoji panel and clipboard history
71+
[Documentation] Toggle between clipboard history and emoji panel and ensure items are announced
72+
[Setup] setup and open windows search
73+
[Teardown] close windows search and teardown
74+
[Tags] emojiPanel clipboard
75+
write and copy text test toggle between
76+
${firstEmoji}= open emoji panel
77+
open clipboard history
78+
read clipboard history test toggle between
79+
open emoji panel
80+
read emojis ${firstEmoji}

tests/system/robotArgs.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
--pythonpath .\tests\system\libraries
55
--include NVDA
66
--exclude excluded_from_build
7+
--exclude emojiPanel
78
--variable whichNVDA:source
89
--variable installDir:

0 commit comments

Comments
 (0)