| 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/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "base/test/histogram_tester.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 |
| 25 namespace { | 26 namespace { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 bool expect_unhashed_value_; | 97 bool expect_unhashed_value_; |
| 97 std::unique_ptr<AntiVirusMetricsProvider> provider_; | 98 std::unique_ptr<AntiVirusMetricsProvider> provider_; |
| 98 content::TestBrowserThreadBundle thread_bundle_; | 99 content::TestBrowserThreadBundle thread_bundle_; |
| 99 base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_; | 100 base::WeakPtrFactory<AntiVirusMetricsProviderTest> weak_ptr_factory_; |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest); | 103 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProviderTest); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 TEST_P(AntiVirusMetricsProviderTest, GetMetricsFullName) { | 106 TEST_P(AntiVirusMetricsProviderTest, GetMetricsFullName) { |
| 107 base::HistogramTester histograms; |
| 106 SetFullNamesFeatureEnabled(expect_unhashed_value_); | 108 SetFullNamesFeatureEnabled(expect_unhashed_value_); |
| 107 // Make sure the I/O is happening on the FILE thread by disallowing it on | 109 // Make sure the I/O is happening on the FILE thread by disallowing it on |
| 108 // the main thread. | 110 // the main thread. |
| 109 bool previous_value = base::ThreadRestrictions::SetIOAllowed(false); | 111 bool previous_value = base::ThreadRestrictions::SetIOAllowed(false); |
| 110 provider_->GetAntiVirusMetrics( | 112 provider_->GetAntiVirusMetrics( |
| 111 base::Bind(&AntiVirusMetricsProviderTest::GetMetricsCallback, | 113 base::Bind(&AntiVirusMetricsProviderTest::GetMetricsCallback, |
| 112 weak_ptr_factory_.GetWeakPtr())); | 114 weak_ptr_factory_.GetWeakPtr())); |
| 113 content::RunMessageLoop(); | 115 content::RunMessageLoop(); |
| 114 EXPECT_TRUE(got_results_); | 116 EXPECT_TRUE(got_results_); |
| 115 base::ThreadRestrictions::SetIOAllowed(previous_value); | 117 base::ThreadRestrictions::SetIOAllowed(previous_value); |
| 118 histograms.ExpectUniqueSample("UMA.AntiVirusMetricsProvider.Result", |
| 119 AntiVirusMetricsProvider::RESULT_SUCCESS, 1); |
| 116 } | 120 } |
| 117 | 121 |
| 118 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); | 122 INSTANTIATE_TEST_CASE_P(, AntiVirusMetricsProviderTest, ::testing::Bool()); |
| OLD | NEW |