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

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

Issue 2762113002: Reading List iOS: Adapt loading offline for new reload process (Closed)
Patch Set: update comment Created 3 years, 9 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/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/ios/wait_util.h"
11 #include "components/reading_list/ios/reading_list_model.h" 13 #include "components/reading_list/ios/reading_list_model.h"
12 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" 14 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
13 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 15 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
14 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 16 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
15 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.h" 17 #import "ios/chrome/browser/ui/reading_list/reading_list_collection_view_item.h"
16 #import "ios/chrome/browser/ui/reading_list/reading_list_empty_collection_backgr ound.h" 18 #import "ios/chrome/browser/ui/reading_list/reading_list_empty_collection_backgr ound.h"
17 #include "ios/chrome/browser/ui/ui_util.h" 19 #include "ios/chrome/browser/ui/ui_util.h"
18 #include "ios/chrome/grit/ios_strings.h" 20 #include "ios/chrome/grit/ios_strings.h"
19 #include "ios/chrome/grit/ios_theme_resources.h" 21 #include "ios/chrome/grit/ios_theme_resources.h"
20 #import "ios/chrome/test/app/chrome_test_util.h" 22 #import "ios/chrome/test/app/chrome_test_util.h"
23 #include "ios/chrome/test/app/navigation_test_util.h"
24 #import "ios/chrome/test/app/tab_test_util.h"
21 #import "ios/chrome/test/earl_grey/accessibility_util.h" 25 #import "ios/chrome/test/earl_grey/accessibility_util.h"
22 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" 26 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
23 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" 27 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
24 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 28 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
25 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 29 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
26 #import "ios/testing/wait_util.h" 30 #import "ios/testing/wait_util.h"
27 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 31 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
32 #import "ios/web/public/navigation_manager.h"
33 #import "ios/web/public/reload_type.h"
28 #import "ios/web/public/test/http_server.h" 34 #import "ios/web/public/test/http_server.h"
29 #import "ios/web/public/test/http_server_util.h" 35 #import "ios/web/public/test/http_server_util.h"
36 #import "ios/web/public/test/response_providers/delayed_response_provider.h"
37 #import "ios/web/public/test/response_providers/html_response_provider.h"
30 38
31 #if !defined(__has_feature) || !__has_feature(objc_arc) 39 #if !defined(__has_feature) || !__has_feature(objc_arc)
32 #error "This file requires ARC support." 40 #error "This file requires ARC support."
33 #endif 41 #endif
34 42
35 namespace { 43 namespace {
44 const char kContentToRemove[] = "Text that distillation should remove.";
45 const char kContentToKeep[] = "Text that distillation should keep.";
46 const char kDistillableTitle[] = "Tomato";
47 const char kDistillableURL[] = "http://potato";
48 const char kNonDistillableURL[] = "http://beans";
36 const char kReadTitle[] = "foobar"; 49 const char kReadTitle[] = "foobar";
37 const char kReadURL[] = "http://readfoobar.com"; 50 const char kReadURL[] = "http://readfoobar.com";
38 const char kUnreadTitle[] = "I am an unread entry"; 51 const char kUnreadTitle[] = "I am an unread entry";
39 const char kUnreadURL[] = "http://unreadfoobar.com"; 52 const char kUnreadURL[] = "http://unreadfoobar.com";
40 const char kReadURL2[] = "http://kReadURL2.com"; 53 const char kReadURL2[] = "http://kReadURL2.com";
41 const char kReadTitle2[] = "read item 2"; 54 const char kReadTitle2[] = "read item 2";
42 const char kUnreadTitle2[] = "I am another unread entry"; 55 const char kUnreadTitle2[] = "I am another unread entry";
43 const char kUnreadURL2[] = "http://unreadfoobar2.com"; 56 const char kUnreadURL2[] = "http://unreadfoobar2.com";
44 const size_t kNumberReadEntries = 2; 57 const size_t kNumberReadEntries = 2;
45 const size_t kNumberUnreadEntries = 2; 58 const size_t kNumberUnreadEntries = 2;
46 const CFTimeInterval kSnackbarAppearanceTimeout = 5; 59 const CFTimeInterval kSnackbarAppearanceTimeout = 5;
47 const CFTimeInterval kSnackbarDisappearanceTimeout = 60 const CFTimeInterval kSnackbarDisappearanceTimeout =
48 MDCSnackbarMessageDurationMax + 1; 61 MDCSnackbarMessageDurationMax + 1;
62 const CFTimeInterval kLoadOfflineTimeout = 5;
49 const CFTimeInterval kLongPressDuration = 1.0; 63 const CFTimeInterval kLongPressDuration = 1.0;
50 const char kReadHeader[] = "Read"; 64 const char kReadHeader[] = "Read";
51 const char kUnreadHeader[] = "Unread"; 65 const char kUnreadHeader[] = "Unread";
52 66
53 // Returns the string concatenated |n| times. 67 // Returns the string concatenated |n| times.
54 std::string operator*(const std::string& s, unsigned int n) { 68 std::string operator*(const std::string& s, unsigned int n) {
55 std::ostringstream out; 69 std::ostringstream out;
56 for (unsigned int i = 0; i < n; i++) 70 for (unsigned int i = 0; i < n; i++)
57 out << s; 71 out << s;
58 return out.str(); 72 return out.str();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 208 }
195 } 209 }
196 return size; 210 return size;
197 } 211 }
198 212
199 // Returns a match for the Reading List Empty Collection Background. 213 // Returns a match for the Reading List Empty Collection Background.
200 id<GREYMatcher> EmptyBackground() { 214 id<GREYMatcher> EmptyBackground() {
201 return grey_accessibilityID( 215 return grey_accessibilityID(
202 [ReadingListEmptyCollectionBackground accessibilityIdentifier]); 216 [ReadingListEmptyCollectionBackground accessibilityIdentifier]);
203 } 217 }
204 } // namespace
205 218
206 // Test class for the Reading List menu. 219 // Adds an the current page to the Reading List.
jif 2017/03/21 17:09:50 s/an //
Olivier 2017/03/21 17:44:24 Done.
207 @interface ReadingListTestCase : ChromeTestCase 220 void AddCurrentPageToReadingList() {
208
209 @end
210
211 @implementation ReadingListTestCase
212
213 - (void)setUp {
214 [super setUp];
215 ReadingListModel* model = GetReadingListModel();
216 for (const GURL& url : model->Keys())
217 model->RemoveEntryByURL(url);
218 }
219
220 // Tests that the Reading List view is accessible.
221 - (void)testAccessibility {
222 AddEntriesAndEnterEdit();
223 // In edit mode.
224 chrome_test_util::VerifyAccessibilityForCurrentScreen();
225 TapButtonWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
226 chrome_test_util::VerifyAccessibilityForCurrentScreen();
227 }
228
229 // Tests that sharing a web page to the Reading List results in a snackbar
230 // appearing, and that the Reading List entry is present in the Reading List.
231 - (void)testSavingToReadingList {
232 // Setup a server serving a distillable page at http://potato with the title
233 // "tomato", and a non distillable page at http://beans
234 std::map<GURL, std::string> responses;
235 const GURL distillablePageURL =
236 web::test::HttpServer::MakeUrl("http://potato");
237 std::string pageTitle = "tomato";
238
239 std::string contentToRemove = "Text that distillation should remove.";
240 std::string contentToKeep = "Text that distillation should keep.";
241 // Distillation only occurs on pages that are not too small.
242 responses[distillablePageURL] =
243 "<html><head><title>" + pageTitle + "</title></head>" +
244 contentToRemove * 20 + "<article>" + contentToKeep * 20 + "</article>" +
245 contentToRemove * 20 + "</html>";
246 const GURL nonDistillablePageURL =
247 web::test::HttpServer::MakeUrl("http://beans");
248 responses[nonDistillablePageURL] =
249 "<html><head><title>greens</title></head></html>";
250
251 web::test::SetUpSimpleHttpServer(responses);
252
253 // Open http://potato
254 [ChromeEarlGrey loadURL:distillablePageURL];
255
256 // Add the page to the reading list. 221 // Add the page to the reading list.
257 [ChromeEarlGreyUI openShareMenu]; 222 [ChromeEarlGreyUI openShareMenu];
258 TapButtonWithID(IDS_IOS_SHARE_MENU_READING_LIST_ACTION); 223 TapButtonWithID(IDS_IOS_SHARE_MENU_READING_LIST_ACTION);
259 224
260 // Wait for the snackbar to appear. 225 // Wait for the snackbar to appear.
261 id<GREYMatcher> snackbarMatcher = 226 id<GREYMatcher> snackbarMatcher =
262 chrome_test_util::ButtonWithAccessibilityLabelId( 227 chrome_test_util::ButtonWithAccessibilityLabelId(
263 IDS_IOS_READING_LIST_SNACKBAR_MESSAGE); 228 IDS_IOS_READING_LIST_SNACKBAR_MESSAGE);
264 ConditionBlock waitForAppearance = ^{ 229 ConditionBlock waitForAppearance = ^{
265 NSError* error = nil; 230 NSError* error = nil;
(...skipping 10 matching lines...) Expand all
276 ConditionBlock waitForDisappearance = ^{ 241 ConditionBlock waitForDisappearance = ^{
277 NSError* error = nil; 242 NSError* error = nil;
278 [[EarlGrey selectElementWithMatcher:snackbarMatcher] 243 [[EarlGrey selectElementWithMatcher:snackbarMatcher]
279 assertWithMatcher:grey_nil() 244 assertWithMatcher:grey_nil()
280 error:&error]; 245 error:&error];
281 return error == nil; 246 return error == nil;
282 }; 247 };
283 GREYAssert(testing::WaitUntilConditionOrTimeout(kSnackbarDisappearanceTimeout, 248 GREYAssert(testing::WaitUntilConditionOrTimeout(kSnackbarDisappearanceTimeout,
284 waitForDisappearance), 249 waitForDisappearance),
285 @"Snackbar did not disappear."); 250 @"Snackbar did not disappear.");
251 }
252
253 // Returns the responses for a web server that can serve a distillable content
254 // at kDistillableURL and a not distillable content at kNotDistillableURL.
255 std::map<GURL, std::string> ResponsesForDistillationServer() {
256 // Setup a server serving a distillable page at http://potato with the title
257 // "tomato", and a non distillable page at http://beans
258 std::map<GURL, std::string> responses;
259 std::string pageTitle = "Tomato";
Eugene But (OOO till 7-30) 2017/03/21 17:10:24 s/pageTitle/page_title Same comment for other var
Olivier 2017/03/21 17:44:24 Done.
260 const GURL distillablePageURL =
261 web::test::HttpServer::MakeUrl(kDistillableURL);
262
263 std::string contentToRemove(kContentToRemove);
264 std::string contentToKeep(kContentToKeep);
265 // Distillation only occurs on pages that are not too small.
266 responses[distillablePageURL] =
267 "<html><head><title>" + pageTitle + "</title></head>" +
268 contentToRemove * 20 + "<article>" + contentToKeep * 20 + "</article>" +
269 contentToRemove * 20 + "</html>";
270 const GURL nonDistillablePageURL =
271 web::test::HttpServer::MakeUrl(kNonDistillableURL);
272 responses[nonDistillablePageURL] =
273 "<html><head><title>greens</title></head></html>";
274 return responses;
275 }
276
277 // Test that the correct version of kDistillableURL is displayed.
Eugene But (OOO till 7-30) 2017/03/21 17:10:24 s/Test/Tests
Olivier 2017/03/21 17:44:23 Done.
278 void AssertIsShowingDistillablePage(bool online) {
279 // There will be multiple reload. Wait.
280 id<GREYMatcher> webViewMatch = nil;
281 if (online) {
282 webViewMatch = chrome_test_util::WebViewContainingText(kContentToKeep);
283 } else {
284 webViewMatch = chrome_test_util::StaticHtmlViewContainingText(
285 base::SysUTF8ToNSString(kContentToKeep));
286 }
287 ConditionBlock waitForLoading = ^{
288 NSError* error = nil;
289 [[EarlGrey selectElementWithMatcher:webViewMatch]
290 assertWithMatcher:grey_notNil()
291 error:&error];
292 return error == nil;
293 };
294 GREYAssert(
295 testing::WaitUntilConditionOrTimeout(kLoadOfflineTimeout, waitForLoading),
296 @"Page did not load.");
297
298 // Test Omnibox URL
299 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
300 "localhost:8080/potato/")]
301 assertWithMatcher:grey_notNil()];
302
303 // Test presence of online page
304 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
jif 2017/03/21 17:09:50 line 303-312 sort of duplicate the lines 281-293
Olivier 2017/03/21 17:44:24 For the one that is present, yes, for the other on
305 kContentToKeep)]
306 assertWithMatcher:online ? grey_notNil() : grey_nil()];
307
308 // Test presence of offline page
309 [[EarlGrey
310 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText(
311 base::SysUTF8ToNSString(kContentToKeep))]
312 assertWithMatcher:online ? grey_nil() : grey_notNil()];
313
314 // Test the presence of the omnibox offline chip.
315 [[EarlGrey
316 selectElementWithMatcher:grey_allOf(
317 chrome_test_util::PageSecurityInfoButton(),
318 chrome_test_util::ButtonWithImage(
319 IDR_IOS_OMNIBOX_OFFLINE),
jif 2017/03/21 17:09:50 test that the image is IDR_IOS_OMNIBOX_HTTP when o
Olivier 2017/03/21 17:44:23 The image is not displayed.
320 nil)]
321 assertWithMatcher:online ? grey_nil() : grey_notNil()];
322 }
323
324 } // namespace
325
326 // Test class for the Reading List menu.
327 @interface ReadingListTestCase : ChromeTestCase
328
329 @end
330
331 @implementation ReadingListTestCase
332
333 - (void)setUp {
334 [super setUp];
335 ReadingListModel* model = GetReadingListModel();
336 for (const GURL& url : model->Keys())
337 model->RemoveEntryByURL(url);
338 }
339
340 - (void)tearDown {
341 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
342 if (!server.IsRunning()) {
343 server.StartOrDie();
344 }
345 [super tearDown];
346 }
347
348 // Tests that the Reading List view is accessible.
349 - (void)testAccessibility {
350 AddEntriesAndEnterEdit();
351 // In edit mode.
352 chrome_test_util::VerifyAccessibilityForCurrentScreen();
353 TapButtonWithID(IDS_IOS_READING_LIST_CANCEL_BUTTON);
354 chrome_test_util::VerifyAccessibilityForCurrentScreen();
355 }
356
357 // Tests that sharing a web page to the Reading List results in a snackbar
358 // appearing, and that the Reading List entry is present in the Reading List.
359 // Loads offline version via context menu.
360 - (void)testSavingToReadingListAndLoadDistilled {
361 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
362 GURL distillablePageURL(web::test::HttpServer::MakeUrl(kDistillableURL));
363 GURL nonDistillablePageURL(
364 web::test::HttpServer::MakeUrl(kNonDistillableURL));
365 std::string pageTitle(kDistillableTitle);
366 // Open http://potato
367 [ChromeEarlGrey loadURL:distillablePageURL];
368
369 AddCurrentPageToReadingList();
286 370
287 // Navigate to http://beans 371 // Navigate to http://beans
288 [ChromeEarlGrey loadURL:nonDistillablePageURL]; 372 [ChromeEarlGrey loadURL:nonDistillablePageURL];
289 [ChromeEarlGrey waitForPageToFinishLoading]; 373 [ChromeEarlGrey waitForPageToFinishLoading];
290 374
291 // Verify that an entry with the correct title is present in the reading list. 375 // Verify that an entry with the correct title is present in the reading list.
292 OpenReadingList(); 376 OpenReadingList();
293 AssertEntryVisible(pageTitle); 377 AssertEntryVisible(pageTitle);
294 378
295 // Long press the entry, and open it offline. 379 // Long press the entry, and open it offline.
296 LongPressEntry(pageTitle); 380 LongPressEntry(pageTitle);
297 TapButtonWithID(IDS_IOS_READING_LIST_CONTENT_CONTEXT_OFFLINE); 381 TapButtonWithID(IDS_IOS_READING_LIST_CONTENT_CONTEXT_OFFLINE);
298 382 AssertIsShowingDistillablePage(false);
299 // Verify that the correct distilled content is shown.
300 [[EarlGrey
301 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText(
302 base::SysUTF8ToNSString(
303 contentToKeep.c_str()))]
304 assertWithMatcher:grey_notNil()];
305 [[EarlGrey
306 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText(
307 base::SysUTF8ToNSString(
308 contentToRemove.c_str()))]
309 assertWithMatcher:grey_nil()];
310
311 // Verify that the Omnibox' Info Bubble uses the offline icon.
312 [[EarlGrey
313 selectElementWithMatcher:chrome_test_util::PageSecurityInfoButton()]
314 assertWithMatcher:chrome_test_util::ButtonWithImage(
315 IDR_IOS_OMNIBOX_OFFLINE)];
316 383
317 // Tap the Omnibox' Info Bubble to open the Page Info. 384 // Tap the Omnibox' Info Bubble to open the Page Info.
318 [[EarlGrey 385 [[EarlGrey
319 selectElementWithMatcher:chrome_test_util::PageSecurityInfoButton()] 386 selectElementWithMatcher:chrome_test_util::PageSecurityInfoButton()]
320 performAction:grey_tap()]; 387 performAction:grey_tap()];
321
322 // Verify that the Page Info is about offline pages. 388 // Verify that the Page Info is about offline pages.
323 id<GREYMatcher> pageInfoTitleMatcher = 389 id<GREYMatcher> pageInfoTitleMatcher =
324 chrome_test_util::StaticTextWithAccessibilityLabelId( 390 chrome_test_util::StaticTextWithAccessibilityLabelId(
325 IDS_IOS_PAGE_INFO_OFFLINE_TITLE); 391 IDS_IOS_PAGE_INFO_OFFLINE_TITLE);
326 [[EarlGrey selectElementWithMatcher:pageInfoTitleMatcher] 392 [[EarlGrey selectElementWithMatcher:pageInfoTitleMatcher]
327 assertWithMatcher:grey_notNil()]; 393 assertWithMatcher:grey_notNil()];
328 394
329 // Verify that the webState's title is correct. 395 // Verify that the webState's title is correct.
330 XCTAssertTrue(chrome_test_util::GetCurrentWebState()->GetTitle() == 396 XCTAssertTrue(chrome_test_util::GetCurrentWebState()->GetTitle() ==
331 base::ASCIIToUTF16(pageTitle.c_str())); 397 base::ASCIIToUTF16(pageTitle.c_str()));
332 } 398 }
333 399
400 // Tests that sharing a web page to the Reading List results in a snackbar
401 // appearing, and that the Reading List entry is present in the Reading List.
402 // Loads online version by tapping on entry.
403 - (void)testSavingToReadingListAndLoadNormal {
404 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
405 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
406 std::string pageTitle(kDistillableTitle);
407
408 // Open http://potato
409 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)];
410
411 AddCurrentPageToReadingList();
412
413 // Navigate to http://beans
414 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)];
415 [ChromeEarlGrey waitForPageToFinishLoading];
416
417 // Verify that an entry with the correct title is present in the reading list.
418 OpenReadingList();
419 AssertEntryVisible(pageTitle);
420 // Long press the entry, and open it offline.
421 TapEntry(pageTitle);
422
423 AssertIsShowingDistillablePage(true);
424 // Stop server to reload offline.
425 server.Stop();
426
427 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload(
428 web::ReloadType::NORMAL, false);
429 AssertIsShowingDistillablePage(false);
430 }
431
432 // Tests that sharing a web page to the Reading List results in a snackbar
433 // appearing, and that the Reading List entry is present in the Reading List.
434 // Loads offline version by tapping on entry without web server.
435 - (void)testSavingToReadingListAndLoadNoNetwork {
436 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
437 std::string pageTitle(kDistillableTitle);
438 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
439 // Open http://potato
440 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)];
441
442 AddCurrentPageToReadingList();
443
444 // Navigate to http://beans
445 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)];
446 [ChromeEarlGrey waitForPageToFinishLoading];
447
448 // Stop server to generate error.
449 server.Stop();
450
451 // Verify that an entry with the correct title is present in the reading list.
452 OpenReadingList();
453 AssertEntryVisible(pageTitle);
454 // Long press the entry, and open it offline.
455 TapEntry(pageTitle);
456
457 AssertIsShowingDistillablePage(false);
458 // Start server to reload online error.
459 server.StartOrDie();
460 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
461
462 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload(
463 web::ReloadType::NORMAL, false);
464 AssertIsShowingDistillablePage(true);
465 }
466
467 // Tests that sharing a web page to the Reading List results in a snackbar
468 // appearing, and that the Reading List entry is present in the Reading List.
469 // Loads offline version by tapping on entry with delayed web server.
470 - (void)testSavingToReadingListAndLoadBadNetwork {
471 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
472 std::string pageTitle(kDistillableTitle);
473 // Open http://potato
474 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)];
475
476 AddCurrentPageToReadingList();
477
478 // Navigate to http://beans
479 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)];
480 [ChromeEarlGrey waitForPageToFinishLoading];
481
482 web::test::SetUpHttpServer(base::MakeUnique<web::DelayedResponseProvider>(
483 base::MakeUnique<HtmlResponseProvider>(ResponsesForDistillationServer()),
484 5));
485
486 // Verify that an entry with the correct title is present in the reading list.
487 OpenReadingList();
488 AssertEntryVisible(pageTitle);
489 // Long press the entry, and open it offline.
490 TapEntry(pageTitle);
491
492 AssertIsShowingDistillablePage(false);
493 // Reload should load online page.
494 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload(
495 web::ReloadType::NORMAL, false);
496 AssertIsShowingDistillablePage(true);
497 // Reload should load offline page.
498 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload(
499 web::ReloadType::NORMAL, false);
500 AssertIsShowingDistillablePage(false);
501 }
502
334 // Tests that only the "Edit" button is showing when not editing. 503 // Tests that only the "Edit" button is showing when not editing.
335 - (void)testVisibleButtonsNonEditingMode { 504 - (void)testVisibleButtonsNonEditingMode {
336 GetReadingListModel()->AddEntry(GURL(kUnreadURL), std::string(kUnreadTitle), 505 GetReadingListModel()->AddEntry(GURL(kUnreadURL), std::string(kUnreadTitle),
337 reading_list::ADDED_VIA_CURRENT_APP); 506 reading_list::ADDED_VIA_CURRENT_APP);
338 OpenReadingList(); 507 OpenReadingList();
339 508
340 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON); 509 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_BUTTON);
341 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON); 510 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
342 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON); 511 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_READ_BUTTON);
343 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON); 512 AssertButtonNotVisibleWithID(IDS_IOS_READING_LIST_MARK_UNREAD_BUTTON);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 assertWithMatcher:grey_nil()]; 722 assertWithMatcher:grey_nil()];
554 TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON); 723 TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
555 TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON); 724 TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
556 725
557 // Verify the background string is displayed. 726 // Verify the background string is displayed.
558 [[EarlGrey selectElementWithMatcher:EmptyBackground()] 727 [[EarlGrey selectElementWithMatcher:EmptyBackground()]
559 assertWithMatcher:grey_notNil()]; 728 assertWithMatcher:grey_notNil()];
560 } 729 }
561 730
562 @end 731 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698