| 1 |
# Unit tests for ax_utilities_action.py methods. |
| 2 |
# |
| 3 |
# Copyright 2026 Igalia, S.L. |
| 4 |
# Author: Joanmarie Diggs <[email protected]> |
| 5 |
# |
| 6 |
# This library is free software; you can redistribute it and/or |
| 7 |
# modify it under the terms of the GNU Lesser General Public |
| 8 |
# License as published by the Free Software Foundation; either |
| 9 |
# version 2.1 of the License, or (at your option) any later version. |
| 10 |
# |
| 11 |
# This library is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
# Lesser General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU Lesser General Public |
| 17 |
# License along with this library; if not, write to the |
| 18 |
# Free Software Foundation, Inc., Franklin Street, Fifth Floor, |
| 19 |
# Boston MA 02110-1301 USA. |
| 20 |
|
| 21 |
# pylint: disable=import-outside-toplevel |
| 22 |
# pylint: disable=protected-access |
| 23 |
|
| 24 |
"""Unit tests for ax_utilities_action.py methods.""" |
| 25 |
|
| 26 |
from __future__ import annotations |
| 27 |
|
| 28 |
from typing import TYPE_CHECKING |
| 29 |
|
| 30 |
import gi |
| 31 |
import pytest |
| 32 |
|
| 33 |
gi.require_version("Atspi", "2.0") |
| 34 |
from gi.repository import Atspi |
| 35 |
|
| 36 |
if TYPE_CHECKING: |
| 37 |
from unittest.mock import MagicMock |
| 38 |
|
| 39 |
from .orca_test_context import OrcaTestContext |
| 40 |
|
| 41 |
|
| 42 |
@pytest.mark.unit |
| 43 |
class TestAXUtilitiesAction: |
| 44 |
"""Test AXUtilitiesAction class methods.""" |
| 45 |
|
| 46 |
def _setup_dependencies(self, test_context: OrcaTestContext) -> dict[str, MagicMock]: |
| 47 |
"""Set up mocks for ax_utilities_action dependencies.""" |
| 48 |
|
| 49 |
core_modules = [ |
| 50 |
"orca.debug", |
| 51 |
"orca.messages", |
| 52 |
"orca.input_event", |
| 53 |
"orca.keybindings", |
| 54 |
"orca.cmdnames", |
| 55 |
"orca.dbus_service", |
| 56 |
"orca.script_manager", |
| 57 |
"orca.orca_i18n", |
| 58 |
"orca.guilabels", |
| 59 |
"orca.text_attribute_names", |
| 60 |
"orca.focus_manager", |
| 61 |
"orca.braille", |
| 62 |
"orca.keynames", |
| 63 |
] |
| 64 |
|
| 65 |
essential_modules = {} |
| 66 |
for module_name in core_modules: |
| 67 |
mock_module = test_context.Mock() |
| 68 |
test_context.patch_module(module_name, mock_module) |
| 69 |
essential_modules[module_name] = mock_module |
| 70 |
|
| 71 |
test_context.configure_shared_module_behaviors(essential_modules) |
| 72 |
keynames_mock = essential_modules["orca.keynames"] |
| 73 |
keynames_mock.KEY_BACKSPACE = "BackSpace" |
| 74 |
keynames_mock.KEY_DELETE = "Delete" |
| 75 |
keynames_mock.KEY_TAB = "Tab" |
| 76 |
keynames_mock.KEY_RETURN = "Return" |
| 77 |
keynames_mock.KEY_ESCAPE = "Escape" |
| 78 |
|
| 79 |
return essential_modules |
| 80 |
|
| 81 |
def test_get_action_names_no_actions(self, test_context: OrcaTestContext) -> None: |
| 82 |
"""Test AXUtilitiesAction.get_action_names with no actions.""" |
| 83 |
|
| 84 |
self._setup_dependencies(test_context) |
| 85 |
from orca.ax_action import AXAction |
| 86 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 87 |
|
| 88 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 89 |
test_context.patch_object(AXAction, "get_n_actions", return_value=0) |
| 90 |
result = AXUtilitiesAction.get_action_names(mock_accessible) |
| 91 |
assert not result |
| 92 |
|
| 93 |
def test_get_action_names_with_actions(self, test_context: OrcaTestContext) -> None: |
| 94 |
"""Test AXUtilitiesAction.get_action_names with multiple actions.""" |
| 95 |
|
| 96 |
self._setup_dependencies(test_context) |
| 97 |
from orca.ax_action import AXAction |
| 98 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 99 |
|
| 100 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 101 |
test_context.patch_object(AXAction, "get_n_actions", return_value=3) |
| 102 |
|
| 103 |
def mock_get_action_name(_obj, i) -> str: |
| 104 |
names = ["click", "", "press"] |
| 105 |
return names[i] |
| 106 |
|
| 107 |
test_context.patch_object(AXAction, "get_action_name", new=mock_get_action_name) |
| 108 |
result = AXUtilitiesAction.get_action_names(mock_accessible) |
| 109 |
assert result == ["click", "press"] |
| 110 |
|
| 111 |
def test_get_action_index_found(self, test_context: OrcaTestContext) -> None: |
| 112 |
"""Test AXUtilitiesAction.get_action_index found action.""" |
| 113 |
|
| 114 |
self._setup_dependencies(test_context) |
| 115 |
from orca.ax_action import AXAction |
| 116 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 117 |
|
| 118 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 119 |
test_context.patch_object( |
| 120 |
AXAction, |
| 121 |
"normalize_action_name", |
| 122 |
side_effect=lambda name: name.lower(), |
| 123 |
) |
| 124 |
test_context.patch_object(AXAction, "get_n_actions", return_value=2) |
| 125 |
|
| 126 |
def mock_get_action_name(_obj, index) -> str: |
| 127 |
if index == 0: |
| 128 |
return "press" |
| 129 |
return "click" |
| 130 |
|
| 131 |
test_context.patch_object(AXAction, "get_action_name", new=mock_get_action_name) |
| 132 |
result = AXUtilitiesAction.get_action_index(mock_accessible, "click") |
| 133 |
assert result == 1 |
| 134 |
|
| 135 |
def test_get_action_index_not_found(self, test_context: OrcaTestContext) -> None: |
| 136 |
"""Test AXUtilitiesAction.get_action_index not found.""" |
| 137 |
|
| 138 |
self._setup_dependencies(test_context) |
| 139 |
from orca.ax_action import AXAction |
| 140 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 141 |
|
| 142 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 143 |
test_context.patch_object( |
| 144 |
AXAction, |
| 145 |
"normalize_action_name", |
| 146 |
side_effect=lambda name: name.lower(), |
| 147 |
) |
| 148 |
test_context.patch_object(AXAction, "get_n_actions", return_value=2) |
| 149 |
test_context.patch_object(AXAction, "get_action_name", return_value="press") |
| 150 |
result = AXUtilitiesAction.get_action_index(mock_accessible, "click") |
| 151 |
assert result == -1 |
| 152 |
|
| 153 |
def test_do_named_action_success(self, test_context: OrcaTestContext) -> None: |
| 154 |
"""Test AXUtilitiesAction.do_named_action success.""" |
| 155 |
|
| 156 |
self._setup_dependencies(test_context) |
| 157 |
from orca.ax_action import AXAction |
| 158 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 159 |
|
| 160 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 161 |
test_context.patch_object(AXUtilitiesAction, "get_action_index", return_value=0) |
| 162 |
test_context.patch_object(AXAction, "do_action", return_value=True) |
| 163 |
result = AXUtilitiesAction.do_named_action(mock_accessible, "click") |
| 164 |
assert result is True |
| 165 |
|
| 166 |
def test_do_named_action_not_found(self, test_context: OrcaTestContext) -> None: |
| 167 |
"""Test AXUtilitiesAction.do_named_action action not found.""" |
| 168 |
|
| 169 |
self._setup_dependencies(test_context) |
| 170 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 171 |
|
| 172 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 173 |
test_context.patch_object(AXUtilitiesAction, "get_action_index", return_value=-1) |
| 174 |
result = AXUtilitiesAction.do_named_action(mock_accessible, "click") |
| 175 |
assert result is False |
| 176 |
|
| 177 |
def test_find_first_action_with_keybinding_found( |
| 178 |
self, |
| 179 |
test_context: OrcaTestContext, |
| 180 |
) -> None: |
| 181 |
"""Test AXUtilitiesAction._find_first_action_with_keybinding found action.""" |
| 182 |
|
| 183 |
self._setup_dependencies(test_context) |
| 184 |
from orca.ax_action import AXAction |
| 185 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 186 |
|
| 187 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 188 |
test_context.patch_object(AXAction, "get_n_actions", return_value=2) |
| 189 |
|
| 190 |
def mock_get_action_key_binding(_obj, index) -> str: |
| 191 |
if index == 0: |
| 192 |
return "" |
| 193 |
return "Alt+F" |
| 194 |
|
| 195 |
test_context.patch_object( |
| 196 |
AXAction, |
| 197 |
"get_action_key_binding", |
| 198 |
new=mock_get_action_key_binding, |
| 199 |
) |
| 200 |
result = AXUtilitiesAction._find_first_action_with_keybinding(mock_accessible) |
| 201 |
assert result == 1 |
| 202 |
|
| 203 |
def test_find_first_action_with_keybinding_not_found( |
| 204 |
self, |
| 205 |
test_context: OrcaTestContext, |
| 206 |
) -> None: |
| 207 |
"""Test AXUtilitiesAction._find_first_action_with_keybinding not found.""" |
| 208 |
|
| 209 |
self._setup_dependencies(test_context) |
| 210 |
from orca.ax_action import AXAction |
| 211 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 212 |
|
| 213 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 214 |
test_context.patch_object(AXAction, "get_n_actions", return_value=2) |
| 215 |
test_context.patch_object(AXAction, "get_action_key_binding", return_value="") |
| 216 |
result = AXUtilitiesAction._find_first_action_with_keybinding(mock_accessible) |
| 217 |
assert result == -1 |
| 218 |
|
| 219 |
@pytest.mark.parametrize( |
| 220 |
"case", |
| 221 |
[ |
| 222 |
{ |
| 223 |
"id": "empty_string", |
| 224 |
"sequence": "", |
| 225 |
"gtk_result": None, |
| 226 |
"localized": None, |
| 227 |
"expected": "", |
| 228 |
}, |
| 229 |
{ |
| 230 |
"id": "normalizes_plus_separated", |
| 231 |
"sequence": "Ctrl+F", |
| 232 |
"gtk_result": "Ctrl+F", |
| 233 |
"localized": "Ctrl+F", |
| 234 |
"expected": "Ctrl+F", |
| 235 |
}, |
| 236 |
{ |
| 237 |
"id": "already_angle_bracket", |
| 238 |
"sequence": "<Primary>F", |
| 239 |
"gtk_result": "Ctrl+F", |
| 240 |
"localized": "Ctrl+F", |
| 241 |
"expected": "Ctrl+F", |
| 242 |
}, |
| 243 |
{ |
| 244 |
"id": "gtk_returns_trailing_plus", |
| 245 |
"sequence": "Alt+F", |
| 246 |
"gtk_result": "Alt+", |
| 247 |
"localized": "<Alt>F", |
| 248 |
"expected": "<Alt>F", |
| 249 |
}, |
| 250 |
{ |
| 251 |
"id": "single_char_skips_normalization", |
| 252 |
"sequence": "F", |
| 253 |
"gtk_result": "F", |
| 254 |
"localized": "F", |
| 255 |
"expected": "F", |
| 256 |
}, |
| 257 |
{ |
| 258 |
"id": "comma_separated_skips_normalization", |
| 259 |
"sequence": "Ctrl+F,Ctrl+G", |
| 260 |
"gtk_result": "", |
| 261 |
"localized": "Ctrl+F,Ctrl+G", |
| 262 |
"expected": "Ctrl+F,Ctrl+G", |
| 263 |
}, |
| 264 |
], |
| 265 |
ids=lambda case: case["id"], |
| 266 |
) |
| 267 |
def test_get_label_for_key_sequence( |
| 268 |
self, |
| 269 |
test_context: OrcaTestContext, |
| 270 |
case: dict, |
| 271 |
) -> None: |
| 272 |
"""Test AXUtilitiesAction._get_label_for_key_sequence normalization and Gtk parsing.""" |
| 273 |
|
| 274 |
essential_modules = self._setup_dependencies(test_context) |
| 275 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 276 |
|
| 277 |
if case["sequence"]: |
| 278 |
gi_repo = test_context.patch("orca.ax_utilities_action.Gtk") |
| 279 |
gi_repo.accelerator_parse.return_value = (0, 0) |
| 280 |
gi_repo.accelerator_get_label.return_value = case["gtk_result"] |
| 281 |
|
| 282 |
keynames_mock = essential_modules["orca.keynames"] |
| 283 |
keynames_mock.localize_key_sequence.side_effect = lambda s: s |
| 284 |
|
| 285 |
result = AXUtilitiesAction._get_label_for_key_sequence(case["sequence"]) |
| 286 |
|
| 287 |
if not case["sequence"]: |
| 288 |
assert result == "" |
| 289 |
elif case["gtk_result"] and not case["gtk_result"].endswith("+"): |
| 290 |
assert result == case["gtk_result"] |
| 291 |
else: |
| 292 |
assert result == case["localized"] |
| 293 |
|
| 294 |
@pytest.mark.parametrize( |
| 295 |
"case", |
| 296 |
[ |
| 297 |
{ |
| 298 |
"id": "from_keyshortcuts_attribute", |
| 299 |
"attributes": {"keyshortcuts": "Ctrl+F"}, |
| 300 |
"label_result": "Ctrl+F", |
| 301 |
"keybinding_index": -1, |
| 302 |
"expected": "Ctrl+F", |
| 303 |
}, |
| 304 |
{ |
| 305 |
"id": "single_char_shortcut_not_accelerator", |
| 306 |
"attributes": {"keyshortcuts": "F"}, |
| 307 |
"label_result": "F", |
| 308 |
"keybinding_index": -1, |
| 309 |
"expected": "", |
| 310 |
}, |
| 311 |
{ |
| 312 |
"id": "from_action_keybinding_three_parts", |
| 313 |
"attributes": {}, |
| 314 |
"label_result": "Ctrl+F", |
| 315 |
"keybinding_index": 0, |
| 316 |
"keybinding_string": "F;Alt+F;Ctrl+F", |
| 317 |
"expected": "Ctrl+F", |
| 318 |
}, |
| 319 |
{ |
| 320 |
"id": "from_action_keybinding_ctrl_in_last", |
| 321 |
"attributes": {}, |
| 322 |
"label_result": "Ctrl+F", |
| 323 |
"keybinding_index": 0, |
| 324 |
"keybinding_string": "Ctrl+F", |
| 325 |
"expected": "Ctrl+F", |
| 326 |
}, |
| 327 |
{ |
| 328 |
"id": "from_action_keybinding_no_ctrl", |
| 329 |
"attributes": {}, |
| 330 |
"label_result": "Alt+F", |
| 331 |
"keybinding_index": 0, |
| 332 |
"keybinding_string": "Alt+F", |
| 333 |
"expected": "", |
| 334 |
}, |
| 335 |
{ |
| 336 |
"id": "no_shortcuts_no_keybinding", |
| 337 |
"attributes": {}, |
| 338 |
"label_result": "", |
| 339 |
"keybinding_index": -1, |
| 340 |
"expected": "", |
| 341 |
}, |
| 342 |
], |
| 343 |
ids=lambda case: case["id"], |
| 344 |
) |
| 345 |
def test_get_accelerator( |
| 346 |
self, |
| 347 |
test_context: OrcaTestContext, |
| 348 |
case: dict, |
| 349 |
) -> None: |
| 350 |
"""Test AXUtilitiesAction.get_accelerator parsing paths.""" |
| 351 |
|
| 352 |
self._setup_dependencies(test_context) |
| 353 |
from orca.ax_action import AXAction |
| 354 |
from orca.ax_object import AXObject |
| 355 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 356 |
|
| 357 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 358 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 359 |
test_context.patch_object(AXObject, "get_attributes_dict", return_value=case["attributes"]) |
| 360 |
test_context.patch_object( |
| 361 |
AXUtilitiesAction, |
| 362 |
"_get_label_for_key_sequence", |
| 363 |
side_effect=lambda seq: case["label_result"] if seq else "", |
| 364 |
) |
| 365 |
test_context.patch_object( |
| 366 |
AXUtilitiesAction, |
| 367 |
"_find_first_action_with_keybinding", |
| 368 |
return_value=case["keybinding_index"], |
| 369 |
) |
| 370 |
if case["keybinding_index"] >= 0: |
| 371 |
test_context.patch_object( |
| 372 |
AXAction, |
| 373 |
"get_action_key_binding", |
| 374 |
return_value=case.get("keybinding_string", ""), |
| 375 |
) |
| 376 |
|
| 377 |
result = AXUtilitiesAction.get_accelerator(mock_accessible) |
| 378 |
assert result == case["expected"] |
| 379 |
|
| 380 |
def test_get_mnemonic_no_attributes(self, test_context: OrcaTestContext) -> None: |
| 381 |
"""Test AXUtilitiesAction.get_mnemonic with no keyshortcuts attribute.""" |
| 382 |
|
| 383 |
self._setup_dependencies(test_context) |
| 384 |
from orca.ax_object import AXObject |
| 385 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 386 |
|
| 387 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 388 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 389 |
test_context.patch_object(AXObject, "get_attributes_dict", return_value={}) |
| 390 |
test_context.patch_object( |
| 391 |
AXUtilitiesAction, "_find_first_action_with_keybinding", return_value=-1 |
| 392 |
) |
| 393 |
result = AXUtilitiesAction.get_mnemonic(mock_accessible) |
| 394 |
assert result == "" |
| 395 |
|
| 396 |
def test_get_mnemonic_single_letter_shortcut(self, test_context: OrcaTestContext) -> None: |
| 397 |
"""Test AXUtilitiesAction.get_mnemonic with single letter keyshortcut.""" |
| 398 |
|
| 399 |
self._setup_dependencies(test_context) |
| 400 |
from orca.ax_object import AXObject |
| 401 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 402 |
|
| 403 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 404 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 405 |
test_context.patch_object( |
| 406 |
AXObject, |
| 407 |
"get_attributes_dict", |
| 408 |
return_value={"keyshortcuts": "F"}, |
| 409 |
) |
| 410 |
test_context.patch_object( |
| 411 |
AXUtilitiesAction, "_get_label_for_key_sequence", return_value="F" |
| 412 |
) |
| 413 |
result = AXUtilitiesAction.get_mnemonic(mock_accessible) |
| 414 |
assert result == "F" |
| 415 |
|
| 416 |
def test_get_mnemonic_multiple_letter_shortcut(self, test_context: OrcaTestContext) -> None: |
| 417 |
"""Test AXUtilitiesAction.get_mnemonic with multi-letter keyshortcut.""" |
| 418 |
|
| 419 |
self._setup_dependencies(test_context) |
| 420 |
from orca.ax_object import AXObject |
| 421 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 422 |
|
| 423 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 424 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 425 |
test_context.patch_object( |
| 426 |
AXObject, |
| 427 |
"get_attributes_dict", |
| 428 |
return_value={"keyshortcuts": "Ctrl+F"}, |
| 429 |
) |
| 430 |
test_context.patch_object( |
| 431 |
AXUtilitiesAction, "_get_label_for_key_sequence", return_value="Ctrl+F" |
| 432 |
) |
| 433 |
test_context.patch_object( |
| 434 |
AXUtilitiesAction, "_find_first_action_with_keybinding", return_value=-1 |
| 435 |
) |
| 436 |
result = AXUtilitiesAction.get_mnemonic(mock_accessible) |
| 437 |
assert result == "" |
| 438 |
|
| 439 |
def test_get_mnemonic_from_action_keybinding(self, test_context: OrcaTestContext) -> None: |
| 440 |
"""Test AXUtilitiesAction.get_mnemonic from action key binding.""" |
| 441 |
|
| 442 |
self._setup_dependencies(test_context) |
| 443 |
from orca.ax_action import AXAction |
| 444 |
from orca.ax_object import AXObject |
| 445 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 446 |
|
| 447 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 448 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 449 |
test_context.patch_object(AXObject, "get_attributes_dict", return_value={}) |
| 450 |
test_context.patch_object( |
| 451 |
AXUtilitiesAction, "_find_first_action_with_keybinding", return_value=0 |
| 452 |
) |
| 453 |
test_context.patch_object(AXAction, "get_action_key_binding", return_value="Alt+F;Alt+F") |
| 454 |
test_context.patch_object( |
| 455 |
AXUtilitiesAction, "_get_label_for_key_sequence", return_value="Alt+F" |
| 456 |
) |
| 457 |
result = AXUtilitiesAction.get_mnemonic(mock_accessible) |
| 458 |
assert result == "Alt+F" |
| 459 |
|
| 460 |
def test_get_mnemonic_with_ctrl_in_result(self, test_context: OrcaTestContext) -> None: |
| 461 |
"""Test AXUtilitiesAction.get_mnemonic with Ctrl in result.""" |
| 462 |
|
| 463 |
self._setup_dependencies(test_context) |
| 464 |
from orca.ax_action import AXAction |
| 465 |
from orca.ax_object import AXObject |
| 466 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 467 |
|
| 468 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 469 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 470 |
test_context.patch_object(AXObject, "get_attributes_dict", return_value={}) |
| 471 |
test_context.patch_object( |
| 472 |
AXUtilitiesAction, "_find_first_action_with_keybinding", return_value=0 |
| 473 |
) |
| 474 |
test_context.patch_object(AXAction, "get_action_key_binding", return_value="Ctrl+F;Ctrl+F") |
| 475 |
test_context.patch_object( |
| 476 |
AXUtilitiesAction, "_get_label_for_key_sequence", return_value="Ctrl+F" |
| 477 |
) |
| 478 |
result = AXUtilitiesAction.get_mnemonic(mock_accessible) |
| 479 |
assert result == "" |
| 480 |
|
| 481 |
def test_get_mnemonic_with_space(self, test_context: OrcaTestContext) -> None: |
| 482 |
"""Test AXUtilitiesAction.get_mnemonic with space key.""" |
| 483 |
|
| 484 |
self._setup_dependencies(test_context) |
| 485 |
from orca.ax_action import AXAction |
| 486 |
from orca.ax_object import AXObject |
| 487 |
from orca.ax_utilities_action import AXUtilitiesAction |
| 488 |
|
| 489 |
mock_accessible = test_context.Mock(spec=Atspi.Accessible) |
| 490 |
test_context.patch_object(AXObject, "is_valid", return_value=True) |
| 491 |
test_context.patch_object(AXObject, "get_attributes_dict", return_value={}) |
| 492 |
test_context.patch_object( |
| 493 |
AXUtilitiesAction, "_find_first_action_with_keybinding", return_value=0 |
| 494 |
) |
| 495 |
test_context.patch_object(AXAction, "get_action_key_binding", return_value="space;space") |
| 496 |
test_context.patch_object( |
| 497 |
AXUtilitiesAction, "_get_label_for_key_sequence", return_value="space" |
| 498 |
) |
| 499 |
result = AXUtilitiesAction.get_mnemonic(mock_accessible) |
| 500 |
assert result == "" |