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

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

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: better formatting 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 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 e37e6cd19b6fe2588fd43d94cd7379046fed6604..1e687684d9dfafacfec4e62aa2c11c0eceec7e67 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_util.h"
#import "ios/web/public/test/response_providers/delayed_response_provider.h"
#import "ios/web/public/test/response_providers/html_response_provider.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,14 @@ 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.");
+ GREYAssert(testing::WaitUntilConditionOrTimeout(
+ kLoadOfflineTimeout,
+ ^bool {
+ return web::test::WebViewContainingText(
+ chrome_test_util::GetCurrentWebState(),
+ kContentToKeep);
+ }),
+ @"Waiting for online page.");
} else {
[ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep];
}
@@ -340,15 +335,15 @@ void AssertIsShowingDistillablePage(bool online) {
"localhost:8080/potato/")]
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: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