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

Side by Side Diff: components/previews/core/previews_io_data_unittest.cc

Issue 2760063002: Add support to previews/ for Server LoFi and LitePages (Closed)
Patch Set: build fix Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/previews/core/previews_io_data.h" 5 #include "components/previews/core/previews_io_data.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 2); 215 2);
216 216
217 // Set NQE type to fast enough. 217 // Set NQE type to fast enough.
218 network_quality_estimator.set_effective_connection_type( 218 network_quality_estimator.set_effective_connection_type(
219 net::EFFECTIVE_CONNECTION_TYPE_2G); 219 net::EFFECTIVE_CONNECTION_TYPE_2G);
220 EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE)); 220 EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
221 histogram_tester.ExpectBucketCount( 221 histogram_tester.ExpectBucketCount(
222 "Previews.EligibilityReason.Offline", 222 "Previews.EligibilityReason.Offline",
223 static_cast<int>(PreviewsEligibilityReason::NETWORK_NOT_SLOW), 1); 223 static_cast<int>(PreviewsEligibilityReason::NETWORK_NOT_SLOW), 1);
224 224
225 // LitePage makes its own decision about network quality.
226 EXPECT_TRUE(io_data()->ShouldAllowPreview(*request, PreviewsType::LITE_PAGE));
227 histogram_tester.ExpectBucketCount(
228 "Previews.EligibilityReason.LitePage",
229 static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1);
230
225 // Set NQE type to slow. 231 // Set NQE type to slow.
226 network_quality_estimator.set_effective_connection_type( 232 network_quality_estimator.set_effective_connection_type(
227 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); 233 net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G);
228 234
229 request->SetLoadFlags(net::LOAD_BYPASS_CACHE); 235 request->SetLoadFlags(net::LOAD_BYPASS_CACHE);
230 EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE)); 236 EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
231 histogram_tester.ExpectBucketCount( 237 histogram_tester.ExpectBucketCount(
232 "Previews.EligibilityReason.Offline", 238 "Previews.EligibilityReason.Offline",
233 static_cast<int>( 239 static_cast<int>(PreviewsEligibilityReason::RELOAD_DISALLOWED), 1);
234 PreviewsEligibilityReason::RELOAD_DISALLOWED_FOR_OFFLINE), 240
235 1); 241 // Server LoFi ignores reload when deciding to show the preview.
242 EXPECT_TRUE(
243 io_data()->ShouldAllowPreview(*request, PreviewsType::SERVER_LOFI));
244 histogram_tester.ExpectBucketCount(
245 "Previews.EligibilityReason.ServerLoFi",
246 static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1);
236 247
237 request->SetLoadFlags(0); 248 request->SetLoadFlags(0);
238 EXPECT_TRUE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE)); 249 EXPECT_TRUE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
239 histogram_tester.ExpectBucketCount( 250 histogram_tester.ExpectBucketCount(
240 "Previews.EligibilityReason.Offline", 251 "Previews.EligibilityReason.Offline",
241 static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1); 252 static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1);
242 253
243 histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 8); 254 histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 8);
244 255
245 variations::testing::ClearAllVariationParams(); 256 variations::testing::ClearAllVariationParams();
246 } 257 }
247 258
248 } // namespace previews 259 } // namespace previews
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698