| OLD | NEW |
| 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" | |
| 16 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 17 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/version.h" | 17 #include "base/version.h" |
| 19 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
| 20 #include "components/variations/metrics_util.h" | 19 #include "components/variations/metrics_util.h" |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
| 23 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 24 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 base::RunLoop run_loop_; | 102 base::RunLoop run_loop_; |
| 104 base::ThreadChecker thread_checker_; | 103 base::ThreadChecker thread_checker_; |
| 105 base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_; | 104 base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_; |
| 106 | 105 |
| 107 private: | 106 private: |
| 108 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest); | 107 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest); |
| 109 }; | 108 }; |
| 110 | 109 |
| 111 TEST_P(AntiVirusMetricsProviderTest, GetMetricsFullName) { | 110 TEST_P(AntiVirusMetricsProviderTest, GetMetricsFullName) { |
| 112 ASSERT_TRUE(thread_checker_.CalledOnValidThread()); | 111 ASSERT_TRUE(thread_checker_.CalledOnValidThread()); |
| 113 base::HistogramTester histograms; | |
| 114 SetFullNamesFeatureEnabled(expect_unhashed_value_); | 112 SetFullNamesFeatureEnabled(expect_unhashed_value_); |
| 115 // Make sure the I/O is happening on the FILE thread by disallowing it on | 113 // Make sure the I/O is happening on the FILE thread by disallowing it on |
| 116 // the main thread. | 114 // the main thread. |
| 117 bool previous_value = base::ThreadRestrictions::SetIOAllowed(false); | 115 bool previous_value = base::ThreadRestrictions::SetIOAllowed(false); |
| 118 provider_->GetAntiVirusMetrics( | 116 provider_->GetAntiVirusMetrics( |
| 119 base::Bind(&AntiVirusMetricsProviderTest::GetMetricsCallback, | 117 base::Bind(&AntiVirusMetricsProviderTest::GetMetricsCallback, |
| 120 weak_ptr_factory_.GetWeakPtr())); | 118 weak_ptr_factory_.GetWeakPtr())); |
| 121 content::RunThisRunLoop(&run_loop_); | 119 content::RunThisRunLoop(&run_loop_); |
| 122 EXPECT_TRUE(got_results_); | 120 EXPECT_TRUE(got_results_); |
| 123 base::ThreadRestrictions::SetIOAllowed(previous_value); | 121 base::ThreadRestrictions::SetIOAllowed(previous_value); |
| 124 histograms.ExpectUniqueSample("UMA.AntiVirusMetricsProvider.Result", | |
| 125 AntiVirusMetricsProvider::RESULT_SUCCESS, 1); | |
| 126 } | 122 } |
| 127 | 123 |
| 128 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); | 124 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); |
| OLD | NEW |