Chromium Code Reviews| 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" |
| 11 #include "base/sys_info.h" | |
| 11 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "chrome/browser/android/offline_pages/prerendering_loader.h" | 13 #include "chrome/browser/android/offline_pages/prerendering_loader.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/offline_pages/background/offliner.h" | 15 #include "components/offline_pages/background/offliner.h" |
| 15 #include "components/offline_pages/background/save_page_request.h" | 16 #include "components/offline_pages/background/save_page_request.h" |
| 16 #include "components/offline_pages/stub_offline_page_model.h" | 17 #include "components/offline_pages/stub_offline_page_model.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "content/public/test/web_contents_tester.h" | 19 #include "content/public/test/web_contents_tester.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 | 322 |
| 322 loader()->CompleteLoadingAsCanceled(); | 323 loader()->CompleteLoadingAsCanceled(); |
| 323 PumpLoop(); | 324 PumpLoop(); |
| 324 EXPECT_TRUE(completion_callback_called()); | 325 EXPECT_TRUE(completion_callback_called()); |
| 325 EXPECT_EQ(Offliner::RequestStatus::PRERENDERING_CANCELED, request_status()); | 326 EXPECT_EQ(Offliner::RequestStatus::PRERENDERING_CANCELED, request_status()); |
| 326 EXPECT_FALSE(loader()->IsLoaded()); | 327 EXPECT_FALSE(loader()->IsLoaded()); |
| 327 // Note: save still in progress since it does not support canceling. | 328 // Note: save still in progress since it does not support canceling. |
| 328 EXPECT_TRUE(SaveInProgress()); | 329 EXPECT_TRUE(SaveInProgress()); |
| 329 } | 330 } |
| 330 | 331 |
| 332 TEST_F(PrerenderingOfflinerTest, CancelOnForegroundTransitionIfLowEndDevice) { | |
| 333 base::Time creation_time = base::Time::Now(); | |
| 334 SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time); | |
| 335 EXPECT_TRUE(offliner()->LoadAndSave(request, callback())); | |
| 336 EXPECT_FALSE(loader()->IsIdle()); | |
| 337 | |
| 338 offliner()->SetApplicationStateForTesting( | |
| 339 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); | |
| 340 | |
| 341 if (base::SysInfo::IsLowEndDevice()) { | |
|
Pete Williamson
2016/07/13 23:17:55
This seems a bit problematic, the build bots may b
dougarnett
2016/07/13 23:44:20
I tried to address this point in advance in origin
Pete Williamson
2016/07/13 23:57:12
I'd really like to see this tested on both before
dougarnett
2016/07/14 15:29:21
Acknowledged - I will look to mock the case.
Plea
dougarnett
2016/07/15 16:00:25
Done.
Pete Williamson
2016/07/16 00:57:20
I don't see the change to mock, is it uploaded yet
| |
| 342 EXPECT_TRUE(loader()->IsIdle()); | |
| 343 EXPECT_EQ(Offliner::RequestStatus::FOREGROUND_CANCELED, request_status()); | |
| 344 } else { | |
| 345 // Loader still loading if not low-end device. | |
| 346 EXPECT_FALSE(loader()->IsIdle()); | |
| 347 } | |
| 348 } | |
| 349 | |
| 331 } // namespace offline_pages | 350 } // namespace offline_pages |
| OLD | NEW |