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

Side by Side Diff: chrome/browser/offline_pages/background_loader_offliner_unittest.cc

Issue 2891623002: Disable crashing unittests in background offliner. (Closed)
Patch Set: Rebased, which handles the file moving outside the /android path. Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/offline_pages/background_loader_offliner.h" 5 #include "chrome/browser/offline_pages/background_loader_offliner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/test/scoped_feature_list.h" 10 #include "base/test/scoped_feature_list.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 void BackgroundLoaderOfflinerTest::OnProgress(const SavePageRequest& request, 229 void BackgroundLoaderOfflinerTest::OnProgress(const SavePageRequest& request,
230 int64_t bytes) { 230 int64_t bytes) {
231 progress_ = bytes; 231 progress_ = bytes;
232 } 232 }
233 233
234 void BackgroundLoaderOfflinerTest::OnCancel(const SavePageRequest& request) { 234 void BackgroundLoaderOfflinerTest::OnCancel(const SavePageRequest& request) {
235 DCHECK(!cancel_callback_called_); 235 DCHECK(!cancel_callback_called_);
236 cancel_callback_called_ = true; 236 cancel_callback_called_ = true;
237 } 237 }
238 238
239 // Two tests crash roughly 20% of runs on Android. http://crbug.com/722556.
240 #if defined(OS_ANDROID)
241 #define MAYBE_FailsOnErrorPage DISABLED_FailsOnErrorPage
242 #define MAYBE_NoNextOnInternetDisconnected DISABLED_NoNextOnInternetDisconnected
243 #else
244 #define MAYBE_FailsOnErrorPage FailsOnErrorPage
245 #define MAYBE_NoNextOnInternetDisconnected NoNextOnInternetDisconnected
246 #endif
247
239 TEST_F(BackgroundLoaderOfflinerTest, 248 TEST_F(BackgroundLoaderOfflinerTest,
240 LoadAndSaveBlockThirdPartyCookiesForCustomTabs) { 249 LoadAndSaveBlockThirdPartyCookiesForCustomTabs) {
241 base::Time creation_time = base::Time::Now(); 250 base::Time creation_time = base::Time::Now();
242 ClientId custom_tabs_client_id("custom_tabs", "88"); 251 ClientId custom_tabs_client_id("custom_tabs", "88");
243 SavePageRequest request(kRequestId, kHttpUrl, custom_tabs_client_id, 252 SavePageRequest request(kRequestId, kHttpUrl, custom_tabs_client_id,
244 creation_time, kUserRequested); 253 creation_time, kUserRequested);
245 254
246 profile()->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true); 255 profile()->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true);
247 EXPECT_FALSE(offliner()->LoadAndSave(request, completion_callback(), 256 EXPECT_FALSE(offliner()->LoadAndSave(request, completion_callback(),
248 progress_callback())); 257 progress_callback()));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, 466 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time,
458 kUserRequested); 467 kUserRequested);
459 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), 468 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(),
460 progress_callback())); 469 progress_callback()));
461 offliner()->WebContentsDestroyed(); 470 offliner()->WebContentsDestroyed();
462 471
463 EXPECT_TRUE(completion_callback_called()); 472 EXPECT_TRUE(completion_callback_called());
464 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED, request_status()); 473 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED, request_status());
465 } 474 }
466 475
467 TEST_F(BackgroundLoaderOfflinerTest, FailsOnErrorPage) { 476 TEST_F(BackgroundLoaderOfflinerTest, MAYBE_FailsOnErrorPage) {
468 base::Time creation_time = base::Time::Now(); 477 base::Time creation_time = base::Time::Now();
469 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, 478 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time,
470 kUserRequested); 479 kUserRequested);
471 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), 480 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(),
472 progress_callback())); 481 progress_callback()));
473 // Create handle with net error code. 482 // Create handle with net error code.
474 // Called after calling LoadAndSave so we have web_contents to work with. 483 // Called after calling LoadAndSave so we have web_contents to work with.
475 std::unique_ptr<content::NavigationHandle> handle( 484 std::unique_ptr<content::NavigationHandle> handle(
476 content::NavigationHandle::CreateNavigationHandleForTesting( 485 content::NavigationHandle::CreateNavigationHandleForTesting(
477 kHttpUrl, offliner()->web_contents()->GetMainFrame(), true, 486 kHttpUrl, offliner()->web_contents()->GetMainFrame(), true,
478 net::Error::ERR_NAME_NOT_RESOLVED)); 487 net::Error::ERR_NAME_NOT_RESOLVED));
479 // NavigationHandle destruction will trigger DidFinishNavigation code. 488 // NavigationHandle destruction will trigger DidFinishNavigation code.
480 handle.reset(); 489 handle.reset();
481 histograms().ExpectBucketCount( 490 histograms().ExpectBucketCount(
482 "OfflinePages.Background.BackgroundLoadingFailedCode.async_loading", 491 "OfflinePages.Background.BackgroundLoadingFailedCode.async_loading",
483 105, // ERR_NAME_NOT_RESOLVED 492 105, // ERR_NAME_NOT_RESOLVED
484 1); 493 1);
485 CompleteLoading(); 494 CompleteLoading();
486 PumpLoop(); 495 PumpLoop();
487 496
488 EXPECT_TRUE(completion_callback_called()); 497 EXPECT_TRUE(completion_callback_called());
489 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED, request_status()); 498 EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED, request_status());
490 } 499 }
491 500
492 TEST_F(BackgroundLoaderOfflinerTest, NoNextOnInternetDisconnected) { 501 TEST_F(BackgroundLoaderOfflinerTest, MAYBE_NoNextOnInternetDisconnected) {
493 base::Time creation_time = base::Time::Now(); 502 base::Time creation_time = base::Time::Now();
494 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, 503 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time,
495 kUserRequested); 504 kUserRequested);
496 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), 505 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(),
497 progress_callback())); 506 progress_callback()));
498 507
499 // Create handle with net error code. 508 // Create handle with net error code.
500 // Called after calling LoadAndSave so we have web_contents to work with. 509 // Called after calling LoadAndSave so we have web_contents to work with.
501 std::unique_ptr<content::NavigationHandle> handle( 510 std::unique_ptr<content::NavigationHandle> handle(
502 content::NavigationHandle::CreateNavigationHandleForTesting( 511 content::NavigationHandle::CreateNavigationHandleForTesting(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 CompleteLoading(); 649 CompleteLoading();
641 PumpLoop(); 650 PumpLoop();
642 651
643 // One extra part should be added if the flag is on. 652 // One extra part should be added if the flag is on.
644 content::MHTMLExtraParts* extra_parts = 653 content::MHTMLExtraParts* extra_parts =
645 content::MHTMLExtraParts::FromWebContents(offliner()->web_contents()); 654 content::MHTMLExtraParts::FromWebContents(offliner()->web_contents());
646 EXPECT_EQ(extra_parts->size(), 1); 655 EXPECT_EQ(extra_parts->size(), 1);
647 } 656 }
648 657
649 } // namespace offline_pages 658 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698