Chromium Code Reviews| Index: chrome/browser/offline_pages/background_loader_offliner_unittest.cc |
| diff --git a/chrome/browser/offline_pages/background_loader_offliner_unittest.cc b/chrome/browser/offline_pages/background_loader_offliner_unittest.cc |
| index 2482234b4963e8f1be33df80e9115c5c5c6027e5..c97aa10484ccb0c43f4f7f338de183d972c9df03 100644 |
| --- a/chrome/browser/offline_pages/background_loader_offliner_unittest.cc |
| +++ b/chrome/browser/offline_pages/background_loader_offliner_unittest.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/test/scoped_mock_time_message_loop_task_runner.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "chrome/browser/android/offline_pages/offliner_helper.h" |
| +#include "chrome/browser/loader/chrome_navigation_data.h" |
| #include "chrome/browser/net/prediction_options.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/test/base/testing_profile.h" |
| @@ -570,6 +571,27 @@ TEST_F(BackgroundLoaderOfflinerTest, MAYBE_NoNextOnInternetDisconnected) { |
| EXPECT_EQ(Offliner::RequestStatus::LOADING_FAILED_NO_NEXT, request_status()); |
| } |
| +TEST_F(BackgroundLoaderOfflinerTest, OffliningPreviewsStatusHistogram) { |
| + base::Time creation_time = base::Time::Now(); |
| + SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, |
| + kUserRequested); |
| + EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(), |
| + progress_callback())); |
| + |
| + // Called after calling LoadAndSave so we have web_contents to work with. |
| + std::unique_ptr<content::NavigationHandle> handle( |
| + content::NavigationHandle::CreateNavigationHandleForTesting( |
| + kHttpUrl, offliner()->web_contents()->GetMainFrame(), true, |
| + net::Error::OK)); |
| + // Call DidFinishNavigation with handle. |
| + offliner()->DidFinishNavigation(handle.get()); |
| + |
| + histograms().ExpectBucketCount( |
| + "OfflinePages.Background.OffliningPreviewStatus.async_loading", |
| + 0, // PreviewsOff |
|
RyanSturm
2017/06/02 20:50:34
Seems like you should have a test for PreviewsOn a
Pete Williamson
2017/06/02 21:40:32
I did try that, but it turns out to be problematic
RyanSturm
2017/06/02 22:14:25
I think that header is already added to this unitt
Pete Williamson
2017/06/02 23:17:41
Yep, that worked, test added. We now test both of
|
| + 1); |
| +} |
| + |
| TEST_F(BackgroundLoaderOfflinerTest, OnlySavesOnceOnMultipleLoads) { |
| base::Time creation_time = base::Time::Now(); |
| SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time, |