OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import <EarlGrey/EarlGrey.h> | 5 #import <EarlGrey/EarlGrey.h> |
6 #import <UIKit/UIKit.h> | 6 #import <UIKit/UIKit.h> |
7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #import "base/mac/bind_objc_block.h" | 11 #import "base/mac/bind_objc_block.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "components/browsing_data/core/pref_names.h" | 14 #include "components/browsing_data/core/pref_names.h" |
15 #include "components/metrics/metrics_pref_names.h" | 15 #include "components/metrics/metrics_pref_names.h" |
16 #include "components/password_manager/core/common/password_manager_pref_names.h" | 16 #include "components/password_manager/core/common/password_manager_pref_names.h" |
17 #include "components/prefs/pref_member.h" | 17 #include "components/prefs/pref_member.h" |
18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
19 #include "components/strings/grit/components_strings.h" | 19 #include "components/strings/grit/components_strings.h" |
| 20 #import "ios/chrome/app/main_controller.h" |
20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 21 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
21 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" | 22 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" |
22 #include "ios/chrome/browser/pref_names.h" | 23 #include "ios/chrome/browser/pref_names.h" |
| 24 #import "ios/chrome/browser/ui/browser_view_controller.h" |
23 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont
roller.h" | 25 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont
roller.h" |
24 #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h" | 26 #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h" |
25 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 27 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
26 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" | 28 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" |
27 #include "ios/chrome/grit/ios_chromium_strings.h" | 29 #include "ios/chrome/grit/ios_chromium_strings.h" |
28 #include "ios/chrome/grit/ios_strings.h" | 30 #include "ios/chrome/grit/ios_strings.h" |
29 #include "ios/chrome/grit/ios_theme_resources.h" | 31 #include "ios/chrome/grit/ios_theme_resources.h" |
30 #import "ios/chrome/test/app/chrome_test_util.h" | 32 #import "ios/chrome/test/app/chrome_test_util.h" |
31 #include "ios/chrome/test/app/navigation_test_util.h" | 33 #include "ios/chrome/test/app/navigation_test_util.h" |
32 #import "ios/chrome/test/app/tab_test_util.h" | 34 #import "ios/chrome/test/app/tab_test_util.h" |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 grey_accessibilityTrait( | 1002 grey_accessibilityTrait( |
1001 UIAccessibilityTraitButton), | 1003 UIAccessibilityTraitButton), |
1002 nil)] performAction:grey_tap()]; | 1004 nil)] performAction:grey_tap()]; |
1003 | 1005 |
1004 [[EarlGrey | 1006 [[EarlGrey |
1005 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( | 1007 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( |
1006 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | 1008 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] |
1007 performAction:grey_tap()]; | 1009 performAction:grey_tap()]; |
1008 } | 1010 } |
1009 | 1011 |
| 1012 // Verifies that the Settings UI registers keyboard commands when presented, but |
| 1013 // not when it itslef presents something. |
| 1014 - (void)testSettingsKeyboardCommands { |
| 1015 // Open Settings. |
| 1016 [ChromeEarlGreyUI openToolsMenu]; |
| 1017 [[EarlGrey selectElementWithMatcher:SettingsButton()] |
| 1018 performAction:grey_tap()]; |
| 1019 [[EarlGrey |
| 1020 selectElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)] |
| 1021 assertWithMatcher:grey_notNil()]; |
| 1022 |
| 1023 // Verify that the Settings register keyboard commands. |
| 1024 MainController* mainController = chrome_test_util::GetMainController(); |
| 1025 BrowserViewController* bvc = |
| 1026 [[mainController browserViewInformation] currentBVC]; |
| 1027 UIViewController* settings = bvc.presentedViewController; |
| 1028 GREYAssertNotNil(settings.keyCommands, |
| 1029 @"Settings should register key commands when presented."); |
| 1030 |
| 1031 // Present the Sign-in UI. |
| 1032 id<GREYMatcher> matcher = |
| 1033 grey_allOf(grey_accessibilityID(kSettingsSignInCellId), |
| 1034 grey_sufficientlyVisible(), nil); |
| 1035 [[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()]; |
| 1036 // Wait for UI to finish loading the Sign-in screen. |
| 1037 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 1038 |
| 1039 // Verify that the Settings register keyboard commands. |
| 1040 GREYAssertNil(settings.keyCommands, |
| 1041 @"Settings should not register key commands when presented."); |
| 1042 |
| 1043 // Dismiss the Sign-in UI. |
| 1044 id<GREYMatcher> cancelButton = |
| 1045 grey_allOf(grey_accessibilityID(@"cancel"), |
| 1046 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); |
| 1047 [[EarlGrey selectElementWithMatcher:cancelButton] performAction:grey_tap()]; |
| 1048 // Wait for UI to finish closing the Sign-in screen. |
| 1049 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 1050 |
| 1051 // Verify that the Settings register keyboard commands. |
| 1052 GREYAssertNotNil(settings.keyCommands, |
| 1053 @"Settings should register key commands when presented."); |
| 1054 } |
| 1055 |
1010 @end | 1056 @end |
OLD | NEW |