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

Side by Side Diff: ios/chrome/browser/web/browsing_egtest.mm

Issue 2793233004: Add wait to testBrowsingPostEntryWithKeyboard. (Closed)
Patch Set: edit naming 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 <XCTest/XCTest.h> 5 #import <XCTest/XCTest.h>
6 #include <map> 6 #include <map>
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/ios/ios_util.h" 10 #include "base/ios/ios_util.h"
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // forward again. 572 // forward again.
573 [self goBack]; 573 [self goBack];
574 [[EarlGrey selectElementWithMatcher:OmniboxText(firstURL.GetContent())] 574 [[EarlGrey selectElementWithMatcher:OmniboxText(firstURL.GetContent())]
575 assertWithMatcher:grey_notNil()]; 575 assertWithMatcher:grey_notNil()];
576 [self goForward]; 576 [self goForward];
577 [[EarlGrey selectElementWithMatcher:OmniboxText(secondURL.GetContent())] 577 [[EarlGrey selectElementWithMatcher:OmniboxText(secondURL.GetContent())]
578 assertWithMatcher:grey_notNil()]; 578 assertWithMatcher:grey_notNil()];
579 } 579 }
580 580
581 // Tap the text field indicated by |ID| to open the keyboard, and then 581 // Tap the text field indicated by |ID| to open the keyboard, and then
582 // press the keyboard's "Go" button. 582 // press the keyboard's "Go" button to submit the form.
583 - (void)openKeyboardAndTapGoButtonWithTextFieldID:(const std::string&)ID { 583 - (void)submitFormUsingKeyboardGoButtonWithInputID:(const std::string&)ID {
584 // Disable EarlGrey's synchronization since it is blocked by opening the 584 // Disable EarlGrey's synchronization since it is blocked by opening the
585 // keyboard from a web view. 585 // keyboard from a web view.
586 [[GREYConfiguration sharedInstance] 586 [[GREYConfiguration sharedInstance]
587 setValue:@NO 587 setValue:@NO
588 forConfigKey:kGREYConfigKeySynchronizationEnabled]; 588 forConfigKey:kGREYConfigKeySynchronizationEnabled];
589 589
590 // Wait for web view to be interactable before tapping. 590 // Wait for web view to be interactable before tapping.
591 GREYCondition* interactableCondition = [GREYCondition 591 GREYCondition* interactableCondition = [GREYCondition
592 conditionWithName:@"Wait for web view to be interactable." 592 conditionWithName:@"Wait for web view to be interactable."
593 block:^BOOL { 593 block:^BOOL {
(...skipping 26 matching lines...) Expand all
620 GREYAssert([condition waitWithTimeout:10], 620 GREYAssert([condition waitWithTimeout:10],
621 @"No keyboard with 'Go' button showed up."); 621 @"No keyboard with 'Go' button showed up.");
622 622
623 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")] 623 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")]
624 performAction:grey_tap()]; 624 performAction:grey_tap()];
625 625
626 // Reenable synchronization now that the keyboard has been closed. 626 // Reenable synchronization now that the keyboard has been closed.
627 [[GREYConfiguration sharedInstance] 627 [[GREYConfiguration sharedInstance]
628 setValue:@YES 628 setValue:@YES
629 forConfigKey:kGREYConfigKeySynchronizationEnabled]; 629 forConfigKey:kGREYConfigKeySynchronizationEnabled];
630
631 // Ensure that the new page loaded before continuing.
632 [ChromeEarlGrey waitForPageToFinishLoading];
630 } 633 }
631 634
632 // Tests that submitting a POST-based form by tapping the 'Go' button on the 635 // Tests that submitting a POST-based form by tapping the 'Go' button on the
633 // keyboard navigates to the correct URL and the back button works as expected 636 // keyboard navigates to the correct URL and the back button works as expected
634 // afterwards. 637 // afterwards.
635 // TODO(crbug.com/704618): Re-enable this test when the flake is fixed. 638 // TODO(crbug.com/704618): Re-enable this test when the flake is fixed.
636 - (void)FLAKY_testBrowsingPostEntryWithKeyboard { 639 - (void)FLAKY_testBrowsingPostEntryWithKeyboard {
637 // Create map of canned responses and set up the test HTML server. 640 // Create map of canned responses and set up the test HTML server.
638 std::map<GURL, std::string> responses; 641 std::map<GURL, std::string> responses;
639 const GURL URL = 642 const GURL URL =
640 web::test::HttpServer::MakeUrl("http://postEntryWithKeyboard"); 643 web::test::HttpServer::MakeUrl("http://postEntryWithKeyboard");
641 const GURL destinationURL = web::test::HttpServer::MakeUrl("http://foo"); 644 const GURL destinationURL = web::test::HttpServer::MakeUrl("http://foo");
642 // This is a page this an input text field and a button that posts to the 645 // This is a page this an input text field and a button that posts to the
643 // destination. 646 // destination.
644 responses[URL] = base::StringPrintf( 647 responses[URL] = base::StringPrintf(
645 "hello!" 648 "hello!"
646 "<form action='%s' method='post'>" 649 "<form action='%s' method='post'>"
647 "<input value='textfield' id='textfield' type='text'></label>" 650 "<input value='textfield' id='textfield' type='text'></label>"
648 "<input type='submit'></form>", 651 "<input type='submit'></form>",
649 destinationURL.spec().c_str()); 652 destinationURL.spec().c_str());
650 // This is the page that should be showing at the end of the test. 653 // This is the page that should be showing at the end of the test.
651 responses[destinationURL] = "baz!"; 654 responses[destinationURL] = "baz!";
652 web::test::SetUpSimpleHttpServer(responses); 655 web::test::SetUpSimpleHttpServer(responses);
653 656
654 // Open the URL, focus the textfield,and submit via keyboard. 657 // Open the URL, focus the textfield,and submit via keyboard.
655 [ChromeEarlGrey loadURL:URL]; 658 [ChromeEarlGrey loadURL:URL];
656 [[EarlGrey selectElementWithMatcher:WebViewContainingText("hello!")] 659 [[EarlGrey selectElementWithMatcher:WebViewContainingText("hello!")]
657 assertWithMatcher:grey_notNil()]; 660 assertWithMatcher:grey_notNil()];
658 661
659 [self openKeyboardAndTapGoButtonWithTextFieldID:"textfield"]; 662 [self submitFormUsingKeyboardGoButtonWithInputID:"textfield"];
660 663
661 // Verify that the browser navigates to the expected URL. 664 // Verify that the browser navigates to the expected URL.
662 [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())] 665 [[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
663 assertWithMatcher:grey_notNil()]; 666 assertWithMatcher:grey_notNil()];
664 667
665 // Go back and verify that the browser navigates to the original URL. 668 // Go back and verify that the browser navigates to the original URL.
666 [self goBack]; 669 [self goBack];
667 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())] 670 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())]
668 assertWithMatcher:grey_notNil()]; 671 assertWithMatcher:grey_notNil()];
669 } 672 }
670 673
671 @end 674 @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