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

Unified Diff: ios/chrome/browser/web/visible_url_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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/web/visible_url_egtest.mm
diff --git a/ios/chrome/browser/web/visible_url_egtest.mm b/ios/chrome/browser/web/visible_url_egtest.mm
index e9050920b1685bffd9878abaed53269609654115..560f644209822aad415ce14354f89493543a28d1 100644
--- a/ios/chrome/browser/web/visible_url_egtest.mm
+++ b/ios/chrome/browser/web/visible_url_egtest.mm
@@ -28,7 +28,7 @@
#error "This file requires ARC support."
#endif
-using chrome_test_util::WebViewContainingText;
+using base::SysUTF8ToNSString;
using chrome_test_util::OmniboxText;
namespace {
@@ -198,8 +198,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
@@ -219,8 +218,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL2 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage2)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage2];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -248,8 +246,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -281,8 +278,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond and verify that page2 was reloaded, not page1.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage2)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage2];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -297,7 +293,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tap the back button on the page and verify that URL2 (committed URL) is
// displayed even though URL1 is a pending URL.
- [ChromeEarlGrey tapWebViewElementWithID:base::SysUTF8ToNSString(kGoBackLink)];
+ [ChromeEarlGrey tapWebViewElementWithID:SysUTF8ToNSString(kGoBackLink)];
Eugene But (OOO till 7-30) 2017/06/12 03:47:11 nit: Is this really necessary? Same question for o
baxley 2017/06/12 16:41:17 Done.
GREYAssert([self waitForServerToReceiveRequestWithURL:_testURL1],
@"Last request URL: %@", self.lastRequestURLSpec);
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
@@ -305,8 +301,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
@@ -317,8 +312,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tap the forward button on the page and verify that URL1 (committed URL)
// is displayed even though URL2 is a pending URL.
- [ChromeEarlGrey
- tapWebViewElementWithID:base::SysUTF8ToNSString(kGoForwardLink)];
+ [ChromeEarlGrey tapWebViewElementWithID:SysUTF8ToNSString(kGoForwardLink)];
GREYAssert([self waitForServerToReceiveRequestWithURL:_testURL2],
@"Last request URL: %@", self.lastRequestURLSpec);
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
@@ -326,8 +320,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL2 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage2)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage2];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -343,7 +336,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tap the go negative delta button on the page and verify that URL2
// (committed URL) is displayed even though URL1 is a pending URL.
[ChromeEarlGrey
- tapWebViewElementWithID:base::SysUTF8ToNSString(kGoNegativeDeltaLink)];
+ tapWebViewElementWithID:SysUTF8ToNSString(kGoNegativeDeltaLink)];
GREYAssert([self waitForServerToReceiveRequestWithURL:_testURL1],
@"Last request URL: %@", self.lastRequestURLSpec);
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
@@ -351,8 +344,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
@@ -364,7 +356,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tap go positive delta button on the page and verify that URL1 (committed
// URL) is displayed even though URL2 is a pending URL.
[ChromeEarlGrey
- tapWebViewElementWithID:base::SysUTF8ToNSString(kGoPositiveDeltaLink)];
+ tapWebViewElementWithID:SysUTF8ToNSString(kGoPositiveDeltaLink)];
GREYAssert([self waitForServerToReceiveRequestWithURL:_testURL2],
@"Last request URL: %@", self.lastRequestURLSpec);
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
@@ -372,8 +364,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL2 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage2)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage2];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -409,8 +400,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -425,7 +415,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
[self setServerPaused:YES];
// Start renderer initiated navigation.
- [ChromeEarlGrey tapWebViewElementWithID:base::SysUTF8ToNSString(kPage3Link)];
+ [ChromeEarlGrey tapWebViewElementWithID:SysUTF8ToNSString(kPage3Link)];
// Do not wait until renderer-initiated navigation is finished, tap the back
// button in the toolbar and verify that URL2 (committed URL) is displayed
@@ -439,8 +429,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -464,14 +453,13 @@ class PausableResponseProvider : public HtmlResponseProvider {
assertWithMatcher:grey_notNil()];
// Interrupt back navigation with renderer initiated navigation.
- [ChromeEarlGrey tapWebViewElementWithID:base::SysUTF8ToNSString(kPage3Link)];
+ [ChromeEarlGrey tapWebViewElementWithID:SysUTF8ToNSString(kPage3Link)];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL2.GetContent())]
assertWithMatcher:grey_notNil()];
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage3)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage3];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL3.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -501,8 +489,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -519,8 +506,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
performAction:grey_tap()];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
// Quickly (using chrome command) navigate forward twice and wait for
// kChromeUIVersionURL to load.
@@ -530,8 +516,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
chrome_test_util::RunCommandWithActiveViewController(forwardCommand);
const std::string version = version_info::GetVersionNumber();
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(version)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:version];
// Make sure that kChromeUIVersionURL URL is displayed in the omnibox.
std::string expectedText = base::UTF16ToUTF8(web::GetDisplayTitleForUrl(URL));
@@ -552,8 +537,8 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Tap the back button twice on the page and verify that URL3 (committed URL)
// is displayed even though URL1 is a pending URL.
- [ChromeEarlGrey tapWebViewElementWithID:base::SysUTF8ToNSString(kGoBackLink)];
- [ChromeEarlGrey tapWebViewElementWithID:base::SysUTF8ToNSString(kGoBackLink)];
+ [ChromeEarlGrey tapWebViewElementWithID:SysUTF8ToNSString(kGoBackLink)];
+ [ChromeEarlGrey tapWebViewElementWithID:SysUTF8ToNSString(kGoBackLink)];
// Server will receive only one request either for |_testURL2| or for
// |_testURL1| depending on load timing and then will pause. So there is no
// need to wait for particular request.
@@ -562,8 +547,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
// Make server respond so URL1 becomes committed.
[self setServerPaused:NO];
- [[EarlGrey selectElementWithMatcher:WebViewContainingText(kTestPage1)]
- assertWithMatcher:grey_notNil()];
+ [ChromeEarlGrey waitForWebViewContainingText:kTestPage1];
[[EarlGrey selectElementWithMatcher:OmniboxText(_testURL1.GetContent())]
assertWithMatcher:grey_notNil()];
}
@@ -572,7 +556,7 @@ class PausableResponseProvider : public HtmlResponseProvider {
#pragma mark Private
- (NSString*)lastRequestURLSpec {
- return base::SysUTF8ToNSString(_responseProvider->last_request_url().spec());
+ return SysUTF8ToNSString(_responseProvider->last_request_url().spec());
}
- (void)setServerPaused:(BOOL)paused {

Powered by Google App Engine
This is Rietveld 408576698