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

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

Issue 2819393002: Collect loading signal data from the background loader offliner (Closed)
Patch Set: Add comment about why we use a double. Created 3 years, 8 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
« no previous file with comments | « chrome/browser/android/offline_pages/background_loader_offliner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc
diff --git a/chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc b/chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc
index 15df60d4a44755e8d2c0e5b358d4240259e3e36f..8ff60b5376b9838e92e4f7528ce8900dd650fb07 100644
--- a/chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc
+++ b/chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/test/histogram_tester.h"
+#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_mock_time_message_loop_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/android/offline_pages/offliner_helper.h"
@@ -18,8 +19,10 @@
#include "components/offline_pages/core/background/offliner.h"
#include "components/offline_pages/core/background/offliner_policy.h"
#include "components/offline_pages/core/background/save_page_request.h"
+#include "components/offline_pages/core/offline_page_feature.h"
#include "components/offline_pages/core/stub_offline_page_model.h"
#include "components/prefs/pref_service.h"
+#include "content/public/browser/mhtml_extra_parts.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -560,4 +563,45 @@ TEST_F(BackgroundLoaderOfflinerTest, HandleTimeoutWithLowBarNoRetryLimit) {
EXPECT_FALSE(SaveInProgress());
}
+TEST_F(BackgroundLoaderOfflinerTest, SignalCollectionDisabled) {
+ // Ensure feature flag for Signal collection is off,
+ EXPECT_FALSE(offline_pages::IsOfflinePagesLoadSignalCollectingEnabled());
+
+ base::Time creation_time = base::Time::Now();
+ SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time,
+ kUserRequested);
+ EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(),
+ progress_callback()));
+
+ CompleteLoading();
+ PumpLoop();
+
+ // No extra parts should be added if the flag is off.
+ content::MHTMLExtraParts* extra_parts =
+ content::MHTMLExtraParts::FromWebContents(offliner()->web_contents());
+ EXPECT_EQ(extra_parts->size(), 0);
+}
+
+TEST_F(BackgroundLoaderOfflinerTest, SignalCollectionEnabled) {
+ // Ensure feature flag for signal collection is on.
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitAndEnableFeature(
+ kOfflinePagesLoadSignalCollectingFeature);
+ EXPECT_TRUE(IsOfflinePagesLoadSignalCollectingEnabled());
+
+ base::Time creation_time = base::Time::Now();
+ SavePageRequest request(kRequestId, kHttpUrl, kClientId, creation_time,
+ kUserRequested);
+ EXPECT_TRUE(offliner()->LoadAndSave(request, completion_callback(),
+ progress_callback()));
+
+ CompleteLoading();
+ PumpLoop();
+
+ // One extra part should be added if the flag is on.
+ content::MHTMLExtraParts* extra_parts =
+ content::MHTMLExtraParts::FromWebContents(offliner()->web_contents());
+ EXPECT_EQ(extra_parts->size(), 1);
+}
+
} // namespace offline_pages
« no previous file with comments | « chrome/browser/android/offline_pages/background_loader_offliner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698