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

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

Issue 2626143002: Add more criteria to wait until keyboard appears. (Closed)
Patch Set: abstract matcher to method Created 3 years, 11 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 @implementation BrowsingTestCase 122 @implementation BrowsingTestCase
123 123
124 // Matcher for the title of the current tab (on tablet only). 124 // Matcher for the title of the current tab (on tablet only).
125 id<GREYMatcher> tabWithTitle(const std::string& tab_title) { 125 id<GREYMatcher> tabWithTitle(const std::string& tab_title) {
126 id<GREYMatcher> notPartOfOmnibox = 126 id<GREYMatcher> notPartOfOmnibox =
127 grey_not(grey_ancestor(chrome_test_util::omnibox())); 127 grey_not(grey_ancestor(chrome_test_util::omnibox()));
128 return grey_allOf(grey_accessibilityLabel(base::SysUTF8ToNSString(tab_title)), 128 return grey_allOf(grey_accessibilityLabel(base::SysUTF8ToNSString(tab_title)),
129 notPartOfOmnibox, nil); 129 notPartOfOmnibox, nil);
130 } 130 }
131 131
132 // Matcher for a Go button that is interactable.
133 id<GREYMatcher> goButtonMatcher() {
134 return grey_allOf(grey_accessibilityID(@"Go"), grey_interactable(), nil);
135 }
136
132 // Tests that page successfully reloads. 137 // Tests that page successfully reloads.
133 - (void)testReload { 138 - (void)testReload {
134 // Set up test HTTP server responses. 139 // Set up test HTTP server responses.
135 std::unique_ptr<web::DataResponseProvider> provider( 140 std::unique_ptr<web::DataResponseProvider> provider(
136 new ReloadResponseProvider()); 141 new ReloadResponseProvider());
137 web::test::SetUpHttpServer(std::move(provider)); 142 web::test::SetUpHttpServer(std::move(provider));
138 143
139 GURL URL = ReloadResponseProvider::GetReloadTestUrl(); 144 GURL URL = ReloadResponseProvider::GetReloadTestUrl();
140 [ChromeEarlGrey loadURL:URL]; 145 [ChromeEarlGrey loadURL:URL];
141 std::string expectedBodyBeforeReload( 146 std::string expectedBodyBeforeReload(
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // keyboard from a web view. 619 // keyboard from a web view.
615 [[GREYConfiguration sharedInstance] 620 [[GREYConfiguration sharedInstance]
616 setValue:@NO 621 setValue:@NO
617 forConfigKey:kGREYConfigKeySynchronizationEnabled]; 622 forConfigKey:kGREYConfigKeySynchronizationEnabled];
618 623
619 // Wait until the keyboard shows up before tapping. 624 // Wait until the keyboard shows up before tapping.
620 GREYCondition* condition = [GREYCondition 625 GREYCondition* condition = [GREYCondition
621 conditionWithName:@"Wait for the keyboard to show up." 626 conditionWithName:@"Wait for the keyboard to show up."
622 block:^BOOL { 627 block:^BOOL {
623 NSError* error = nil; 628 NSError* error = nil;
624 [[EarlGrey 629 [[EarlGrey selectElementWithMatcher:goButtonMatcher()]
625 selectElementWithMatcher:grey_accessibilityID(@"Go")]
626 assertWithMatcher:grey_notNil() 630 assertWithMatcher:grey_notNil()
627 error:&error]; 631 error:&error];
628 return (error == nil); 632 return (error == nil);
629 }]; 633 }];
630 GREYAssert([condition waitWithTimeout:10], 634 GREYAssert([condition waitWithTimeout:10],
631 @"No keyboard with 'Go' button showed up."); 635 @"No keyboard with 'Go' button showed up.");
632 636
633 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")] 637 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")]
634 performAction:grey_tap()]; 638 performAction:grey_tap()];
635 639
636 // Reenable synchronization now that the keyboard has been closed. 640 // Reenable synchronization now that the keyboard has been closed.
637 [[GREYConfiguration sharedInstance] 641 [[GREYConfiguration sharedInstance]
638 setValue:@YES 642 setValue:@YES
639 forConfigKey:kGREYConfigKeySynchronizationEnabled]; 643 forConfigKey:kGREYConfigKeySynchronizationEnabled];
640 644
641 // Verify that the browser navigates to the expected URL. 645 // Verify that the browser navigates to the expected URL.
642 [[EarlGrey selectElementWithMatcher:omniboxText(destinationURL.GetContent())] 646 [[EarlGrey selectElementWithMatcher:omniboxText(destinationURL.GetContent())]
643 assertWithMatcher:grey_notNil()]; 647 assertWithMatcher:grey_notNil()];
644 648
645 // Go back and verify that the browser navigates to the original URL. 649 // Go back and verify that the browser navigates to the original URL.
646 [self goBack]; 650 [self goBack];
647 [[EarlGrey selectElementWithMatcher:omniboxText(URL.GetContent())] 651 [[EarlGrey selectElementWithMatcher:omniboxText(URL.GetContent())]
648 assertWithMatcher:grey_notNil()]; 652 assertWithMatcher:grey_notNil()];
649 } 653 }
650 654
651 @end 655 @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