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

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: Revise some comments wrt app listener setting/clearing 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..ca9f1586bef25aea31bcca6cc70664e2967834e3 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,35 @@ TEST_F(PrerenderingOfflinerTest, LoadAndSaveLoadedButThenCanceledFromLoader) {
EXPECT_TRUE(SaveInProgress());
}
+TEST_F(PrerenderingOfflinerTest, ForegroundTransitionCancelsOnLowEndDevice) {
+ offliner()->SetLowEndDeviceForTesting(true);
+
+ 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);
+
+ // Loading canceled on low-end device.
+ EXPECT_TRUE(loader()->IsIdle());
+ EXPECT_EQ(Offliner::RequestStatus::FOREGROUND_CANCELED, request_status());
+}
+
+TEST_F(PrerenderingOfflinerTest, ForegroundTransitionIgnoredOnHighEndDevice) {
+ offliner()->SetLowEndDeviceForTesting(false);
+
+ 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);
+
+ // Loader still loading since not low-end device.
+ EXPECT_FALSE(loader()->IsIdle());
+}
+
} // namespace offline_pages
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_offliner.cc ('k') | components/offline_pages/background/offliner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698