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; |
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 Loading... | |
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 Loading... | |
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."); |
943 const base::string16 CHROMEVOX_ENABLED = base::ASCIIToUTF16( | 932 const base::string16 CHROMEVOX_ENABLED_TITLE = |
944 "ChromeVox (spoken feedback) is enabled.\nPress Ctrl+Alt+Z to disable."); | 933 base::ASCIIToUTF16("ChromeVox enabled"); |
945 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED( | 934 const base::string16 CHROMEVOX_ENABLED = |
946 BRAILLE_CONNECTED + base::ASCIIToUTF16(" ") + CHROMEVOX_ENABLED); | 935 base::ASCIIToUTF16("Press Ctrl + Alt + Z to disable spoken feedback."); |
936 const base::string16 BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED_TITLE = | |
937 base::ASCIIToUTF16("Braille and ChromeVox are enabled"); | |
947 | 938 |
948 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 939 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
949 | 940 |
950 // Enabling spoken feedback should show the notification. | 941 // Enabling spoken feedback should show the notification. |
951 AccessibilityManager::Get()->EnableSpokenFeedback( | 942 AccessibilityManager::Get()->EnableSpokenFeedback( |
952 true, ash::A11Y_NOTIFICATION_SHOW); | 943 true, ash::A11Y_NOTIFICATION_SHOW); |
953 EXPECT_EQ(CHROMEVOX_ENABLED, GetNotificationText()); | 944 message_center::NotificationList::Notifications notifications = |
945 message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
946 EXPECT_EQ(1u, notifications.size()); | |
947 EXPECT_EQ(CHROMEVOX_ENABLED_TITLE, (*notifications.begin())->title()); | |
948 EXPECT_EQ(CHROMEVOX_ENABLED, (*notifications.begin())->message()); | |
954 | 949 |
955 // Connecting a braille display when spoken feedback is already enabled | 950 // Connecting a braille display when spoken feedback is already enabled |
956 // should only show the message about the braille display. | 951 // should only show the message about the braille display. |
957 SetBrailleConnected(true); | 952 SetBrailleConnected(true); |
958 EXPECT_EQ(BRAILLE_CONNECTED, GetNotificationText()); | 953 notifications = |
954 message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
James Cook
2017/05/16 00:56:19
optional: if you want to make lines like this (and
| |
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 = |
964 message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
965 EXPECT_EQ(0u, notifications.size()); | |
965 AccessibilityManager::Get()->EnableSpokenFeedback( | 966 AccessibilityManager::Get()->EnableSpokenFeedback( |
966 false, ash::A11Y_NOTIFICATION_SHOW); | 967 false, ash::A11Y_NOTIFICATION_SHOW); |
967 EXPECT_FALSE(IsNotificationShown()); | 968 notifications = |
969 message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
970 EXPECT_EQ(0u, notifications.size()); | |
968 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 971 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
969 | 972 |
970 // Connecting a braille display should enable spoken feedback and show | 973 // Connecting a braille display should enable spoken feedback and show |
971 // both messages. | 974 // both messages. |
972 SetBrailleConnected(true); | 975 SetBrailleConnected(true); |
973 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 976 EXPECT_TRUE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
974 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED, GetNotificationText()); | 977 notifications = |
978 message_center::MessageCenter::Get()->GetVisibleNotifications(); | |
979 EXPECT_EQ(BRAILLE_CONNECTED_AND_CHROMEVOX_ENABLED_TITLE, | |
980 (*notifications.begin())->title()); | |
981 EXPECT_EQ(CHROMEVOX_ENABLED, (*notifications.begin())->message()); | |
975 } | 982 } |
James Cook
2017/05/16 00:56:19
Thanks for fixing up the tests!
yiyix
2017/05/19 02:29:56
:) you are welcome
| |
976 | 983 |
977 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { | 984 IN_PROC_BROWSER_TEST_P(TrayAccessibilityTest, KeepMenuVisibilityOnLockScreen) { |
978 // Enables high contrast mode. | 985 // Enables high contrast mode. |
979 AccessibilityManager::Get()->EnableHighContrast(true); | 986 AccessibilityManager::Get()->EnableHighContrast(true); |
980 EXPECT_TRUE(CanCreateMenuItem()); | 987 EXPECT_TRUE(CanCreateMenuItem()); |
981 | 988 |
982 // Locks the screen. | 989 // Locks the screen. |
983 SetLoginStatus(ash::LoginStatus::LOCKED); | 990 SetLoginStatus(ash::LoginStatus::LOCKED); |
984 EXPECT_TRUE(CanCreateMenuItem()); | 991 EXPECT_TRUE(CanCreateMenuItem()); |
985 | 992 |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1704 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); | 1711 EXPECT_TRUE(IsTapDraggingMenuShownOnDetailMenu()); |
1705 CloseDetailMenu(); | 1712 CloseDetailMenu(); |
1706 } | 1713 } |
1707 | 1714 |
1708 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, | 1715 INSTANTIATE_TEST_CASE_P(TrayAccessibilityTestInstance, |
1709 TrayAccessibilityTest, | 1716 TrayAccessibilityTest, |
1710 testing::Values(PREF_SERVICE, | 1717 testing::Values(PREF_SERVICE, |
1711 POLICY)); | 1718 POLICY)); |
1712 | 1719 |
1713 } // namespace chromeos | 1720 } // namespace chromeos |
OLD | NEW |