| OLD | NEW |
| 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/android/offline_pages/prerendering_offliner.h" | 5 #include "chrome/browser/android/offline_pages/prerendering_offliner.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 base::Time creation_time = base::Time::Now(); | 466 base::Time creation_time = base::Time::Now(); |
| 467 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, | 467 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, |
| 468 kUserRequested); | 468 kUserRequested); |
| 469 request.set_completed_attempt_count(policy()->GetMaxCompletedTries() - 1); | 469 request.set_completed_attempt_count(policy()->GetMaxCompletedTries() - 1); |
| 470 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), | 470 EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), |
| 471 progress_callback())); | 471 progress_callback())); |
| 472 loader()->set_is_lowbar_met(true); | 472 loader()->set_is_lowbar_met(true); |
| 473 EXPECT_TRUE(offliner()->HandleTimeout(request)); | 473 EXPECT_TRUE(offliner()->HandleTimeout(request)); |
| 474 EXPECT_TRUE(loader()->start_snapshot_called()); | 474 EXPECT_TRUE(loader()->start_snapshot_called()); |
| 475 EXPECT_TRUE(SaveInProgress()); |
| 476 model()->CompleteSavingAsSuccess(); |
| 477 PumpLoop(); |
| 478 EXPECT_TRUE(completion_callback_called()); |
| 479 EXPECT_EQ(Offliner::RequestStatus::SAVED_ON_LAST_RETRY, request_status()); |
| 475 } | 480 } |
| 476 | 481 |
| 477 TEST_F(PrerenderingOfflinerTest, | 482 TEST_F(PrerenderingOfflinerTest, |
| 478 HandleTimeoutWithLowbarAndCompletedTriesMetLowEndDevice) { | 483 HandleTimeoutWithLowbarAndCompletedTriesMetLowEndDevice) { |
| 479 offliner()->SetLowEndDeviceForTesting(true); | 484 offliner()->SetLowEndDeviceForTesting(true); |
| 480 | 485 |
| 481 base::Time creation_time = base::Time::Now(); | 486 base::Time creation_time = base::Time::Now(); |
| 482 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, | 487 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, |
| 483 kUserRequested); | 488 kUserRequested); |
| 484 request.set_completed_attempt_count(policy()->GetMaxCompletedTries() - 1); | 489 request.set_completed_attempt_count(policy()->GetMaxCompletedTries() - 1); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 PumpLoop(); | 583 PumpLoop(); |
| 579 EXPECT_EQ(Offliner::RequestStatus::SAVED, request_status()); | 584 EXPECT_EQ(Offliner::RequestStatus::SAVED, request_status()); |
| 580 | 585 |
| 581 // One extra part should be added if the flag is on. | 586 // One extra part should be added if the flag is on. |
| 582 content::MHTMLExtraParts* extra_parts = | 587 content::MHTMLExtraParts* extra_parts = |
| 583 content::MHTMLExtraParts::FromWebContents(loader()->web_contents()); | 588 content::MHTMLExtraParts::FromWebContents(loader()->web_contents()); |
| 584 EXPECT_EQ(extra_parts->size(), 1); | 589 EXPECT_EQ(extra_parts->size(), 1); |
| 585 } | 590 } |
| 586 | 591 |
| 587 } // namespace offline_pages | 592 } // namespace offline_pages |
| OLD | NEW |