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

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: more cleanup Created 3 years, 6 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
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 #include <map> 5 #include <map>
6 6
7 #import <EarlGrey/EarlGrey.h> 7 #import <EarlGrey/EarlGrey.h>
8 #import <WebKit/WebKit.h> 8 #import <WebKit/WebKit.h>
9 #import <XCTest/XCTest.h> 9 #import <XCTest/XCTest.h>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const GURL destinationURL = 46 const GURL destinationURL =
47 web::test::HttpServer::MakeUrl("http://destination"); 47 web::test::HttpServer::MakeUrl("http://destination");
48 responses[startURL] = "Start"; 48 responses[startURL] = "Start";
49 responses[destinationURL] = "You've arrived!"; 49 responses[destinationURL] = "You've arrived!";
50 web::test::SetUpSimpleHttpServer(responses); 50 web::test::SetUpSimpleHttpServer(responses);
51 51
52 // Just load the first URL. 52 // Just load the first URL.
53 [ChromeEarlGrey loadURL:startURL]; 53 [ChromeEarlGrey loadURL:startURL];
54 54
55 // Waits for the page to load and check it is the expected content. 55 // Waits for the page to load and check it is the expected content.
56 id<GREYMatcher> responseMatcher = 56 [ChromeEarlGrey waitForWebViewContainingText:responses[startURL]];
57 chrome_test_util::WebViewContainingText(responses[startURL]);
58 [[EarlGrey selectElementWithMatcher:responseMatcher]
59 assertWithMatcher:grey_notNil()];
60 57
61 // In the omnibox, the URL should be present, without the http:// prefix. 58 // In the omnibox, the URL should be present, without the http:// prefix.
62 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] 59 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
63 assertWithMatcher:chrome_test_util::OmniboxText(startURL.GetContent())]; 60 assertWithMatcher:chrome_test_util::OmniboxText(startURL.GetContent())];
64 61
65 // Types some javascript in the omnibox to trigger a navigation. 62 // Types some javascript in the omnibox to trigger a navigation.
66 NSString* script = 63 NSString* script =
67 [NSString stringWithFormat:@"javascript:location.href='%s'\n", 64 [NSString stringWithFormat:@"javascript:location.href='%s'\n",
68 destinationURL.spec().c_str()]; 65 destinationURL.spec().c_str()];
69 66
70 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] 67 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
71 performAction:grey_typeText(script)]; 68 performAction:grey_typeText(script)];
72 69
73 // In the omnibox, the new URL should be present, without the http:// prefix. 70 // In the omnibox, the new URL should be present, without the http:// prefix.
74 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] 71 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
75 assertWithMatcher:chrome_test_util::OmniboxText( 72 assertWithMatcher:chrome_test_util::OmniboxText(
76 destinationURL.GetContent())]; 73 destinationURL.GetContent())];
77 74
78 // Verifies that the navigation to the destination page happened. 75 // Verifies that the navigation to the destination page happened.
79 GREYAssertEqual(destinationURL, 76 GREYAssertEqual(destinationURL,
80 chrome_test_util::GetCurrentWebState()->GetVisibleURL(), 77 chrome_test_util::GetCurrentWebState()->GetVisibleURL(),
81 @"Did not navigate to the destination url."); 78 @"Did not navigate to the destination url.");
82 79
83 // Verifies that the destination page is shown. 80 // Verifies that the destination page is shown.
84 id<GREYMatcher> navigationMatcher = 81 [ChromeEarlGrey waitForWebViewContainingText:responses[destinationURL]];
85 chrome_test_util::WebViewContainingText(responses[destinationURL]);
86 [[EarlGrey selectElementWithMatcher:grey_kindOfClass([WKWebView class])]
87 assertWithMatcher:navigationMatcher];
88 } 82 }
89 83
90 @end 84 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698