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

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

Issue 2748033002: Revert of Moving previews code from components/ to chrome/ (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/previews/core/previews_io_data.cc ('k') | components/previews/core/previews_opt_out_store_sql.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23b1bac9a3a2007ad4e929db67761845c9aa64fa..39a8925e618e6667060a5207f816ae47e89a35be 100644
--- a/components/previews/core/previews_io_data_unittest.cc
+++ b/components/previews/core/previews_io_data_unittest.cc
@@ -37,10 +37,6 @@
namespace {
-bool CheckOfflineFieldTrial(PreviewsType type) {
- return previews::params::IsOfflinePreviewsEnabled();
-}
-
class TestPreviewsIOData : public PreviewsIOData {
public:
TestPreviewsIOData(
@@ -129,7 +125,7 @@
set_io_data(base::MakeUnique<TestPreviewsIOData>(loop_.task_runner(),
loop_.task_runner()));
set_ui_service(base::MakeUnique<PreviewsUIService>(
- io_data(), loop_.task_runner(), nullptr, PreviewsIsEnabledCallback()));
+ io_data(), loop_.task_runner(), nullptr));
base::RunLoop().RunUntilIdle();
// After the outstanding posted tasks have run, |io_data_| should be fully
// initialized.
@@ -148,37 +144,28 @@
loop_.task_runner()));
base::HistogramTester histogram_tester;
- // The blacklist is not created yet.
- EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
- histogram_tester.ExpectUniqueSample(
- "Previews.EligibilityReason.Offline",
- static_cast<int>(PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE), 1);
-
- set_ui_service(base::MakeUnique<PreviewsUIService>(
- io_data(), loop_.task_runner(),
- base::MakeUnique<TestPreviewsOptOutStore>(),
- base::Bind(&CheckOfflineFieldTrial)));
-
- // The blacklist is not created yet.
- EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
- histogram_tester.ExpectBucketCount(
- "Previews.EligibilityReason.Offline",
- static_cast<int>(PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE), 2);
-
- base::RunLoop().RunUntilIdle();
-
- histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 2);
// If not in the field trial, don't log anything, and return false.
EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
- histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 2);
+ histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 0);
// Enable Offline previews field trial.
base::FieldTrialList field_trial_list(nullptr);
std::map<std::string, std::string> params;
params["show_offline_pages"] = "true";
-
variations::AssociateVariationParams("ClientSidePreviews", "Enabled", params);
base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled");
+
+ // The blacklist is not created yet.
+ EXPECT_FALSE(io_data()->ShouldAllowPreview(*request, PreviewsType::OFFLINE));
+ histogram_tester.ExpectUniqueSample(
+ "Previews.EligibilityReason.Offline",
+ static_cast<int>(PreviewsEligibilityReason::BLACKLIST_UNAVAILABLE), 1);
+
+ set_ui_service(base::WrapUnique(
+ new PreviewsUIService(io_data(), loop_.task_runner(),
+ base::MakeUnique<TestPreviewsOptOutStore>())));
+
+ base::RunLoop().RunUntilIdle();
// Return one of the failing statuses from the blacklist; cause the blacklist
// to not be loaded by clearing the blacklist.
@@ -240,7 +227,7 @@
"Previews.EligibilityReason.Offline",
static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1);
- histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 8);
+ histogram_tester.ExpectTotalCount("Previews.EligibilityReason.Offline", 7);
variations::testing::ClearAllVariationParams();
}
« no previous file with comments | « components/previews/core/previews_io_data.cc ('k') | components/previews/core/previews_opt_out_store_sql.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698