OLD | NEW |
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 Loading... |
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; |
| 50 using message_center::MessageCenter; |
49 using testing::Return; | 51 using testing::Return; |
50 using testing::_; | 52 using testing::_; |
51 using testing::WithParamInterface; | 53 using testing::WithParamInterface; |
52 | 54 |
53 namespace chromeos { | 55 namespace chromeos { |
54 | 56 |
55 enum PrefSettingMechanism { | 57 enum PrefSettingMechanism { |
56 PREF_SERVICE, | 58 PREF_SERVICE, |
57 POLICY, | 59 POLICY, |
58 }; | 60 }; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 views::Button::STATE_NORMAL; | 335 views::Button::STATE_NORMAL; |
334 } | 336 } |
335 | 337 |
336 // In material design we show the settings button but theme it as disabled if | 338 // In material design we show the settings button but theme it as disabled if |
337 // it is not possible to load the settings page. | 339 // it is not possible to load the settings page. |
338 bool IsSettingsAvailableOnDetailMenu() const { | 340 bool IsSettingsAvailableOnDetailMenu() const { |
339 return tray()->detailed_menu_->settings_view_->state() == | 341 return tray()->detailed_menu_->settings_view_->state() == |
340 views::Button::STATE_NORMAL; | 342 views::Button::STATE_NORMAL; |
341 } | 343 } |
342 | 344 |
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) { | 345 void SetBrailleConnected(bool connected) { |
356 braille_controller_.SetAvailable(connected); | 346 braille_controller_.SetAvailable(connected); |
357 braille_controller_.GetObserver()->OnBrailleDisplayStateChanged( | 347 braille_controller_.GetObserver()->OnBrailleDisplayStateChanged( |
358 *braille_controller_.GetDisplayState()); | 348 *braille_controller_.GetDisplayState()); |
359 } | 349 } |
360 | 350 |
361 policy::MockConfigurationPolicyProvider provider_; | 351 policy::MockConfigurationPolicyProvider provider_; |
362 MockBrailleController braille_controller_; | 352 MockBrailleController braille_controller_; |
363 }; | 353 }; |
364 | 354 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 | 923 |
934 SetShowAccessibilityOptionsInSystemTrayMenu(false); | 924 SetShowAccessibilityOptionsInSystemTrayMenu(false); |
935 | 925 |
936 // Confirms that the menu remains visible. | 926 // Confirms that the menu remains visible. |
937 EXPECT_TRUE(CanCreateMenuItem()); | 927 EXPECT_TRUE(CanCreateMenuItem()); |
938 } | 928 } |
939 | 929 |
940 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) { | 930 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, ShowNotification) { |
941 const base::string16 BRAILLE_CONNECTED = | 931 const base::string16 BRAILLE_CONNECTED = |
942 base::ASCIIToUTF16("Braille display connected."); | 932 base::ASCIIToUTF16("Braille display connected."); |
943 const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16( | 933 const base::string16 CHROMEVOX_ENABLED_TITLE = |
944 "ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable."); | 934 base::ASCIIToUTF16("ChromeVox enabled"); |
945 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED( | 935 const base::string16 CHROMEVOX_ENABLED = |
946 BRAILLE_CONNECTED + base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED); | 936 base::ASCIIToUTF16("Press Ctrl + Alt + Z to disable spoken feedback."); |
| 937 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED_TITLE = |
| 938 base::ASCIIToUTF16("Braille and ChromeVox are enabled"); |
947 | 939 |
948 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 940 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
949 | 941 |
950 // Enabling spoken feedback should show the notification. | 942 // Enabling spoken feedback should show the notification. |
951 AccessibilityManager::Get()->EnableSpokenFeedback( | 943 AccessibilityManager::Get()->EnableSpokenFeedback( |
952 true, ash::A11Y_NOTIFICATION_SHOW); | 944 true, ash::A11Y_NOTIFICATION_SHOW); |
953 EXPECT_EQ(CHROMEVOX_ENABLED, GetNotificationText()); | 945 message_center::NotificationList::Notifications notifications = |
| 946 MessageCenter::Get()->GetVisibleNotifications(); |
| 947 EXPECT_EQ(1u, notifications.size()); |
| 948 EXPECT_EQ(CHROMEVOX_ENABLED_TITLE, (*notifications.begin())->title()); |
| 949 EXPECT_EQ(CHROMEVOX_ENABLED, (*notifications.begin())->message()); |
954 | 950 |
955 // Connecting a braille display when spoken feedback is already enabled | 951 // Connecting a braille display when spoken feedback is already enabled |
956 // should only show the message about the braille display. | 952 // should only show the message about the braille display. |
957 SetBrailleConnected(true); | 953 SetBrailleConnected(true); |
958 EXPECT_EQ(BRAILLE_CONNECTED, GetNotificationText()); | 954 notifications = MessageCenter::Get()->GetVisibleNotifications(); |
| 955 EXPECT_EQ(1u, notifications.size()); |
| 956 EXPECT_EQ(base::string16(), (*notifications.begin())->title()); |
| 957 EXPECT_EQ(BRAILLE_CONNECTED, (*notifications.begin())->message()); |
959 | 958 |
960 // Neither disconnecting a braille display, nor disabling spoken feedback | 959 // Neither disconnecting a braille display, nor disabling spoken feedback |
961 // should show any notification. | 960 // should show any notification. |
962 SetBrailleConnected(false); | 961 SetBrailleConnected(false); |
963 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 962 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
964 EXPECT_FALSE(IsNotificationShown()); | 963 notifications = MessageCenter::Get()->GetVisibleNotifications(); |
| 964 EXPECT_EQ(0u, notifications.size()); |
965 AccessibilityManager::Get()->EnableSpokenFeedback( | 965 AccessibilityManager::Get()->EnableSpokenFeedback( |
966 false, ash::A11Y_NOTIFICATION_SHOW); | 966 false, ash::A11Y_NOTIFICATION_SHOW); |
967 EXPECT_FALSE(IsNotificationShown()); | 967 notifications = MessageCenter::Get()->GetVisibleNotifications(); |
| 968 EXPECT_EQ(0u, notifications.size()); |
968 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 969 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
969 | 970 |
970 // Connecting a braille display should enable spoken feedback and show | 971 // Connecting a braille display should enable spoken feedback and show |
971 // both messages. | 972 // both messages. |
972 SetBrailleConnected(true); | 973 SetBrailleConnected(true); |
973 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 974 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
974 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED, GetNotificationText()); | 975 notifications = MessageCenter::Get()->GetVisibleNotifications(); |
| 976 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED_TITLE, |
| 977 (*notifications.begin())->title()); |
| 978 EXPECT_EQ(CHROMEVOX_ENABLED, (*notifications.begin())->message()); |
975 } | 979 } |
976 | 980 |
977 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { | 981 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { |
978 // Enables high contrast mode. | 982 // Enables high contrast mode. |
979 AccessibilityManager::Get()->EnableHighContrast(true); | 983 AccessibilityManager::Get()->EnableHighContrast(true); |
980 EXPECT_TRUE(CanCreateMenuItem()); | 984 EXPECT_TRUE(CanCreateMenuItem()); |
981 | 985 |
982 // Locks the screen. | 986 // Locks the screen. |
983 SetLoginStatus(ash::LoginStatus::LOCKED); | 987 SetLoginStatus(ash::LoginStatus::LOCKED); |
984 EXPECT_TRUE(CanCreateMenuItem()); | 988 EXPECT_TRUE(CanCreateMenuItem()); |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); | 1708 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); |
1705 CloseDetailMenu(); | 1709 CloseDetailMenu(); |
1706 } | 1710 } |
1707 | 1711 |
1708 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, | 1712 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, |
1709 TrayAccessibilityTest, | 1713 TrayAccessibilityTest, |
1710 testing::Values(PREF_SERVICE, | 1714 testing::Values(PREF_SERVICE, |
1711 POLICY)); | 1715 POLICY)); |
1712 | 1716 |
1713 } // namespace chromeos | 1717 } // namespace chromeos |
OLD | NEW |