| 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" |
| 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 Loading... |
| 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 |
| 125 AntiVirusMetricsProvider::ResultCode expected_result = |
| 126 AntiVirusMetricsProvider::RESULT_SUCCESS; |
| 127 if (base::win::OSInfo::GetInstance()->version_type() == |
| 128 base::win::SUITE_SERVER) |
| 129 expected_result = AntiVirusMetricsProvider::RESULT_WSC_NOT_AVAILABLE; |
| 130 histograms.ExpectUniqueSample("UMA.AntiVirusMetricsProvider.Result", |
| 131 expected_result, 1); |
| 122 } | 132 } |
| 123 | 133 |
| 124 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); | 134 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); |
| OLD | NEW |