| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 - (void)testKeyboardCommandsNotRegistered_SettingsPresented { | 129 - (void)testKeyboardCommandsNotRegistered_SettingsPresented { |
| 130 // Open Settings | 130 // Open Settings |
| 131 id<GREYMatcher> toolsMenuSettings = | 131 id<GREYMatcher> toolsMenuSettings = |
| 132 grey_accessibilityID(kToolsMenuSettingsId); | 132 grey_accessibilityID(kToolsMenuSettingsId); |
| 133 [self selectToolsMenuItem:toolsMenuSettings]; | 133 [self selectToolsMenuItem:toolsMenuSettings]; |
| 134 | 134 |
| 135 [self verifyNoKeyboardCommandsAreRegistered]; | 135 [self verifyNoKeyboardCommandsAreRegistered]; |
| 136 | 136 |
| 137 // Close Settings | 137 // Close Settings |
| 138 id<GREYMatcher> settingsDoneButton = | 138 id<GREYMatcher> settingsDoneButton = |
| 139 chrome_test_util::buttonWithAccessibilityLabelId( | 139 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 140 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON); | 140 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON); |
| 141 [[EarlGrey selectElementWithMatcher:settingsDoneButton] | 141 [[EarlGrey selectElementWithMatcher:settingsDoneButton] |
| 142 performAction:grey_tap()]; | 142 performAction:grey_tap()]; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Tests that keyboard commands are not registered when the bookmark UI is | 145 // Tests that keyboard commands are not registered when the bookmark UI is |
| 146 // shown. | 146 // shown. |
| 147 - (void)testKeyboardCommandsNotRegistered_AddBookmarkPresented { | 147 - (void)testKeyboardCommandsNotRegistered_AddBookmarkPresented { |
| 148 [self verifyBookmarksLoaded]; | 148 [self verifyBookmarksLoaded]; |
| 149 BOOL success = chrome_test_util::ClearBookmarks(); | 149 BOOL success = chrome_test_util::ClearBookmarks(); |
| 150 GREYAssert(success, @"Not all bookmarks were removed."); | 150 GREYAssert(success, @"Not all bookmarks were removed."); |
| 151 | 151 |
| 152 // Bookmark page | 152 // Bookmark page |
| 153 if (IsIPadIdiom()) { | 153 if (IsIPadIdiom()) { |
| 154 id<GREYMatcher> bookmarkMatcher = | 154 id<GREYMatcher> bookmarkMatcher = |
| 155 chrome_test_util::buttonWithAccessibilityLabelId(IDS_TOOLTIP_STAR); | 155 chrome_test_util::ButtonWithAccessibilityLabelId(IDS_TOOLTIP_STAR); |
| 156 [[EarlGrey selectElementWithMatcher:bookmarkMatcher] | 156 [[EarlGrey selectElementWithMatcher:bookmarkMatcher] |
| 157 performAction:grey_tap()]; | 157 performAction:grey_tap()]; |
| 158 } else { | 158 } else { |
| 159 [ChromeEarlGreyUI openToolsMenu]; | 159 [ChromeEarlGreyUI openToolsMenu]; |
| 160 id<GREYMatcher> bookmarkMatcher = grey_accessibilityLabel(@"Add Bookmark"); | 160 id<GREYMatcher> bookmarkMatcher = grey_accessibilityLabel(@"Add Bookmark"); |
| 161 [[EarlGrey selectElementWithMatcher:bookmarkMatcher] | 161 [[EarlGrey selectElementWithMatcher:bookmarkMatcher] |
| 162 performAction:grey_tap()]; | 162 performAction:grey_tap()]; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Tap on the HUD. | 165 // Tap on the HUD. |
| 166 id<GREYMatcher> edit = chrome_test_util::buttonWithAccessibilityLabelId( | 166 id<GREYMatcher> edit = chrome_test_util::ButtonWithAccessibilityLabelId( |
| 167 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON); | 167 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON); |
| 168 [[EarlGrey selectElementWithMatcher:edit] performAction:grey_tap()]; | 168 [[EarlGrey selectElementWithMatcher:edit] performAction:grey_tap()]; |
| 169 | 169 |
| 170 [self waitForSingleBookmarkEditorToDisplay]; | 170 [self waitForSingleBookmarkEditorToDisplay]; |
| 171 | 171 |
| 172 [self verifyNoKeyboardCommandsAreRegistered]; | 172 [self verifyNoKeyboardCommandsAreRegistered]; |
| 173 | 173 |
| 174 id<GREYMatcher> cancel = grey_accessibilityID(@"Cancel"); | 174 id<GREYMatcher> cancel = grey_accessibilityID(@"Cancel"); |
| 175 [[EarlGrey selectElementWithMatcher:cancel] performAction:grey_tap()]; | 175 [[EarlGrey selectElementWithMatcher:cancel] performAction:grey_tap()]; |
| 176 } | 176 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 [self verifyKeyboardCommandsAreRegistered]; | 219 [self verifyKeyboardCommandsAreRegistered]; |
| 220 | 220 |
| 221 UIResponder* firstResponder = GetFirstResponder(); | 221 UIResponder* firstResponder = GetFirstResponder(); |
| 222 GREYAssert( | 222 GREYAssert( |
| 223 [firstResponder isKindOfClass:NSClassFromString(@"WKContentView")], | 223 [firstResponder isKindOfClass:NSClassFromString(@"WKContentView")], |
| 224 @"Expected first responder to be a WKContentView. Instead, is a %@", | 224 @"Expected first responder to be a WKContentView. Instead, is a %@", |
| 225 NSStringFromClass([firstResponder class])); | 225 NSStringFromClass([firstResponder class])); |
| 226 } | 226 } |
| 227 | 227 |
| 228 @end | 228 @end |
| OLD | NEW |