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

Unified Diff: chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc

Issue 2149773002: PrerenderingOffliner will abort background load if it sees chrome transitioning to foreground on lo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nutha try Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc
diff --git a/chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc b/chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc
index f2a4b7853c6d3e1cf24083e720e94cb873d81ade..a8d034127ead58e998e2157111cc7e11cb000cb9 100644
--- a/chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc
+++ b/chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/run_loop.h"
+#include "base/sys_info.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/android/offline_pages/prerendering_loader.h"
#include "chrome/test/base/testing_profile.h"
@@ -328,4 +329,22 @@ TEST_F(PrerenderingOfflinerTest, LoadAndSaveLoadedButThenCanceledFromLoader) {
EXPECT_TRUE(SaveInProgress());
}
+TEST_F(PrerenderingOfflinerTest, CancelOnForegroundTransitionIfLowEndDevice) {
+ base::Time creation_time = base::Time::Now();
+ SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time);
+ EXPECT_TRUE(offliner()->LoadAndSave(request, callback()));
+ EXPECT_FALSE(loader()->IsIdle());
+
+ offliner()->SetApplicationStateForTesting(
+ base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES);
+
+ 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
+ EXPECT_TRUE(loader()->IsIdle());
+ EXPECT_EQ(Offliner::RequestStatus::FOREGROUND_CANCELED, request_status());
+ } else {
+ // Loader still loading if not low-end device.
+ EXPECT_FALSE(loader()->IsIdle());
+ }
+}
+
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698