Skip to content

Commit 011f364

Browse files
authored
Merge c5c353b into 34e831b
2 parents 34e831b + c5c353b commit 011f364

2 files changed

Lines changed: 180 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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
*** Settings ***
6+
Documentation Tests how NVDA interacts with various features of the Windows system
7+
Force Tags NVDA smoke test
8+
9+
# for start & quit in Test Setup and Test Test Teardown
10+
Library NvdaLib.py
11+
Library windowsTests.py
12+
Library ScreenCapLibrary
13+
14+
Test Setup start NVDA standard-dontShowWelcomeDialog.ini
15+
Test Teardown default teardown
16+
17+
*** Keywords ***
18+
default teardown
19+
${screenshotName}= create_preserved_test_output_filename failedTest.png
20+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
21+
quit NVDA
22+
23+
setup and open windows search
24+
start NVDA standard-dontShowWelcomeDialog.ini
25+
open windows search
26+
27+
close windows search and teardown
28+
${screenshotName}= create_preserved_test_output_filename failedTest.png
29+
Run Keyword If Test Failed Take Screenshot ${screenShotName}
30+
close windows search
31+
quit NVDA
32+
33+
*** Test Cases ***
34+
emoji panel search
35+
[Documentation] Read emoji by navigating the emoji panel
36+
[Setup] setup and open windows search
37+
[Teardown] close windows search and teardown
38+
[Tags] excluded_from_build # AppVeyor's Windows build doesn't have an emoji panel with searching
39+
open emoji panel
40+
search emojis came
41+
read emojis camel two-hump camel camera
42+
43+
44+
emoji panel open
45+
[Documentation] Confirm that opening the emoji panel announces an emoji
46+
[Setup] setup and open windows search
47+
[Teardown] close windows search and teardown
48+
${firstEmoji}= open emoji panel # set expected first emoji
49+
search emojis ${firstEmoji}
50+
read emojis ${firstEmoji}
51+
52+
53+
clipboard history
54+
[Documentation] Copy text and read from the clipboard history
55+
[Setup] setup and open windows search
56+
[Teardown] close windows search and teardown
57+
write and copy text foo
58+
write and copy text lorem ipsum
59+
write and copy text bar
60+
open clipboard history
61+
read clipboard history bar lorem ipsum foo
62+
63+
64+
toggle between emoji panel and clipboard history
65+
[Documentation] Toggle between clipboard history and emoji panel and ensure items are announced
66+
[Setup] setup and open windows search
67+
[Teardown] close windows search and teardown
68+
write and copy text test toggle between
69+
${firstEmoji}= open emoji panel
70+
open clipboard history
71+
read clipboard history test toggle between
72+
open emoji panel
73+
read emojis ${firstEmoji}

0 commit comments

Comments
 (0)