Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/chromeos/system/tray_accessibility_browsertest.cc

Issue 2838903002: Add accessibility related notification to notification center (Closed)
Patch Set: nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/accessibility_types.h" 5 #include "ash/accessibility_types.h"
6 #include "ash/login_status.h" 6 #include "ash/login_status.h"
7 #include "ash/magnifier/magnification_controller.h" 7 #include "ash/magnifier/magnification_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray_accessibility.h" 10 #include "ash/system/tray_accessibility.h"
(...skipping 20 matching lines...) Expand all
31 #include "components/policy/core/browser/browser_policy_connector.h" 31 #include "components/policy/core/browser/browser_policy_connector.h"
32 #include "components/policy/core/common/external_data_fetcher.h" 32 #include "components/policy/core/common/external_data_fetcher.h"
33 #include "components/policy/core/common/mock_configuration_policy_provider.h" 33 #include "components/policy/core/common/mock_configuration_policy_provider.h"
34 #include "components/policy/core/common/policy_map.h" 34 #include "components/policy/core/common/policy_map.h"
35 #include "components/policy/core/common/policy_types.h" 35 #include "components/policy/core/common/policy_types.h"
36 #include "components/policy/policy_constants.h" 36 #include "components/policy/policy_constants.h"
37 #include "components/prefs/pref_service.h" 37 #include "components/prefs/pref_service.h"
38 #include "components/session_manager/core/session_manager.h" 38 #include "components/session_manager/core/session_manager.h"
39 #include "content/public/test/test_utils.h" 39 #include "content/public/test/test_utils.h"
40 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
41 #include "ui/message_center/message_center.h"
41 #include "ui/views/controls/button/button.h" 42 #include "ui/views/controls/button/button.h"
42 #include "ui/views/controls/button/custom_button.h" 43 #include "ui/views/controls/button/custom_button.h"
43 #include "ui/views/controls/label.h" 44 #include "ui/views/controls/label.h"
44 #include "ui/views/widget/widget.h" 45 #include "ui/views/widget/widget.h"
45 46
46 using extensions::api::braille_display_private::BrailleObserver; 47 using extensions::api::braille_display_private::BrailleObserver;
47 using extensions::api::braille_display_private::DisplayState; 48 using extensions::api::braille_display_private::DisplayState;
48 using extensions::api::braille_display_private::MockBrailleController; 49 using extensions::api::braille_display_private::MockBrailleController;
49 using testing::Return; 50 using testing::Return;
50 using testing::_; 51 using testing::_;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 views::Button::STATE_NORMAL; 334 views::Button::STATE_NORMAL;
334 } 335 }
335 336
336 // In material design we show the settings button but theme it as disabled if 337 // In material design we show the settings button but theme it as disabled if
337 // it is not possible to load the settings page. 338 // it is not possible to load the settings page.
338 bool IsSettingsAvailableOnDetailMenu() const { 339 bool IsSettingsAvailableOnDetailMenu() const {
339 return tray()->detailed_menu_->settings_view_->state() == 340 return tray()->detailed_menu_->settings_view_->state() ==
340 views::Button::STATE_NORMAL; 341 views::Button::STATE_NORMAL;
341 } 342 }
342 343
343 bool IsNotificationShown() const {
344 return (tray()->detailed_popup_ &&
345 !tray()->detailed_popup_->GetWidget()->IsClosed());
346 }
347
348 base::string16 GetNotificationText() const {
349 if (IsNotificationShown())
350 return tray()->detailed_popup_->label_for_test()->text();
351 else
352 return base::string16();
353 }
354
355 void SetBrailleConnected(bool connected) { 344 void SetBrailleConnected(bool connected) {
356 braille_controller_.SetAvailable(connected); 345 braille_controller_.SetAvailable(connected);
357 braille_controller_.GetObserver()->OnBrailleDisplayStateChanged( 346 braille_controller_.GetObserver()->OnBrailleDisplayStateChanged(
358 *braille_controller_.GetDisplayState()); 347 *braille_controller_.GetDisplayState());
359 } 348 }
360 349
361 policy::MockConfigurationPolicyProvider provider_; 350 policy::MockConfigurationPolicyProvider provider_;
362 MockBrailleController braille_controller_; 351 MockBrailleController braille_controller_;
363 }; 352 };
364 353
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 922
934 SetShowAccessibilityOptionsInSystemTrayMenu(false); 923 SetShowAccessibilityOptionsInSystemTrayMenu(false);
935 924
936 // Confirms that the menu remains visible. 925 // Confirms that the menu remains visible.
937 EXPECT_TRUE(CanCreateMenuItem()); 926 EXPECT_TRUE(CanCreateMenuItem());
938 } 927 }
939 928
940 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) { 929 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) {
941 const base::string16 BRAILLE_CONNECTED = 930 const base::string16 BRAILLE_CONNECTED =
942 base::ASCIIToUTF16("Braille display connected."); 931 base::ASCIIToUTF16("Braille display connected.");
932 const base::string16 CHROMEVOX_ENABLED_TITILE =
tdanderson 2017/05/08 21:55:27 typo: _TITLE
yiyix 2017/05/15 22:55:15 Done.
933 base::ASCIIToUTF16("ChromeVox enabled");
943 const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16( 934 const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16(
944 "ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable."); 935 "Spoken feedback is enabled.\nPress Ctrl+Alt+Z to disable.");
945 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED( 936 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED_TITLE =
946 BRAILLE_CONNECTED + base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED); 937 base::ASCIIToUTF16("Braille and Chromevox are enabled");
938 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED =
939 base::ASCIIToUTF16("Press Ctrl + Alt + Z to disable spoken feedback.");
947 940
948 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 941 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
949 942
950 // Enabling spoken feedback should show the notification. 943 // Enabling spoken feedback should show the notification.
951 AccessibilityManager::Get()->EnableSpokenFeedback( 944 AccessibilityManager::Get()->EnableSpokenFeedback(
952 true, ash::A11Y_NOTIFICATION_SHOW); 945 true, ash::A11Y_NOTIFICATION_SHOW);
953 EXPECT_EQ(CHROMEVOX_ENABLED, GetNotificationText()); 946 message_center::NotificationList::Notifications notifications =
947 message_center::MessageCenter::Get()->GetVisibleNotifications();
948 EXPECT_EQ(1u, notifications.size());
949 EXPECT_EQ(CHROMEVOX_ENABLED_TITILE, (*notifications.begin())->title());
950 EXPECT_EQ(CHROMEVOX_ENABLED, (*notifications.begin())->message());
954 951
955 // Connecting a braille display when spoken feedback is already enabled 952 // Connecting a braille display when spoken feedback is already enabled
956 // should only show the message about the braille display. 953 // should only show the message about the braille display.
957 SetBrailleConnected(true); 954 SetBrailleConnected(true);
958 EXPECT_EQ(BRAILLE_CONNECTED, GetNotificationText()); 955 notifications =
956 message_center::MessageCenter::Get()->GetVisibleNotifications();
957 EXPECT_EQ(1u, notifications.size());
958 EXPECT_EQ(base::string16(), (*notifications.begin())->title());
959 EXPECT_EQ(BRAILLE_CONNECTED, (*notifications.begin())->message());
959 960
960 // Neither disconnecting a braille display, nor disabling spoken feedback 961 // Neither disconnecting a braille display, nor disabling spoken feedback
961 // should show any notification. 962 // should show any notification.
962 SetBrailleConnected(false); 963 SetBrailleConnected(false);
963 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 964 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
964 EXPECT_FALSE(IsNotificationShown()); 965 notifications =
966 message_center::MessageCenter::Get()->GetVisibleNotifications();
967 EXPECT_EQ(0u, notifications.size());
965 AccessibilityManager::Get()->EnableSpokenFeedback( 968 AccessibilityManager::Get()->EnableSpokenFeedback(
966 false, ash::A11Y_NOTIFICATION_SHOW); 969 false, ash::A11Y_NOTIFICATION_SHOW);
967 EXPECT_FALSE(IsNotificationShown()); 970 notifications =
971 message_center::MessageCenter::Get()->GetVisibleNotifications();
972 EXPECT_EQ(0u, notifications.size());
968 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 973 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
969 974
970 // Connecting a braille display should enable spoken feedback and show 975 // Connecting a braille display should enable spoken feedback and show
971 // both messages. 976 // both messages.
972 SetBrailleConnected(true); 977 SetBrailleConnected(true);
973 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); 978 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
974 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED, GetNotificationText()); 979 notifications =
980 message_center::MessageCenter::Get()->GetVisibleNotifications();
981 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED_TITLE,
982 (*notifications.begin())->title());
983 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED,
984 (*notifications.begin())->message());
975 } 985 }
976 986
977 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { 987 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) {
978 // Enables high contrast mode. 988 // Enables high contrast mode.
979 AccessibilityManager::Get()->EnableHighContrast(true); 989 AccessibilityManager::Get()->EnableHighContrast(true);
980 EXPECT_TRUE(CanCreateMenuItem()); 990 EXPECT_TRUE(CanCreateMenuItem());
981 991
982 // Locks the screen. 992 // Locks the screen.
983 SetLoginStatus(ash::LoginStatus::LOCKED); 993 SetLoginStatus(ash::LoginStatus::LOCKED);
984 EXPECT_TRUE(CanCreateMenuItem()); 994 EXPECT_TRUE(CanCreateMenuItem());
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); 1714 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu());
1705 CloseDetailMenu(); 1715 CloseDetailMenu();
1706 } 1716 }
1707 1717
1708 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, 1718 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance,
1709 TrayAccessibilityTest, 1719 TrayAccessibilityTest,
1710 testing::Values(PREF_SERVICE, 1720 testing::Values(PREF_SERVICE,
1711 POLICY)); 1721 POLICY));
1712 1722
1713 } // namespace chromeos 1723 } // namespace chromeos
OLDNEW
« ash/system/tray_accessibility.cc ('K') | « ash/system/tray_accessibility.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698