OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "chrome/browser/policy/cloud_policy_controller.h" | 11 #include "chrome/browser/policy/cloud_policy_controller.h" |
12 #include "chrome/browser/policy/cloud_policy_data_store.h" | 12 #include "chrome/browser/policy/cloud_policy_data_store.h" |
13 #include "chrome/browser/policy/device_management_backend.h" | 13 #include "chrome/browser/policy/device_management_backend.h" |
14 #include "chrome/browser/policy/device_management_backend_mock.h" | 14 #include "chrome/browser/policy/device_management_backend_mock.h" |
15 #include "chrome/browser/policy/device_management_service.h" | 15 #include "chrome/browser/policy/device_management_service.h" |
16 #include "chrome/browser/policy/device_token_fetcher.h" | 16 #include "chrome/browser/policy/device_token_fetcher.h" |
17 #include "chrome/browser/policy/enterprise_metrics.h" | 17 #include "chrome/browser/policy/enterprise_metrics.h" |
18 #include "chrome/browser/policy/mock_cloud_policy_data_store.h" | 18 #include "chrome/browser/policy/mock_cloud_policy_data_store.h" |
19 #include "chrome/browser/policy/mock_device_management_service.h" | 19 #include "chrome/browser/policy/mock_device_management_service.h" |
20 #include "chrome/browser/policy/policy_notifier.h" | 20 #include "chrome/browser/policy/policy_notifier.h" |
21 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 21 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
22 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 22 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
23 #include "chrome/browser/policy/user_policy_cache.h" | 23 #include "chrome/browser/policy/user_policy_cache.h" |
24 #include "chrome/browser/policy/user_policy_token_cache.h" | 24 #include "chrome/browser/policy/user_policy_token_cache.h" |
25 #include "chrome/test/base/testing_browser_process_test.h" | |
26 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
27 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
30 | 29 |
31 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
32 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" | 31 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" |
33 #include "chrome/browser/chromeos/login/mock_signed_settings_helper.h" | 32 #include "chrome/browser/chromeos/login/mock_signed_settings_helper.h" |
34 #include "chrome/browser/chromeos/login/signed_settings.h" | 33 #include "chrome/browser/chromeos/login/signed_settings.h" |
35 #include "chrome/browser/policy/device_policy_cache.h" | 34 #include "chrome/browser/policy/device_policy_cache.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 }; | 106 }; |
108 | 107 |
109 } // namespace | 108 } // namespace |
110 | 109 |
111 // This derives from testing::Test and not from InProcessBrowserTest and is | 110 // This derives from testing::Test and not from InProcessBrowserTest and is |
112 // linked with browser_tests. The reason is that these are just unit tests, but | 111 // linked with browser_tests. The reason is that these are just unit tests, but |
113 // due to the static initialization of the UMA counters they have to run each | 112 // due to the static initialization of the UMA counters they have to run each |
114 // in its own process to make sure the counters are not initialized before the | 113 // in its own process to make sure the counters are not initialized before the |
115 // test runs, and that the StatisticsRecorder instance created for the test | 114 // test runs, and that the StatisticsRecorder instance created for the test |
116 // doesn't interfere with counters in other tests. | 115 // doesn't interfere with counters in other tests. |
117 class EnterpriseMetricsTest : public TestingBrowserProcessTest { | 116 class EnterpriseMetricsTest : public testing::Test { |
118 public: | 117 public: |
119 EnterpriseMetricsTest() | 118 EnterpriseMetricsTest() |
120 : ui_thread_(BrowserThread::UI, &loop_), | 119 : ui_thread_(BrowserThread::UI, &loop_), |
121 file_thread_(BrowserThread::FILE, &loop_) { | 120 file_thread_(BrowserThread::FILE, &loop_) { |
122 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 121 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
123 } | 122 } |
124 | 123 |
125 void SetMetricName(const std::string& metric_name) { | 124 void SetMetricName(const std::string& metric_name) { |
126 metric_name_ = metric_name; | 125 metric_name_ = metric_name; |
127 if (metric_name == kMetricToken) { | 126 if (metric_name == kMetricToken) { |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 helper.CompleteRetrieve(chromeos::SignedSettings::NOT_FOUND); | 840 helper.CompleteRetrieve(chromeos::SignedSettings::NOT_FOUND); |
842 helper.SetData("\xff"); | 841 helper.SetData("\xff"); |
843 helper.SetPolicy(); | 842 helper.SetPolicy(); |
844 ExpectSample(kMetricPolicyFetchInvalidPolicy); | 843 ExpectSample(kMetricPolicyFetchInvalidPolicy); |
845 EXPECT_TRUE(CheckSamples()); | 844 EXPECT_TRUE(CheckSamples()); |
846 } | 845 } |
847 | 846 |
848 #endif | 847 #endif |
849 | 848 |
850 } // namespace policy | 849 } // namespace policy |
OLD | NEW |