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

Unified Diff: ios/chrome/browser/ui/reading_list/reading_list_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: review comments 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/ui/reading_list/reading_list_egtest.mm
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm b/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm
index 135d8c445aeec3d7a9d0dc7200d6ad4efcc96676..97b6ec12fac7f998bc1b4fcccce64f93964a31dc 100644
--- a/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm
+++ b/ios/chrome/browser/ui/reading_list/reading_list_egtest.mm
@@ -35,6 +35,7 @@
#import "ios/web/public/test/http_server/html_response_provider.h"
#import "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h"
+#import "ios/web/public/test/web_view_content_test_util.h"
#include "net/base/network_change_notifier.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -317,20 +318,17 @@ void AssertIsShowingDistillablePage(bool online) {
NSString* contentToKeep = base::SysUTF8ToNSString(kContentToKeep);
// There will be multiple reloads, wait for the page to be displayed.
if (online) {
- // TODO(crbug.com/707009): Remove use of WebViewContainingText, with a
- // method that is not an EarlGrey matcher.
- id<GREYMatcher> web_view_match = nil;
- web_view_match = chrome_test_util::WebViewContainingText(kContentToKeep);
- ConditionBlock wait_for_loading = ^{
- NSError* error = nil;
- [[EarlGrey selectElementWithMatcher:web_view_match]
- assertWithMatcher:grey_notNil()
- error:&error];
- return error == nil;
- };
- GREYAssert(testing::WaitUntilConditionOrTimeout(kLoadOfflineTimeout,
- wait_for_loading),
- @"Page did not load.");
+ // Due to the reloads, a timeout longer than what is provided in
+ // [ChromeEarlGrey waitForWebViewContainingText] is required, so call
+ // WebViewContainingText directly.
+ GREYAssert(testing::WaitUntilConditionOrTimeout(
+ kLoadOfflineTimeout,
+ ^bool {
+ return web::test::IsWebViewContainingText(
+ chrome_test_util::GetCurrentWebState(),
+ kContentToKeep);
+ }),
+ @"Waiting for online page.");
} else {
[ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep];
}
@@ -341,15 +339,16 @@ void AssertIsShowingDistillablePage(bool online) {
distillableURL.GetContent())]
assertWithMatcher:grey_notNil()];
- // Test presence of online page
- [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
- kContentToKeep)]
- assertWithMatcher:online ? grey_notNil() : grey_nil()];
-
- // Test presence of offline page.
+ // Test that the offline and online pages are properly displayed.
if (online) {
+ [ChromeEarlGrey
+ waitForWebViewContainingText:base::SysNSStringToUTF8(contentToKeep)];
[ChromeEarlGrey waitForStaticHTMLViewNotContainingText:contentToKeep];
} else {
+ // TODO(crbug.com/714157): Remove matcher that asserts grey_nil().
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
+ kContentToKeep)]
+ assertWithMatcher:grey_nil()];
[ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep];
}

Powered by Google App Engine
This is Rietveld 408576698