OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <EarlGrey/EarlGrey.h> |
| 6 #import <XCTest/XCTest.h> |
| 7 |
| 8 #include "base/ios/ios_util.h" |
| 9 #include "components/strings/grit/components_strings.h" |
| 10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 11 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 12 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" |
| 13 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h" |
| 14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 15 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
| 16 #include "ios/chrome/browser/ui/ui_util.h" |
| 17 #include "ios/chrome/grit/ios_strings.h" |
| 18 #import "ios/chrome/test/app/chrome_test_util.h" |
| 19 #import "ios/chrome/test/app/tab_test_util.h" |
| 20 #import "ios/chrome/test/earl_grey/chrome_assertions.h" |
| 21 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 22 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 23 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 24 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 25 #import "ios/testing/earl_grey/disabled_test_macros.h" |
| 26 #import "ios/web/public/test/http_server.h" |
| 27 #include "ios/web/public/test/http_server_util.h" |
| 28 #include "ui/base/l10n/l10n_util_mac.h" |
| 29 |
| 30 using chrome_test_util::buttonWithAccessibilityLabelId; |
| 31 using chrome_test_util::omniboxText; |
| 32 using chrome_test_util::webViewContainingText; |
| 33 |
| 34 // Toolbar integration tests for Chrome. |
| 35 @interface ToolbarTestCase : ChromeTestCase |
| 36 @end |
| 37 |
| 38 namespace { |
| 39 |
| 40 // Displays the |panel_type| new tab page. On a phone this will send a command |
| 41 // to display a dialog, on tablet this calls -selectPanel to slide the NTP. |
| 42 void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) { |
| 43 NewTabPageController* ntp_controller = |
| 44 chrome_test_util::GetCurrentNewTabPageController(); |
| 45 if (IsIPadIdiom()) { |
| 46 [ntp_controller selectPanel:panel_type]; |
| 47 } else { |
| 48 NSUInteger tag = 0; |
| 49 if (panel_type == NewTabPage::PanelIdentifier::kBookmarksPanel) { |
| 50 tag = IDC_SHOW_BOOKMARK_MANAGER; |
| 51 } else if (panel_type == NewTabPage::PanelIdentifier::kOpenTabsPanel) { |
| 52 tag = IDC_SHOW_OTHER_DEVICES; |
| 53 } |
| 54 if (tag) { |
| 55 base::scoped_nsobject<GenericChromeCommand> command( |
| 56 [[GenericChromeCommand alloc] initWithTag:tag]); |
| 57 chrome_test_util::RunCommandWithActiveViewController(command); |
| 58 } |
| 59 } |
| 60 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 61 } |
| 62 |
| 63 } // namespace |
| 64 |
| 65 @implementation ToolbarTestCase |
| 66 |
| 67 #pragma mark Tests |
| 68 |
| 69 // Verifies that entering a URL in the omnibox navigates to the correct URL and |
| 70 // displays content. |
| 71 - (void)testEnterURL { |
| 72 web::test::SetUpFileBasedHttpServer(); |
| 73 const GURL URL = web::test::HttpServer::MakeUrl( |
| 74 "http://ios/testing/data/http_server_files/destination.html"); |
| 75 [ChromeEarlGrey loadURL:URL]; |
| 76 [[EarlGrey selectElementWithMatcher:omniboxText(URL.GetContent())] |
| 77 assertWithMatcher:grey_notNil()]; |
| 78 [[EarlGrey selectElementWithMatcher:webViewContainingText("You've arrived")] |
| 79 assertWithMatcher:grey_notNil()]; |
| 80 } |
| 81 |
| 82 // Verifies opening a new tab from the tools menu. |
| 83 - (void)testNewTabFromMenu { |
| 84 chrome_test_util::AssertMainTabCount(1); |
| 85 |
| 86 // Open tab via the UI. |
| 87 [ChromeEarlGreyUI openToolsMenu]; |
| 88 id<GREYMatcher> newTabButtonMatcher = |
| 89 grey_accessibilityID(kToolsMenuNewTabId); |
| 90 [[EarlGrey selectElementWithMatcher:newTabButtonMatcher] |
| 91 performAction:grey_tap()]; |
| 92 |
| 93 chrome_test_util::AssertMainTabCount(2); |
| 94 } |
| 95 |
| 96 // Verifies opening a new incognito tab from the tools menu. |
| 97 // TODO(crbug.com/631078): Enable this test. |
| 98 - (void)DISABLED_testNewIncognitoTabFromMenu { |
| 99 chrome_test_util::AssertIncognitoTabCount(0); |
| 100 |
| 101 // Open incognito tab. |
| 102 [ChromeEarlGreyUI openToolsMenu]; |
| 103 id<GREYMatcher> newIncognitoTabButtonMatcher = |
| 104 grey_accessibilityID(kToolsMenuNewIncognitoTabId); |
| 105 [[EarlGrey selectElementWithMatcher:newIncognitoTabButtonMatcher] |
| 106 performAction:grey_tap()]; |
| 107 |
| 108 chrome_test_util::AssertIncognitoTabCount(1); |
| 109 } |
| 110 |
| 111 // Tests whether input mode in an omnibox can be canceled via "Cancel" button |
| 112 // and asserts it doesn't commit the omnibox contents if the input is canceled. |
| 113 - (void)testToolbarOmniboxCancel { |
| 114 // Handset only (tablet does not have cancel button). |
| 115 if (IsIPadIdiom()) { |
| 116 EARL_GREY_TEST_SKIPPED(@"Test not support on iPad"); |
| 117 } |
| 118 |
| 119 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); |
| 120 |
| 121 [ChromeEarlGrey loadURL:URL]; |
| 122 |
| 123 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 124 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 125 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 126 performAction:grey_typeText(@"foo")]; |
| 127 |
| 128 id<GREYMatcher> CancelButton = |
| 129 grey_allOf(chrome_test_util::buttonWithAccessibilityLabelId(IDS_CANCEL), |
| 130 grey_not(grey_accessibilityID(@"Typing Shield")), nil); |
| 131 [[EarlGrey selectElementWithMatcher:CancelButton] performAction:grey_tap()]; |
| 132 |
| 133 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 134 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 135 } |
| 136 |
| 137 // Tests whether input mode in an omnibox can be canceled via "hide keyboard" |
| 138 // button and asserts it doesn't commit the omnibox contents if the input is |
| 139 // canceled. |
| 140 - (void)testToolbarOmniboxHideKeyboard { |
| 141 // TODO(crbug.com/642559): Enable the test for iPad when typing bug is fixed. |
| 142 if (IsIPadIdiom()) { |
| 143 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug."); |
| 144 } |
| 145 |
| 146 // Tablet only (handset keyboard does not have "hide keyboard" button). |
| 147 if (!IsIPadIdiom()) { |
| 148 EARL_GREY_TEST_SKIPPED(@"Test not support on iPhone"); |
| 149 } |
| 150 |
| 151 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); |
| 152 |
| 153 [ChromeEarlGrey loadURL:URL]; |
| 154 |
| 155 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 156 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 157 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 158 performAction:grey_typeText(@"foo")]; |
| 159 |
| 160 id<GREYMatcher> hideKeyboard = grey_accessibilityLabel(@"Hide keyboard"); |
| 161 [[EarlGrey selectElementWithMatcher:hideKeyboard] performAction:grey_tap()]; |
| 162 |
| 163 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 164 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 165 } |
| 166 |
| 167 // Tests whether input mode in an omnibox can be canceled via tapping the typing |
| 168 // shield and asserts it doesn't commit the omnibox contents if the input is |
| 169 // canceled. |
| 170 - (void)testToolbarOmniboxTypingShield { |
| 171 // Tablet only (handset keyboard does not have "hide keyboard" button). |
| 172 if (!IsIPadIdiom()) { |
| 173 EARL_GREY_TEST_SKIPPED(@"Test not support on iPhone"); |
| 174 } |
| 175 |
| 176 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); |
| 177 |
| 178 [ChromeEarlGrey loadURL:URL]; |
| 179 |
| 180 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 181 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 182 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 183 performAction:grey_typeText(@"foo")]; |
| 184 |
| 185 id<GREYMatcher> typingShield = grey_accessibilityID(@"Typing Shield"); |
| 186 [[EarlGrey selectElementWithMatcher:typingShield] performAction:grey_tap()]; |
| 187 |
| 188 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 189 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 190 } |
| 191 |
| 192 // Verifies the existence and state of toolbar UI elements. |
| 193 - (void)testToolbarUI { |
| 194 id<GREYMatcher> backButton = |
| 195 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); |
| 196 id<GREYMatcher> forwardButton = |
| 197 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_FORWARD); |
| 198 id<GREYMatcher> reloadButton = |
| 199 chrome_test_util::buttonWithAccessibilityLabelId(IDS_IOS_ACCNAME_RELOAD); |
| 200 id<GREYMatcher> bookmarkButton = |
| 201 chrome_test_util::buttonWithAccessibilityLabelId(IDS_TOOLTIP_STAR); |
| 202 id<GREYMatcher> voiceSearchButton = |
| 203 grey_allOf(chrome_test_util::buttonWithAccessibilityLabelId( |
| 204 IDS_IOS_ACCNAME_VOICE_SEARCH), |
| 205 grey_ancestor(grey_kindOfClass([ToolbarView class])), nil); |
| 206 NSString* ntpOmniboxLabel = l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT); |
| 207 NSString* focusedOmniboxLabel = l10n_util::GetNSString(IDS_ACCNAME_LOCATION); |
| 208 NSString* omniboxLabel = |
| 209 IsIPadIdiom() ? focusedOmniboxLabel : ntpOmniboxLabel; |
| 210 id<GREYMatcher> locationbarButton = |
| 211 grey_allOf(grey_accessibilityLabel(omniboxLabel), |
| 212 grey_minimumVisiblePercent(0.2), nil); |
| 213 |
| 214 [[EarlGrey selectElementWithMatcher:locationbarButton] |
| 215 assertWithMatcher:grey_sufficientlyVisible()]; |
| 216 |
| 217 if (IsIPadIdiom()) { |
| 218 [[EarlGrey selectElementWithMatcher:backButton] |
| 219 assertWithMatcher:grey_sufficientlyVisible()]; |
| 220 [[EarlGrey selectElementWithMatcher:forwardButton] |
| 221 assertWithMatcher:grey_sufficientlyVisible()]; |
| 222 [[EarlGrey selectElementWithMatcher:reloadButton] |
| 223 assertWithMatcher:grey_sufficientlyVisible()]; |
| 224 [[EarlGrey selectElementWithMatcher:bookmarkButton] |
| 225 assertWithMatcher:grey_sufficientlyVisible()]; |
| 226 [[EarlGrey selectElementWithMatcher:voiceSearchButton] |
| 227 assertWithMatcher:grey_sufficientlyVisible()]; |
| 228 } else { |
| 229 [[EarlGrey selectElementWithMatcher:chrome_test_util::toolsMenuButton()] |
| 230 assertWithMatcher:grey_sufficientlyVisible()]; |
| 231 [[EarlGrey selectElementWithMatcher:chrome_test_util::showTabsButton()] |
| 232 assertWithMatcher:grey_sufficientlyVisible()]; |
| 233 } |
| 234 |
| 235 // Navigate to a page and verify the back button is enabled. |
| 236 [ChromeEarlGrey loadURL:GURL("chrome://version")]; |
| 237 [[EarlGrey selectElementWithMatcher:backButton] |
| 238 assertWithMatcher:grey_interactable()]; |
| 239 } |
| 240 |
| 241 // Verifies that the keyboard is properly dismissed when a toolbar button |
| 242 // is pressed (iPad specific). |
| 243 - (void)testIPadKeyboardDismissOnButtonPress { |
| 244 // Tablet only (handset keyboard does not have "hide keyboard" button). |
| 245 if (!IsIPadIdiom()) { |
| 246 EARL_GREY_TEST_SKIPPED(@"Test not supported on iPhone"); |
| 247 } |
| 248 |
| 249 // Load some page so that the "Back" button is tappable. |
| 250 [ChromeEarlGrey loadURL:GURL("chrome://version")]; |
| 251 |
| 252 // First test: check that the keyboard is opened when tapping the omnibox, |
| 253 // and that it is dismissed when the "Back" button is tapped. |
| 254 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 255 performAction:grey_tap()]; |
| 256 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] |
| 257 assertWithMatcher:grey_notNil()]; |
| 258 |
| 259 id<GREYMatcher> backButton = |
| 260 chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK); |
| 261 [[EarlGrey selectElementWithMatcher:backButton] performAction:grey_tap()]; |
| 262 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] |
| 263 assertWithMatcher:grey_notVisible()]; |
| 264 |
| 265 // Second test: check that the keyboard is opened when tapping the omnibox, |
| 266 // and that it is dismissed when the tools menu button is tapped. |
| 267 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 268 performAction:grey_tap()]; |
| 269 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] |
| 270 assertWithMatcher:grey_notNil()]; |
| 271 |
| 272 [[EarlGrey selectElementWithMatcher:chrome_test_util::toolsMenuButton()] |
| 273 performAction:grey_tap()]; |
| 274 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Typing Shield")] |
| 275 assertWithMatcher:grey_notVisible()]; |
| 276 } |
| 277 |
| 278 // Verifies that copying and pasting a URL includes the hidden protocol prefix. |
| 279 - (void)testCopyPasteURL { |
| 280 std::map<GURL, std::string> responses; |
| 281 const GURL URL = web::test::HttpServer::MakeUrl("http://testPage"); |
| 282 const GURL secondURL = web::test::HttpServer::MakeUrl("http://pastePage"); |
| 283 |
| 284 [ChromeEarlGrey loadURL:URL]; |
| 285 |
| 286 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 287 assertWithMatcher:chrome_test_util::omniboxText(URL.GetContent())]; |
| 288 |
| 289 NSString* shareButtonLabel = l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_SHARE); |
| 290 if (!IsIPadIdiom()) { |
| 291 [ChromeEarlGreyUI openToolsMenu]; |
| 292 } |
| 293 id<GREYMatcher> share_button = |
| 294 chrome_test_util::buttonWithAccessibilityLabel(shareButtonLabel); |
| 295 [[EarlGrey selectElementWithMatcher:share_button] performAction:grey_tap()]; |
| 296 |
| 297 [[EarlGrey |
| 298 selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabel( |
| 299 @"Copy")] performAction:grey_tap()]; |
| 300 |
| 301 [ChromeEarlGrey loadURL:secondURL]; |
| 302 |
| 303 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 304 performAction:grey_longPress()]; |
| 305 |
| 306 id<GREYMatcher> pasteBarButton = grey_allOf( |
| 307 grey_accessibilityLabel(@"Paste"), |
| 308 grey_not(grey_accessibilityTrait(UIAccessibilityTraitButton)), |
| 309 grey_not(grey_accessibilityTrait(UIAccessibilityTraitStaticText)), nil); |
| 310 [[EarlGrey selectElementWithMatcher:pasteBarButton] performAction:grey_tap()]; |
| 311 |
| 312 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 313 assertWithMatcher:chrome_test_util::omniboxText(URL.spec().c_str())]; |
| 314 } |
| 315 |
| 316 // Verifies that the clear text button clears any text in the omnibox. |
| 317 - (void)testOmniboxClearTextButton { |
| 318 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); |
| 319 |
| 320 [ChromeEarlGrey loadURL:URL]; |
| 321 |
| 322 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 323 performAction:grey_typeText(@"foo")]; |
| 324 |
| 325 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 326 assertWithMatcher:chrome_test_util::omniboxText("foo")]; |
| 327 |
| 328 id<GREYMatcher> CancelButton = grey_accessibilityLabel(@"Clear Text"); |
| 329 [[EarlGrey selectElementWithMatcher:CancelButton] performAction:grey_tap()]; |
| 330 |
| 331 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 332 assertWithMatcher:chrome_test_util::omniboxText("")]; |
| 333 } |
| 334 |
| 335 // Types JavaScript into Omnibox and verify that an alert is displayed. |
| 336 - (void)testTypeJavaScriptIntoOmnibox { |
| 337 // TODO(crbug.com/642544): Enable the test for iPad when typing bug is fixed. |
| 338 if (IsIPadIdiom() && base::ios::IsRunningOnIOS10OrLater()) { |
| 339 EARL_GREY_TEST_DISABLED(@"Disabled for iOS10 iPad due to a typing bug."); |
| 340 } |
| 341 [ChromeEarlGrey loadURL:GURL("chrome://version")]; |
| 342 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 343 performAction:grey_typeText(@"javascript:alert('Hello');")]; |
| 344 |
| 345 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")] |
| 346 performAction:grey_tap()]; |
| 347 |
| 348 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Hello")] |
| 349 assertWithMatcher:grey_notNil()]; |
| 350 } |
| 351 |
| 352 // Tests typing in the omnibox. |
| 353 - (void)testToolbarOmniboxTyping { |
| 354 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel); |
| 355 |
| 356 id<GREYMatcher> locationbarButton = grey_allOf( |
| 357 grey_accessibilityLabel(l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)), |
| 358 grey_minimumVisiblePercent(0.2), nil); |
| 359 [[EarlGrey selectElementWithMatcher:locationbarButton] |
| 360 assertWithMatcher:grey_text(@"Search or type URL")]; |
| 361 |
| 362 [[EarlGrey selectElementWithMatcher:locationbarButton] |
| 363 performAction:grey_typeText(@"a")]; |
| 364 [[EarlGrey |
| 365 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"a"), |
| 366 grey_kindOfClass( |
| 367 [OmniboxPopupMaterialRow class]), |
| 368 nil)] |
| 369 assertWithMatcher:grey_sufficientlyVisible()]; |
| 370 |
| 371 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 372 performAction:grey_typeText(@"b")]; |
| 373 [[EarlGrey |
| 374 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"ab"), |
| 375 grey_kindOfClass( |
| 376 [OmniboxPopupMaterialRow class]), |
| 377 nil)] |
| 378 assertWithMatcher:grey_sufficientlyVisible()]; |
| 379 |
| 380 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 381 performAction:grey_typeText(@"C")]; |
| 382 [[EarlGrey |
| 383 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC"), |
| 384 grey_kindOfClass( |
| 385 [OmniboxPopupMaterialRow class]), |
| 386 nil)] |
| 387 assertWithMatcher:grey_sufficientlyVisible()]; |
| 388 |
| 389 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 390 performAction:grey_typeText(@"1")]; |
| 391 [[EarlGrey |
| 392 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC1"), |
| 393 grey_kindOfClass( |
| 394 [OmniboxPopupMaterialRow class]), |
| 395 nil)] |
| 396 assertWithMatcher:grey_sufficientlyVisible()]; |
| 397 |
| 398 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 399 performAction:grey_typeText(@"2")]; |
| 400 [[EarlGrey |
| 401 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12"), |
| 402 grey_kindOfClass( |
| 403 [OmniboxPopupMaterialRow class]), |
| 404 nil)] |
| 405 assertWithMatcher:grey_sufficientlyVisible()]; |
| 406 |
| 407 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 408 performAction:grey_typeText(@"@")]; |
| 409 [[EarlGrey |
| 410 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@"), |
| 411 grey_kindOfClass( |
| 412 [OmniboxPopupMaterialRow class]), |
| 413 nil)] |
| 414 assertWithMatcher:grey_sufficientlyVisible()]; |
| 415 |
| 416 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 417 performAction:grey_typeText(@"{")]; |
| 418 [[EarlGrey |
| 419 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@{"), |
| 420 grey_kindOfClass( |
| 421 [OmniboxPopupMaterialRow class]), |
| 422 nil)] |
| 423 assertWithMatcher:grey_sufficientlyVisible()]; |
| 424 |
| 425 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 426 performAction:grey_typeText(@"#")]; |
| 427 [[EarlGrey |
| 428 selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(@"abC12@{#"), |
| 429 grey_kindOfClass( |
| 430 [OmniboxPopupMaterialRow class]), |
| 431 nil)] |
| 432 assertWithMatcher:grey_sufficientlyVisible()]; |
| 433 |
| 434 // TODO(crbug.com/642559): Enable these steps for iPad when typing bug |
| 435 // is fixed. |
| 436 if (IsIPadIdiom()) { |
| 437 EARL_GREY_TEST_DISABLED(@"Disabled for iPad due to a simulator bug."); |
| 438 } else { |
| 439 NSString* cancelButton = l10n_util::GetNSString(IDS_CANCEL); |
| 440 NSString* typingShield = @"Hide keyboard"; |
| 441 NSString* clearText = IsIPadIdiom() ? typingShield : cancelButton; |
| 442 |
| 443 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(clearText)] |
| 444 performAction:grey_tap()]; |
| 445 [[EarlGrey selectElementWithMatcher:chrome_test_util::omnibox()] |
| 446 assertWithMatcher:chrome_test_util::omniboxText("")]; |
| 447 |
| 448 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel); |
| 449 } |
| 450 } |
| 451 @end |
OLD | NEW |