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

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

Issue 2931453002: Re-enable reading list tests (Closed)
Patch Set: nit 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 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return error == nil; 329 return error == nil;
330 }; 330 };
331 GREYAssert(testing::WaitUntilConditionOrTimeout(kLoadOfflineTimeout, 331 GREYAssert(testing::WaitUntilConditionOrTimeout(kLoadOfflineTimeout,
332 wait_for_loading), 332 wait_for_loading),
333 @"Page did not load."); 333 @"Page did not load.");
334 } else { 334 } else {
335 [ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep]; 335 [ChromeEarlGrey waitForStaticHTMLViewContainingText:contentToKeep];
336 } 336 }
337 337
338 // Test Omnibox URL 338 // Test Omnibox URL
339 GURL distillableURL = web::test::HttpServer::MakeUrl(kDistillableURL);
339 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 340 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
340 web::test::HttpServer::MakeUrl( 341 distillableURL.GetContent())]
341 kDistillableURL)
342 .GetContent())]
343 assertWithMatcher:grey_notNil()]; 342 assertWithMatcher:grey_notNil()];
344 343
345 // Test presence of online page 344 // Test presence of online page
346 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 345 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
347 kContentToKeep)] 346 kContentToKeep)]
348 assertWithMatcher:online ? grey_notNil() : grey_nil()]; 347 assertWithMatcher:online ? grey_notNil() : grey_nil()];
349 348
350 // Test presence of offline page. 349 // Test presence of offline page.
351 if (online) { 350 if (online) {
352 [ChromeEarlGrey waitForStaticHTMLViewNotContainingText:contentToKeep]; 351 [ChromeEarlGrey waitForStaticHTMLViewNotContainingText:contentToKeep];
(...skipping 22 matching lines...) Expand all
375 374
376 - (void)setUp { 375 - (void)setUp {
377 [super setUp]; 376 [super setUp];
378 ReadingListModel* model = GetReadingListModel(); 377 ReadingListModel* model = GetReadingListModel();
379 for (const GURL& url : model->Keys()) 378 for (const GURL& url : model->Keys())
380 model->RemoveEntryByURL(url); 379 model->RemoveEntryByURL(url);
381 } 380 }
382 381
383 - (void)tearDown { 382 - (void)tearDown {
384 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 383 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
384 server.SetSuspend(NO);
385 if (!server.IsRunning()) { 385 if (!server.IsRunning()) {
386 server.StartOrDie(); 386 server.StartOrDie();
387 base::test::ios::SpinRunLoopWithMinDelay( 387 base::test::ios::SpinRunLoopWithMinDelay(
388 base::TimeDelta::FromSecondsD(kServerOperationDelay)); 388 base::TimeDelta::FromSecondsD(kServerOperationDelay));
389 } 389 }
390 [super tearDown]; 390 [super tearDown];
391 } 391 }
392 392
393 // Tests that the Reading List view is accessible. 393 // Tests that the Reading List view is accessible.
394 - (void)testAccessibility { 394 - (void)testAccessibility {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 assertWithMatcher:grey_notNil()]; 443 assertWithMatcher:grey_notNil()];
444 444
445 // Verify that the webState's title is correct. 445 // Verify that the webState's title is correct.
446 XCTAssertTrue(chrome_test_util::GetCurrentWebState()->GetTitle() == 446 XCTAssertTrue(chrome_test_util::GetCurrentWebState()->GetTitle() ==
447 base::ASCIIToUTF16(pageTitle.c_str())); 447 base::ASCIIToUTF16(pageTitle.c_str()));
448 } 448 }
449 449
450 // Tests that sharing a web page to the Reading List results in a snackbar 450 // Tests that sharing a web page to the Reading List results in a snackbar
451 // appearing, and that the Reading List entry is present in the Reading List. 451 // appearing, and that the Reading List entry is present in the Reading List.
452 // Loads online version by tapping on entry. 452 // Loads online version by tapping on entry.
453 // TODO(crbug.com/724555): Re-enable the test. 453 - (void)testSavingToReadingListAndLoadNormal {
454 - (void)DISABLED_testSavingToReadingListAndLoadNormal {
455 auto network_change_disabler = 454 auto network_change_disabler =
456 base::MakeUnique<net::NetworkChangeNotifier::DisableForTest>(); 455 base::MakeUnique<net::NetworkChangeNotifier::DisableForTest>();
457 auto wifi_network = base::MakeUnique<WifiNetworkChangeNotifier>(); 456 auto wifi_network = base::MakeUnique<WifiNetworkChangeNotifier>();
458 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer()); 457 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
459 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 458 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
460 std::string pageTitle(kDistillableTitle); 459 std::string pageTitle(kDistillableTitle);
461 460
462 // Open http://potato 461 // Open http://potato
463 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)]; 462 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)];
464 463
465 AddCurrentPageToReadingList(); 464 AddCurrentPageToReadingList();
466 465
467 // Navigate to http://beans 466 // Navigate to http://beans
468 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)]; 467 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)];
469 [ChromeEarlGrey waitForPageToFinishLoading]; 468 [ChromeEarlGrey waitForPageToFinishLoading];
470 469
471 // Verify that an entry with the correct title is present in the reading list. 470 // Verify that an entry with the correct title is present in the reading list.
472 OpenReadingList(); 471 OpenReadingList();
473 AssertEntryVisible(pageTitle); 472 AssertEntryVisible(pageTitle);
474 WaitForDistillation(); 473 WaitForDistillation();
475 474
476 // Long press the entry, and open it offline. 475 // Long press the entry, and open it offline.
477 TapEntry(pageTitle); 476 TapEntry(pageTitle);
478 477
479 AssertIsShowingDistillablePage(true); 478 AssertIsShowingDistillablePage(true);
480 // Stop server to reload offline. 479 // Stop server to reload offline.
481 server.Stop(); 480 server.SetSuspend(YES);
482 base::test::ios::SpinRunLoopWithMinDelay( 481 base::test::ios::SpinRunLoopWithMinDelay(
483 base::TimeDelta::FromSecondsD(kServerOperationDelay)); 482 base::TimeDelta::FromSecondsD(kServerOperationDelay));
484 483
485 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload( 484 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload(
486 web::ReloadType::NORMAL, false); 485 web::ReloadType::NORMAL, false);
487 AssertIsShowingDistillablePage(false); 486 AssertIsShowingDistillablePage(false);
488 } 487 }
489 488
490 // Tests that sharing a web page to the Reading List results in a snackbar 489 // Tests that sharing a web page to the Reading List results in a snackbar
491 // appearing, and that the Reading List entry is present in the Reading List. 490 // appearing, and that the Reading List entry is present in the Reading List.
492 // Loads offline version by tapping on entry without web server. 491 // Loads offline version by tapping on entry without web server.
493 // TODO(crbug.com/724555): Re-enable the test. 492 - (void)testSavingToReadingListAndLoadNoNetwork {
494 - (void)DISABLED_testSavingToReadingListAndLoadNoNetwork {
495 auto network_change_disabler = 493 auto network_change_disabler =
496 base::MakeUnique<net::NetworkChangeNotifier::DisableForTest>(); 494 base::MakeUnique<net::NetworkChangeNotifier::DisableForTest>();
497 auto wifi_network = base::MakeUnique<WifiNetworkChangeNotifier>(); 495 auto wifi_network = base::MakeUnique<WifiNetworkChangeNotifier>();
498 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer()); 496 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
499 std::string pageTitle(kDistillableTitle); 497 std::string pageTitle(kDistillableTitle);
500 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); 498 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance();
501 // Open http://potato 499 // Open http://potato
502 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)]; 500 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDistillableURL)];
503 501
504 AddCurrentPageToReadingList(); 502 AddCurrentPageToReadingList();
505 503
506 // Navigate to http://beans 504 // Navigate to http://beans
507 505
508 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)]; 506 [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNonDistillableURL)];
509 [ChromeEarlGrey waitForPageToFinishLoading]; 507 [ChromeEarlGrey waitForPageToFinishLoading];
510 508
511 // Verify that an entry with the correct title is present in the reading list. 509 // Verify that an entry with the correct title is present in the reading list.
512 OpenReadingList(); 510 OpenReadingList();
513 AssertEntryVisible(pageTitle); 511 AssertEntryVisible(pageTitle);
514 WaitForDistillation(); 512 WaitForDistillation();
515 513
516 // Stop server to generate error. 514 // Stop server to generate error.
517 server.Stop(); 515 server.SetSuspend(YES);
518 base::test::ios::SpinRunLoopWithMinDelay( 516 base::test::ios::SpinRunLoopWithMinDelay(
519 base::TimeDelta::FromSecondsD(kServerOperationDelay)); 517 base::TimeDelta::FromSecondsD(kServerOperationDelay));
520 // Long press the entry, and open it offline. 518 // Long press the entry, and open it offline.
521 TapEntry(pageTitle); 519 TapEntry(pageTitle);
522 520
523 AssertIsShowingDistillablePage(false); 521 AssertIsShowingDistillablePage(false);
524 // Start server to reload online error. 522 // Start server to reload online error.
525 server.StartOrDie(); 523 server.SetSuspend(NO);
526 base::test::ios::SpinRunLoopWithMinDelay( 524 base::test::ios::SpinRunLoopWithMinDelay(
527 base::TimeDelta::FromSecondsD(kServerOperationDelay)); 525 base::TimeDelta::FromSecondsD(kServerOperationDelay));
528 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer()); 526 web::test::SetUpSimpleHttpServer(ResponsesForDistillationServer());
529 527
530 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload( 528 chrome_test_util::GetCurrentWebState()->GetNavigationManager()->Reload(
531 web::ReloadType::NORMAL, false); 529 web::ReloadType::NORMAL, false);
532 AssertIsShowingDistillablePage(true); 530 AssertIsShowingDistillablePage(true);
533 } 531 }
534 532
535 // Tests that sharing a web page to the Reading List results in a snackbar 533 // Tests that sharing a web page to the Reading List results in a snackbar
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 assertWithMatcher:grey_nil()]; 796 assertWithMatcher:grey_nil()];
799 TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON); 797 TapButtonWithID(IDS_IOS_READING_LIST_EDIT_BUTTON);
800 TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON); 798 TapButtonWithID(IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON);
801 799
802 // Verify the background string is displayed. 800 // Verify the background string is displayed.
803 [[EarlGrey selectElementWithMatcher:EmptyBackground()] 801 [[EarlGrey selectElementWithMatcher:EmptyBackground()]
804 assertWithMatcher:grey_notNil()]; 802 assertWithMatcher:grey_notNil()];
805 } 803 }
806 804
807 @end 805 @end
OLDNEW
« no previous file with comments | « no previous file | ios/web/public/test/http_server/http_server.h » ('j') | ios/web/public/test/http_server/http_server.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698