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

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: Added flag to LoginCustomFlags histogram 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 b9c710c2e66e6f1245a12712b236b8e1d68dec7c..c6635ea523feb1704144f9e6ba61d3dad7448d9b 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 {
@@ -1289,6 +1291,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) {
EXPECT_NE(
coordinator()->SavePageLater(

Powered by Google App Engine
This is Rietveld 408576698