1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/constants/ash_pref_names.h"
#include "ash/constants/ash_switches.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/public/cpp/system_tray_test_api.h"
#include "ash/system/accessibility/accessibility_detailed_view.h"
#include "ash/system/tray/tray_detailed_view.h"
#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "chrome/browser/ash/accessibility/accessibility_manager.h"
#include "chrome/browser/ash/accessibility/magnification_manager.h"
#include "chrome/browser/ash/login/helper.h"
#include "chrome/browser/ash/login/startup_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/session/session_controller_client_impl.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/external_data_fetcher.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_types.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/label.h"
#include "ui/views/widget/widget.h"
using testing::_;
using testing::Return;
using testing::WithParamInterface;
namespace ash {
enum PrefSettingMechanism {
PREF_SERVICE,
POLICY,
};
namespace {
////////////////////////////////////////////////////////////////////////////////
// Changing accessibility settings may change preferences, so these helpers spin
// the message loop to ensure ash sees the change.
void SetScreenMagnifierEnabled(bool enabled) {
MagnificationManager::Get()->SetMagnifierEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void SetDockedMagnifierEnabled(bool enabled) {
MagnificationManager::Get()->SetDockedMagnifierEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableSpokenFeedback(bool enabled) {
AccessibilityManager::Get()->EnableSpokenFeedback(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableSelectToSpeak(bool enabled) {
AccessibilityManager::Get()->SetSelectToSpeakEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableDictation(bool enabled) {
bool already_enabled = AccessibilityManager::Get()->IsDictationEnabled();
if (enabled == already_enabled) {
return;
}
AccessibilityManager::Get()->ToggleDictation();
base::RunLoop().RunUntilIdle();
}
void EnableSwitchAccess(bool enabled) {
AccessibilityManager::Get()->SetSwitchAccessEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableHighContrast(bool enabled) {
AccessibilityManager::Get()->EnableHighContrast(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableAutoclick(bool enabled) {
AccessibilityManager::Get()->EnableAutoclick(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableVirtualKeyboard(bool enabled) {
AccessibilityManager::Get()->EnableVirtualKeyboard(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableLargeCursor(bool enabled) {
AccessibilityManager::Get()->EnableLargeCursor(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableLiveCaption(bool enabled) {
AccessibilityManager::Get()->EnableLiveCaption(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableMonoAudio(bool enabled) {
AccessibilityManager::Get()->EnableMonoAudio(enabled);
base::RunLoop().RunUntilIdle();
}
void SetCaretHighlightEnabled(bool enabled) {
AccessibilityManager::Get()->SetCaretHighlightEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void SetCursorHighlightEnabled(bool enabled) {
AccessibilityManager::Get()->SetCursorHighlightEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void SetFocusHighlightEnabled(bool enabled) {
AccessibilityManager::Get()->SetFocusHighlightEnabled(enabled);
base::RunLoop().RunUntilIdle();
}
void EnableStickyKeys(bool enabled) {
AccessibilityManager::Get()->EnableStickyKeys(enabled);
base::RunLoop().RunUntilIdle();
}
} // namespace
// Uses InProcessBrowserTest instead of OobeBaseTest because most of the tests
// don't need to test the login screen.
class TrayAccessibilityTest : public InProcessBrowserTest,
public WithParamInterface<PrefSettingMechanism> {
public:
TrayAccessibilityTest()
: disable_animations_(
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION) {}
~TrayAccessibilityTest() override = default;
// The profile which should be used by these tests.
Profile* GetProfile() { return ProfileManager::GetActiveUserProfile(); }
// InProcessBrowserTest:
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
tray_test_api_ = ash::SystemTrayTestApi::Create();
}
void SetUpInProcessBrowserTestFixture() override {
InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
provider_.SetDefaultReturns(
/*is_initialization_complete_return=*/true,
/*is_first_policy_load_complete_return=*/true);
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
void SetShowAccessibilityOptionsInSystemTrayMenu(bool value) {
if (GetParam() == PREF_SERVICE) {
PrefService* prefs = GetProfile()->GetPrefs();
prefs->SetBoolean(ash::prefs::kShouldAlwaysShowAccessibilityMenu, value);
// Prefs are sent to ash asynchronously.
base::RunLoop().RunUntilIdle();
} else if (GetParam() == POLICY) {
policy::PolicyMap policy_map;
policy_map.Set(policy::key::kShowAccessibilityOptionsInSystemTrayMenu,
policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
policy::POLICY_SOURCE_CLOUD, base::Value(value), nullptr);
provider_.UpdateChromePolicy(policy_map);
base::RunLoop().RunUntilIdle();
} else {
FAIL() << "Unknown test parameterization";
}
}
bool IsMenuButtonVisible() {
bool visible = tray_test_api_->IsBubbleViewVisible(
ash::VIEW_ID_FEATURE_TILE_ACCESSIBILITY, true /* open_tray */);
tray_test_api_->CloseBubble();
return visible;
}
void CreateDetailedMenu() { tray_test_api_->ShowAccessibilityDetailedView(); }
bool IsBubbleOpen() { return tray_test_api_->IsTrayBubbleOpen(); }
void ClickVirtualKeyboardOnDetailMenu() {
// Scroll the detailed view to show the virtual keyboard option.
tray_test_api_->ScrollToShowView(
tray_test_api_->GetAccessibilityDetailedView()
->scroll_view_for_testing(),
ash::VIEW_ID_ACCESSIBILITY_VIRTUAL_KEYBOARD);
tray_test_api_->ClickBubbleView(
ash::VIEW_ID_ACCESSIBILITY_VIRTUAL_KEYBOARD);
}
bool IsVirtualKeyboardEnabledOnDetailMenu() const {
return tray_test_api_->IsToggleOn(
ash::VIEW_ID_ACCESSIBILITY_VIRTUAL_KEYBOARD_ENABLED);
}
// Disable animations so that tray icons hide immediately.
ui::ScopedAnimationDurationScaleMode disable_animations_;
testing::NiceMock<policy::MockConfigurationPolicyProvider> provider_;
std::unique_ptr<ash::SystemTrayTestApi> tray_test_api_;
};
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, DISABLED_ShowMenu) {
SetShowAccessibilityOptionsInSystemTrayMenu(false);
// Confirms that the menu is hidden.
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling spoken feedback changes the visibility of the menu.
EnableSpokenFeedback(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling high contrast changes the visibility of the menu.
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling screen magnifier changes the visibility of the menu.
SetScreenMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetScreenMagnifierEnabled(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling docked magnifier changes the visibility of the menu.
SetDockedMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling autoclick changes the visibility of the menu.
EnableAutoclick(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling virtual keyboard changes the visibility of the menu.
EnableVirtualKeyboard(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling large mouse cursor changes the visibility of the menu.
EnableLargeCursor(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling Live Caption changes the visibility of the menu.
EnableLiveCaption(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling mono audio changes the visibility of the menu.
EnableMonoAudio(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling caret highlight changes the visibility of the menu.
SetCaretHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling highlight mouse cursor changes the visibility of the menu.
SetCursorHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling highlight keyboard focus changes the visibility of the menu.
SetFocusHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling sticky keys changes the visibility of the menu.
EnableStickyKeys(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling select-to-speak dragging changes the visibility of the menu.
EnableSelectToSpeak(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling dictation changes the visibility of the menu.
EnableDictation(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Toggling switch access changes the visibility of the menu.
EnableSwitchAccess(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(false);
EXPECT_FALSE(IsMenuButtonVisible());
// Enabling all accessibility features.
SetScreenMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetScreenMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false);
EXPECT_FALSE(IsMenuButtonVisible());
}
// Fails on linux-chromeos-dbg see crbug/1027919.
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest,
DISABLED_ShowMenuWithShowMenuOption) {
SetShowAccessibilityOptionsInSystemTrayMenu(true);
// Confirms that the menu is visible.
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling spoken feedback.
EnableSpokenFeedback(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling high contrast.
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling screen magnifier.
SetScreenMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetScreenMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling docked magnifier.
SetDockedMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling autoclick.
EnableAutoclick(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling on-screen keyboard.
EnableVirtualKeyboard(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling large mouse cursor.
EnableLargeCursor(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling Live Caption.
EnableLiveCaption(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling mono audio.
EnableMonoAudio(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling caret highlight.
SetCaretHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight mouse cursor.
SetCursorHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight keyboard focus.
SetFocusHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of the toggling sticky keys.
EnableStickyKeys(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling select-to-speak.
EnableSelectToSpeak(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling dictation.
EnableDictation(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling switch access.
EnableSwitchAccess(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(false);
EXPECT_TRUE(IsMenuButtonVisible());
// Enabling all accessibility features.
SetScreenMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableAutoclick(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetScreenMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(false);
// Confirms that the menu is invisible.
EXPECT_FALSE(IsMenuButtonVisible());
}
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
// Enables high contrast mode.
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
// Locks the screen.
SessionControllerClientImpl::Get()->RequestLockScreen();
// Resets the test API because UnifiedSystemTray is recreated.
tray_test_api_ = ash::SystemTrayTestApi::Create();
EXPECT_TRUE(IsMenuButtonVisible());
// Disables high contrast mode.
EnableHighContrast(false);
// Confirms that the menu is still visible.
EXPECT_TRUE(IsMenuButtonVisible());
}
// Verify that the accessibility system detailed menu remains open when an item
// is selected or deselected.
// Do not use a feature which requires an enable/disable confirmation dialog
// here, as the dialogs change focus and close the detail menu.
IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, DetailMenuRemainsOpen) {
CreateDetailedMenu();
ClickVirtualKeyboardOnDetailMenu();
EXPECT_TRUE(IsVirtualKeyboardEnabledOnDetailMenu());
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_TRUE(IsBubbleOpen());
ClickVirtualKeyboardOnDetailMenu();
EXPECT_FALSE(IsVirtualKeyboardEnabledOnDetailMenu());
{
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
EXPECT_TRUE(IsBubbleOpen());
}
class TrayAccessibilityLoginTest : public TrayAccessibilityTest {
public:
TrayAccessibilityLoginTest() = default;
TrayAccessibilityLoginTest(const TrayAccessibilityLoginTest&) = delete;
TrayAccessibilityLoginTest& operator=(const TrayAccessibilityLoginTest&) =
delete;
~TrayAccessibilityLoginTest() = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
TrayAccessibilityTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kLoginManager);
command_line->AppendSwitch(switches::kForceLoginManagerInTests);
}
};
IN_PROC_BROWSER_TEST_P(TrayAccessibilityLoginTest,
ShowMenuWithShowOnLoginScreen) {
EXPECT_FALSE(user_manager::UserManager::Get()->IsUserLoggedIn());
// Confirms that the menu is visible.
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling spoken feedback.
EnableSpokenFeedback(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling high contrast.
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling screen magnifier.
SetScreenMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetScreenMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling docked magnifier.
SetDockedMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling select-to-speak.
EnableSelectToSpeak(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling dictation.
EnableDictation(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling switch access.
EnableSwitchAccess(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling on-screen keyboard.
EnableVirtualKeyboard(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling large mouse cursor.
EnableLargeCursor(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling Live Caption.
EnableLiveCaption(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling mono audio.
EnableMonoAudio(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling caret highlight.
SetCaretHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight mouse cursor.
SetCursorHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling highlight keyboard focus.
SetFocusHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
// The menu remains visible regardless of toggling sticky keys.
EnableStickyKeys(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false);
EXPECT_TRUE(IsMenuButtonVisible());
// Enabling all accessibility features.
SetScreenMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetDockedMagnifierEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(true);
EXPECT_TRUE(IsMenuButtonVisible());
EnableVirtualKeyboard(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSpokenFeedback(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableHighContrast(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSelectToSpeak(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableDictation(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableSwitchAccess(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetScreenMagnifierEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLargeCursor(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableLiveCaption(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableMonoAudio(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetCaretHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetCursorHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetFocusHighlightEnabled(false);
EXPECT_TRUE(IsMenuButtonVisible());
EnableStickyKeys(false);
EXPECT_TRUE(IsMenuButtonVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(true);
// Confirms that the menu remains visible.
EXPECT_TRUE(IsMenuButtonVisible());
SetShowAccessibilityOptionsInSystemTrayMenu(false);
// Confirms that the menu remains visible.
EXPECT_TRUE(IsMenuButtonVisible());
}
INSTANTIATE_TEST_SUITE_P(TrayAccessibilityTestInstance,
TrayAccessibilityTest,
testing::Values(PREF_SERVICE, POLICY));
INSTANTIATE_TEST_SUITE_P(TrayAccessibilityLoginTestInstance,
TrayAccessibilityLoginTest,
testing::Values(PREF_SERVICE, POLICY));
} // namespace ash
|