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

Unified Diff: chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc

Issue 2484613002: Migrate more tests to ScopedFeatureList. (Closed)
Patch Set: rebase Created 4 years, 1 month 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: chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc
diff --git a/chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc b/chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc
index 55f4d8f178edfcd422b162cd5c4e96913b3f50f1..9ace612832c8d1ca98d1bc1fe795b1f65ff3b023 100644
--- a/chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc
+++ b/chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc
@@ -7,12 +7,12 @@
#include <vector>
#include "base/bind.h"
-#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/strings/sys_string_conversions.h"
#include "base/test/histogram_tester.h"
+#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_restrictions.h"
#include "base/version.h"
@@ -25,21 +25,6 @@
namespace {
-// Helper function to toggle whether the ReportFullAVProductDetails feature is
-// enabled or not.
-void SetFullNamesFeatureEnabled(bool enabled) {
- base::FeatureList::ClearInstanceForTesting();
- std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
- if (enabled) {
- feature_list->InitializeFromCommandLine(
- AntiVirusMetricsProvider::kReportNamesFeature.name, std::string());
- } else {
- feature_list->InitializeFromCommandLine(
- std::string(), AntiVirusMetricsProvider::kReportNamesFeature.name);
- }
- base::FeatureList::SetInstance(std::move(feature_list));
-}
-
void VerifySystemProfileData(const metrics::SystemProfileProto& system_profile,
bool expect_unhashed_value) {
const char kWindowsDefender[] = "Windows Defender";
@@ -96,10 +81,23 @@ class AntiVirusMetricsProviderTest : public ::testing::TestWithParam<bool> {
VerifySystemProfileData(system_profile, expect_unhashed_value_);
}
+ // Helper function to toggle whether the ReportFullAVProductDetails feature is
+ // enabled or not.
+ void SetFullNamesFeatureEnabled(bool enabled) {
+ if (enabled) {
+ scoped_feature_list_.InitAndEnableFeature(
+ AntiVirusMetricsProvider::kReportNamesFeature);
+ } else {
+ scoped_feature_list_.InitAndDisableFeature(
+ AntiVirusMetricsProvider::kReportNamesFeature);
+ }
+ }
+
bool got_results_;
bool expect_unhashed_value_;
std::unique_ptr<AntiVirusMetricsProvider> provider_;
content::TestBrowserThreadBundle thread_bundle_;
+ base::test::ScopedFeatureList scoped_feature_list_;
base::RunLoop run_loop_;
base::ThreadChecker thread_checker_;
base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698