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

Unified Diff: components/offline_pages/background/request_coordinator_unittest.cc

Issue 2483463002: [Offline Pages] Feature flag to allow concurrent background loading on svelte (Closed)
Patch Set: Merge Created 4 years, 1 month 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: components/offline_pages/background/request_coordinator_unittest.cc
diff --git a/components/offline_pages/background/request_coordinator_unittest.cc b/components/offline_pages/background/request_coordinator_unittest.cc
index af0ad232e6c97d91e9f16297d243a5072ac2581a..d12dda40ccbc4fda04e45d328cad5932018c962f 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -14,6 +14,7 @@
#include "base/logging.h"
#include "base/synchronization/waitable_event.h"
#include "base/sys_info.h"
+#include "base/test/scoped_feature_list.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -25,6 +26,7 @@
#include "components/offline_pages/background/request_queue_in_memory_store.h"
#include "components/offline_pages/background/save_page_request.h"
#include "components/offline_pages/background/scheduler.h"
+#include "components/offline_pages/offline_page_feature.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace offline_pages {
@@ -1347,6 +1349,45 @@ TEST_F(RequestCoordinatorTest,
}
}
+TEST_F(RequestCoordinatorTest,
+ SavePageStartsProcessingWhenConnectedOnLowEndDeviceIfFlagEnabled) {
+ // Set up the fake network conditions for the NetworkConnectionNotifier.
+ SetNetworkConditionsForTest(
+ net::NetworkChangeNotifier::ConnectionType::CONNECTION_3G);
+ // Set up the fake network conditions for the network quality estimator.
+ SetEffectiveConnectionTypeForTest(
+ net::EffectiveConnectionType::EFFECTIVE_CONNECTION_TYPE_3G);
+ // Mark device as low-end device.
+ SetIsLowEndDeviceForTest(true);
+ EXPECT_FALSE(offline_pages::IsOfflinePagesSvelteConcurrentLoadingEnabled());
+
+ // Make a request.
+ EXPECT_NE(coordinator()->SavePageLater(
+ kUrl1, kClientId1, kUserRequested,
+ RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER),
+ 0);
+ PumpLoop();
+
+ // Verify not immediately busy (since low-end device).
+ EXPECT_FALSE(is_busy());
+
+ // Set feature flag to allow concurrent loads.
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitAndEnableFeature(
+ kOfflinePagesSvelteConcurrentLoadingFeature);
+ EXPECT_TRUE(offline_pages::IsOfflinePagesSvelteConcurrentLoadingEnabled());
+
+ // Make another request.
+ EXPECT_NE(coordinator()->SavePageLater(
+ kUrl2, kClientId2, kUserRequested,
+ RequestCoordinator::RequestAvailability::ENABLED_FOR_OFFLINER),
+ 0);
+ PumpLoop();
+
+ // Verify immediate processing did start this time.
+ EXPECT_TRUE(is_busy());
+}
+
TEST_F(RequestCoordinatorTest, SavePageDoesntStartProcessingWhenDisconnected) {
SetNetworkConnected(false);
EXPECT_NE(
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | components/offline_pages/offline_page_feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698