Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm

Issue 2825673003: Enable testShowJavaScriptAfterNewTabAnimation for iPad (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #import "base/strings/sys_string_conversions.h" 9 #import "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 548
549 // Tests that an alert is presented after a new tab animation is finished. 549 // Tests that an alert is presented after a new tab animation is finished.
550 - (void)testShowJavaScriptAfterNewTabAnimation { 550 - (void)testShowJavaScriptAfterNewTabAnimation {
551 // TODO(crbug.com/663026): Reenable the test for devices. 551 // TODO(crbug.com/663026): Reenable the test for devices.
552 #if !TARGET_IPHONE_SIMULATOR 552 #if !TARGET_IPHONE_SIMULATOR
553 EARL_GREY_TEST_DISABLED(@"Disabled for devices because existing system " 553 EARL_GREY_TEST_DISABLED(@"Disabled for devices because existing system "
554 @"alerts would prevent app alerts to present " 554 @"alerts would prevent app alerts to present "
555 @"correctly."); 555 @"correctly.");
556 #endif 556 #endif
557 557
558 // TODO(crbug.com/711291): reenable this on tablets.
559 if (IsIPadIdiom()) {
560 EARL_GREY_TEST_DISABLED(@"Disabled for iPad.");
561 }
562
563 // Load the test page with a link to kOnLoadAlertURL and long tap on the link. 558 // Load the test page with a link to kOnLoadAlertURL and long tap on the link.
564 [self loadPageWithLink]; 559 [self loadPageWithLink];
565 id<GREYMatcher> webViewMatcher = 560 id<GREYMatcher> webViewMatcher =
566 chrome_test_util::WebViewContainingText(std::string(kPageWithLinkText)); 561 chrome_test_util::WebViewContainingText(std::string(kPageWithLinkText));
567 [[EarlGrey selectElementWithMatcher:webViewMatcher] 562 [[EarlGrey selectElementWithMatcher:webViewMatcher]
568 performAction:chrome_test_util::LongPressElementForContextMenu( 563 performAction:chrome_test_util::LongPressElementForContextMenu(
569 kLinkID, true /* menu should appear */)]; 564 kLinkID, true /* menu should appear */)];
570 565
571 // Tap on the "Open In New Tab" button. 566 // Tap on the "Open In New Tab" button.
572 id<GREYMatcher> newTabMatcher = testing::ContextMenuItemWithText( 567 id<GREYMatcher> newTabMatcher = testing::ContextMenuItemWithText(
573 l10n_util::GetNSStringWithFixup(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)); 568 l10n_util::GetNSStringWithFixup(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB));
574 [[EarlGrey selectElementWithMatcher:newTabMatcher] performAction:grey_tap()]; 569 [[EarlGrey selectElementWithMatcher:newTabMatcher] performAction:grey_tap()];
575 570
571 // This test case requires that a dialog is presented in the onload event so
572 // that the DialogPresenter attempts to display during a new tab animation.
573 // Because presenting a dialog halts the JavaScript execution on the page,
574 // this prevents the page loaded event from being received until the alert is
575 // closed. On iPad, this means that there is a loading indicator that
576 // continues to animate until the dialog is closed. Disabling EarlGrey
577 // synchronization code for iPad allows the test to detect and dismiss the
578 // dialog while this animation is occurring.
579 if (IsIPadIdiom()) {
580 [[GREYConfiguration sharedInstance]
581 setValue:@(NO)
582 forConfigKey:kGREYConfigKeySynchronizationEnabled];
baxley 2017/04/18 23:15:31 Should we also add the call to enable synchronizat
kkhorimoto 2017/04/19 18:40:38 Done.
583 }
584
576 // Wait for the alert to be shown. 585 // Wait for the alert to be shown.
577 NSString* alertLabel = [DialogPresenter 586 NSString* alertLabel = [DialogPresenter
578 localizedTitleForJavaScriptAlertFromPage:HttpServer::MakeUrl( 587 localizedTitleForJavaScriptAlertFromPage:HttpServer::MakeUrl(
579 kJavaScriptTestURL)]; 588 kJavaScriptTestURL)];
580 WaitForAlertToBeShown(alertLabel); 589 WaitForAlertToBeShown(alertLabel);
581 590
582 // Verify that the omnibox shows the correct URL when the dialog is visible. 591 // Verify that the omnibox shows the correct URL when the dialog is visible.
583 GURL onloadURL = HttpServer::MakeUrl(kOnLoadAlertURL); 592 GURL onloadURL = HttpServer::MakeUrl(kOnLoadAlertURL);
584 std::string title = base::UTF16ToUTF8(web::GetDisplayTitleForUrl(onloadURL)); 593 std::string title = base::UTF16ToUTF8(web::GetDisplayTitleForUrl(onloadURL));
585 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(title)] 594 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(title)]
586 assertWithMatcher:grey_notNil()]; 595 assertWithMatcher:grey_notNil()];
587 596
588 // Close the alert. 597 // Close the alert.
589 TapOK(); 598 TapOK();
599
600 // Reenable synchronization on iPads now that the dialog has been dismissed.
601 if (IsIPadIdiom()) {
602 [[GREYConfiguration sharedInstance]
603 setValue:@(YES)
604 forConfigKey:kGREYConfigKeySynchronizationEnabled];
605 }
590 } 606 }
591 607
592 @end 608 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698