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

Side by Side Diff: chrome/browser/metrics/antivirus_metrics_provider_win_unittest.cc

Issue 2064313004: Add support for obtaining AV products on Win7. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review changes 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 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 "chrome/browser/metrics/antivirus_metrics_provider_win.h" 5 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/test/histogram_tester.h"
15 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
16 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
17 #include "base/version.h" 18 #include "base/version.h"
18 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
19 #include "components/variations/metrics_util.h" 20 #include "components/variations/metrics_util.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/test_browser_thread_bundle.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
22 #include "content/public/test/test_utils.h" 23 #include "content/public/test/test_utils.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 base::RunLoop run_loop_; 103 base::RunLoop run_loop_;
103 base::ThreadChecker thread_checker_; 104 base::ThreadChecker thread_checker_;
104 base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_; 105 base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_;
105 106
106 private: 107 private:
107 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest); 108 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest);
108 }; 109 };
109 110
110 TEST_P(AntiVirusMetricsProviderTest, GetMetricsFullName) { 111 TEST_P(AntiVirusMetricsProviderTest, GetMetricsFullName) {
111 ASSERT_TRUE(thread_checker_.CalledOnValidThread()); 112 ASSERT_TRUE(thread_checker_.CalledOnValidThread());
113 base::HistogramTester histograms;
112 SetFullNamesFeatureEnabled(expect_unhashed_value_); 114 SetFullNamesFeatureEnabled(expect_unhashed_value_);
113 // Make sure the I/O is happening on the FILE thread by disallowing it on 115 // Make sure the I/O is happening on the FILE thread by disallowing it on
114 // the main thread. 116 // the main thread.
115 bool previous_value = base::ThreadRestrictions::SetIOAllowed(false); 117 bool previous_value = base::ThreadRestrictions::SetIOAllowed(false);
116 provider_->GetAntiVirusMetrics( 118 provider_->GetAntiVirusMetrics(
117 base::Bind(&AntiVirusMetricsProviderTest::GetMetricsCallback, 119 base::Bind(&AntiVirusMetricsProviderTest::GetMetricsCallback,
118 weak_ptr_factory_.GetWeakPtr())); 120 weak_ptr_factory_.GetWeakPtr()));
119 content::RunThisRunLoop(&run_loop_); 121 content::RunThisRunLoop(&run_loop_);
120 EXPECT_TRUE(got_results_); 122 EXPECT_TRUE(got_results_);
121 base::ThreadRestrictions::SetIOAllowed(previous_value); 123 base::ThreadRestrictions::SetIOAllowed(previous_value);
124 histograms.ExpectUniqueSample("UMA.AntiVirusMetricsProvider.Result",
125 AntiVirusMetricsProvider::RESULT_SUCCESS, 1);
122 } 126 }
123 127
124 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); 128 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698