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

Unified Diff: components/previews/core/previews_io_data_unittest.cc

Issue 2760063002: Add support to previews/ for Server LoFi and LitePages (Closed)
Patch Set: rebase and previews_service_unittest.cc 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
Index: components/previews/core/previews_io_data_unittest.cc
diff --git a/components/previews/core/previews_io_data_unittest.cc b/components/previews/core/previews_io_data_unittest.cc
index 604cb1aa0603f64b1be6a683c7c5605a9bd583b9..1b535c175f78415ee30ec1fc9b57e642eb76b050 100644
--- a/components/previews/core/previews_io_data_unittest.cc
+++ b/components/previews/core/previews_io_data_unittest.cc
@@ -46,7 +46,10 @@ namespace {
// chrome/browser/previews/previews_service.cc and into the previews/ component.
bool IsPreviewFieldTrialEnabled(PreviewsType type) {
switch (type) {
+ // Use the offline field trial to simulate LoFi and LitePages being enabled.
tbansal1 2017/05/02 21:49:31 Is it possible to expand on this comment a bit? Th
RyanSturm 2017/05/02 22:57:19 Done. I removed sclittle's comment as it makes lit
case PreviewsType::OFFLINE:
+ case PreviewsType::LITE_PAGE:
+ case PreviewsType::SERVER_LOFI:
return params::IsOfflinePreviewsEnabled();
case PreviewsType::CLIENT_LOFI:
return params::IsClientLoFiEnabled();
@@ -273,6 +276,29 @@ TEST_F(PreviewsIODataTest, TestDisallowOfflineWhenNetworkQualityUnavailable) {
1);
}
+TEST_F(PreviewsIODataTest, TestAllowLoFiLitePageWhenNetworkQualityFast) {
+ // LoFi and LitePage check NQE on their own.
+ InitializeUIService();
+ CreateFieldTrialWithParams("ClientSidePreviews", "Enabled",
+ {{"show_offline_pages", "true"},
+ {"max_allowed_effective_connection_type", "2G"}});
+
+ network_quality_estimator()->set_effective_connection_type(
+ net::EFFECTIVE_CONNECTION_TYPE_3G);
+
+ base::HistogramTester histogram_tester;
+ EXPECT_TRUE(io_data()->ShouldAllowPreview(*CreateRequest(),
+ PreviewsType::SERVER_LOFI));
+ EXPECT_TRUE(
+ io_data()->ShouldAllowPreview(*CreateRequest(), PreviewsType::LITE_PAGE));
+ histogram_tester.ExpectUniqueSample(
+ "Previews.EligibilityReason.ServerLoFi",
+ static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1);
+ histogram_tester.ExpectUniqueSample(
+ "Previews.EligibilityReason.LitePage",
+ static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1);
+}
+
TEST_F(PreviewsIODataTest, TestDisallowOfflineWhenNetworkQualityFast) {
InitializeUIService();
CreateFieldTrialWithParams("ClientSidePreviews", "Enabled",
@@ -306,9 +332,7 @@ TEST_F(PreviewsIODataTest, TestDisallowOfflineOnReload) {
EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
histogram_tester.ExpectUniqueSample(
"Previews.EligibilityReason.Offline",
- static_cast<int>(
- PreviewsEligibilityReason::RELOAD_DISALLOWED_FOR_OFFLINE),
- 1);
+ static_cast<int>(PreviewsEligibilityReason::RELOAD_DISALLOWED), 1);
}
TEST_F(PreviewsIODataTest, TestAllowOffline) {

Powered by Google App Engine
This is Rietveld 408576698