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

Unified Diff: components/subresource_filter/core/browser/subresource_filter_features_test_support.cc

Issue 2022783002: Skeleton of the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement RenderFrameObserver::OnDestruct introduced by rebase. Created 4 years, 6 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/subresource_filter/core/browser/subresource_filter_features_test_support.cc
diff --git a/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc b/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6b9cee67bab8835823be2e3637d6e3ac382113c6
--- /dev/null
+++ b/components/subresource_filter/core/browser/subresource_filter_features_test_support.cc
@@ -0,0 +1,49 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/subresource_filter/core/browser/subresource_filter_features_test_support.h"
+
+#include <map>
+#include <memory>
+
+#include "base/metrics/field_trial.h"
+#include "components/subresource_filter/core/browser/subresource_filter_features.h"
+#include "components/variations/variations_associated_data.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace subresource_filter {
+namespace testing {
+
+namespace {
+const char kTestFieldTrialName[] = "FieldTrialNameShouldNotMatter";
+const char kTestExperimentGroupName[] = "GroupNameShouldNotMatter";
+} // namespace
+
+ScopedSubresourceFilterFeatureToggle::ScopedSubresourceFilterFeatureToggle(
+ base::FeatureList::OverrideState feature_state,
+ const std::string& maximum_activation_state) {
+ base::FeatureList::ClearInstanceForTesting();
+ variations::testing::ClearAllVariationParams();
+
+ std::map<std::string, std::string> variation_params;
+ variation_params[kActivationStateParameterName] = maximum_activation_state;
+ EXPECT_TRUE(variations::AssociateVariationParams(
+ kTestFieldTrialName, kTestExperimentGroupName, variation_params));
+
+ base::FieldTrial* field_trial = base::FieldTrialList::CreateFieldTrial(
+ kTestFieldTrialName, kTestExperimentGroupName);
+
+ std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
+ feature_list->RegisterFieldTrialOverride(kSafeBrowsingSubresourceFilter.name,
+ feature_state, field_trial);
+ base::FeatureList::SetInstance(std::move(feature_list));
+}
+
+ScopedSubresourceFilterFeatureToggle::~ScopedSubresourceFilterFeatureToggle() {
+ variations::testing::ClearAllVariationParams();
+ base::FeatureList::ClearInstanceForTesting();
+}
+
+} // namespace testing
+} // namespace subresource_filter

Powered by Google App Engine
This is Rietveld 408576698