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

Side by Side Diff: ios/chrome/browser/ui/reading_list/reading_list_egtest.mm

Issue 2784943002: Remove matcher to wait for static HTML view. (Closed)
Patch Set: typo 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 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 #import <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <UIKit/UIKit.h> 6 #import <UIKit/UIKit.h>
7 #import <XCTest/XCTest.h> 7 #import <XCTest/XCTest.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 "</article>" + content_to_remove * 20 + "</html>"; 286 "</article>" + content_to_remove * 20 + "</html>";
287 const GURL non_distillable_page_url = 287 const GURL non_distillable_page_url =
288 web::test::HttpServer::MakeUrl(kNonDistillableURL); 288 web::test::HttpServer::MakeUrl(kNonDistillableURL);
289 responses[non_distillable_page_url] = 289 responses[non_distillable_page_url] =
290 "<html><head><title>greens</title></head></html>"; 290 "<html><head><title>greens</title></head></html>";
291 return responses; 291 return responses;
292 } 292 }
293 293
294 // Tests that the correct version of kDistillableURL is displayed. 294 // Tests that the correct version of kDistillableURL is displayed.
295 void AssertIsShowingDistillablePage(bool online) { 295 void AssertIsShowingDistillablePage(bool online) {
296 // There will be multiple reload. Wait. 296 NSString* contentToKeep = base::SysUTF8ToNSString(kContentToKeep);
297 id<GREYMatcher> web_view_match = nil; 297 // There will be multiple reloads, wait for the page to be displayed.
298 if (online) { 298 if (online) {
299 // TODO(crbug.com/707009): Remove use of WebViewContainingText, with a
300 // method that is not an EarlGrey matcher.
301 id<GREYMatcher> web_view_match = nil;
299 web_view_match = chrome_test_util::WebViewContainingText(kContentToKeep); 302 web_view_match = chrome_test_util::WebViewContainingText(kContentToKeep);
303 ConditionBlock wait_for_loading = ^{
304 NSError* error = nil;
305 [[EarlGrey selectElementWithMatcher:web_view_match]
306 assertWithMatcher:grey_notNil()
307 error:&error];
308 return error == nil;
309 };
310 GREYAssert(testing::WaitUntilConditionOrTimeout(kLoadOfflineTimeout,
311 wait_for_loading),
312 @"Page did not load.");
300 } else { 313 } else {
301 web_view_match = chrome_test_util::StaticHtmlViewContainingText( 314 [ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep];
302 base::SysUTF8ToNSString(kContentToKeep));
303 } 315 }
304 ConditionBlock wait_for_loading = ^{
305 NSError* error = nil;
306 [[EarlGrey selectElementWithMatcher:web_view_match]
307 assertWithMatcher:grey_notNil()
308 error:&error];
309 return error == nil;
310 };
311 GREYAssert(testing::WaitUntilConditionOrTimeout(kLoadOfflineTimeout,
312 wait_for_loading),
313 @"Page did not load.");
314 316
315 // Test Omnibox URL 317 // Test Omnibox URL
316 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 318 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
317 "localhost:8080/potato/")] 319 "localhost:8080/potato/")]
318 assertWithMatcher:grey_notNil()]; 320 assertWithMatcher:grey_notNil()];
319 321
320 // Test presence of online page 322 // Test presence of online page
321 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 323 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
322 kContentToKeep)] 324 kContentToKeep)]
323 assertWithMatcher:online ? grey_notNil() : grey_nil()]; 325 assertWithMatcher:online ? grey_notNil() : grey_nil()];
324 326
325 // Test presence of offline page 327 // Test presence of offline page.
326 [[EarlGrey 328 if (online) {
327 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText( 329 [ChromeEarlGrey waitForStaticHTMLViewNotContainingText:contentToKeep];
328 base::SysUTF8ToNSString(kContentToKeep))] 330 } else {
329 assertWithMatcher:online ? grey_nil() : grey_notNil()]; 331 [ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep];
332 }
330 333
331 // Test the presence of the omnibox offline chip. 334 // Test the presence of the omnibox offline chip.
332 [[EarlGrey 335 [[EarlGrey
333 selectElementWithMatcher:grey_allOf( 336 selectElementWithMatcher:grey_allOf(
334 chrome_test_util::PageSecurityInfoButton(), 337 chrome_test_util::PageSecurityInfoButton(),
335 chrome_test_util::ButtonWithImage( 338 chrome_test_util::ButtonWithImage(
336 IDR_IOS_OMNIBOX_OFFLINE), 339 IDR_IOS_OMNIBOX_OFFLINE),
337 nil)] 340 nil)]
338 assertWithMatcher:online ? grey_nil() : grey_notNil()]; 341 assertWithMatcher:online ? grey_nil() : grey_notNil()];
339 } 342 }
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 assertWithMatcher:grey_nil()]; 748 assertWithMatcher:grey_nil()];
746 TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON); 749 TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
747 TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON); 750 TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
748 751
749 // Verify the background string is displayed. 752 // Verify the background string is displayed.
750 [[EarlGrey selectElementWithMatcher:EmptyBackground()] 753 [[EarlGrey selectElementWithMatcher:EmptyBackground()]
751 assertWithMatcher:grey_notNil()]; 754 assertWithMatcher:grey_notNil()];
752 } 755 }
753 756
754 @end 757 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698