| 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 <XCTest/XCTest.h> | 6 #import <XCTest/XCTest.h> |
| 7 | 7 |
| 8 #include "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.h" |
| 9 #import "ios/chrome/browser/ui/browser_view_controller.h" | 9 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 21 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 22 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 22 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 23 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 23 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 24 #import "ios/web/public/test/http_server.h" | 24 #import "ios/web/public/test/http_server.h" |
| 25 #include "ios/web/public/test/http_server_util.h" | 25 #include "ios/web/public/test/http_server_util.h" |
| 26 | 26 |
| 27 #if !defined(__has_feature) || !__has_feature(objc_arc) | 27 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 28 #error "This file requires ARC support." | 28 #error "This file requires ARC support." |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 using chrome_test_util::NavigationBarDoneButton; |
| 32 |
| 31 const CGFloat kScrollDisplacement = 50.0; | 33 const CGFloat kScrollDisplacement = 50.0; |
| 32 | 34 |
| 33 // Test cases to verify that keyboard commands are and are not registered when | 35 // Test cases to verify that keyboard commands are and are not registered when |
| 34 // expected. | 36 // expected. |
| 35 @interface KeyboardCommandsTestCase : ChromeTestCase | 37 @interface KeyboardCommandsTestCase : ChromeTestCase |
| 36 @end | 38 @end |
| 37 | 39 |
| 38 @implementation KeyboardCommandsTestCase | 40 @implementation KeyboardCommandsTestCase |
| 39 | 41 |
| 40 #pragma mark - Helpers | 42 #pragma mark - Helpers |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 133 |
| 132 // Tests that keyboard commands are not registered when Settings are shown. | 134 // Tests that keyboard commands are not registered when Settings are shown. |
| 133 - (void)testKeyboardCommandsNotRegistered_SettingsPresented { | 135 - (void)testKeyboardCommandsNotRegistered_SettingsPresented { |
| 134 // Open Settings | 136 // Open Settings |
| 135 id<GREYMatcher> toolsMenuSettings = | 137 id<GREYMatcher> toolsMenuSettings = |
| 136 grey_accessibilityID(kToolsMenuSettingsId); | 138 grey_accessibilityID(kToolsMenuSettingsId); |
| 137 [self selectToolsMenuItem:toolsMenuSettings]; | 139 [self selectToolsMenuItem:toolsMenuSettings]; |
| 138 | 140 |
| 139 [self verifyNoKeyboardCommandsAreRegistered]; | 141 [self verifyNoKeyboardCommandsAreRegistered]; |
| 140 | 142 |
| 141 // Close Settings | 143 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
| 142 id<GREYMatcher> settingsDoneButton = | |
| 143 chrome_test_util::ButtonWithAccessibilityLabelId( | |
| 144 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON); | |
| 145 [[EarlGrey selectElementWithMatcher:settingsDoneButton] | |
| 146 performAction:grey_tap()]; | 144 performAction:grey_tap()]; |
| 147 } | 145 } |
| 148 | 146 |
| 149 // Tests that keyboard commands are not registered when the bookmark UI is | 147 // Tests that keyboard commands are not registered when the bookmark UI is |
| 150 // shown. | 148 // shown. |
| 151 - (void)testKeyboardCommandsNotRegistered_AddBookmarkPresented { | 149 - (void)testKeyboardCommandsNotRegistered_AddBookmarkPresented { |
| 152 [self verifyBookmarksLoaded]; | 150 [self verifyBookmarksLoaded]; |
| 153 BOOL success = chrome_test_util::ClearBookmarks(); | 151 BOOL success = chrome_test_util::ClearBookmarks(); |
| 154 GREYAssert(success, @"Not all bookmarks were removed."); | 152 GREYAssert(success, @"Not all bookmarks were removed."); |
| 155 | 153 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 [self verifyKeyboardCommandsAreRegistered]; | 221 [self verifyKeyboardCommandsAreRegistered]; |
| 224 | 222 |
| 225 UIResponder* firstResponder = GetFirstResponder(); | 223 UIResponder* firstResponder = GetFirstResponder(); |
| 226 GREYAssert( | 224 GREYAssert( |
| 227 [firstResponder isKindOfClass:NSClassFromString(@"WKContentView")], | 225 [firstResponder isKindOfClass:NSClassFromString(@"WKContentView")], |
| 228 @"Expected first responder to be a WKContentView. Instead, is a %@", | 226 @"Expected first responder to be a WKContentView. Instead, is a %@", |
| 229 NSStringFromClass([firstResponder class])); | 227 NSStringFromClass([firstResponder class])); |
| 230 } | 228 } |
| 231 | 229 |
| 232 @end | 230 @end |
| OLD | NEW |