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/logging.h" | 6 #include "base/logging.h" |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" | 8 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" |
9 #include "chrome/browser/chromeos/login/wizard_controller.h" | 9 #include "chrome/browser/chromeos/login/wizard_controller.h" |
10 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" | 10 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h" |
11 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 11 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
12 #include "chrome/browser/policy/enterprise_metrics.h" | 12 #include "chrome/browser/policy/enterprise_metrics.h" |
13 #include "chrome/common/net/gaia/gaia_constants.h" | 13 #include "chrome/common/net/gaia/gaia_constants.h" |
14 #include "chrome/common/net/gaia/google_service_auth_error.h" | 14 #include "chrome/common/net/gaia/google_service_auth_error.h" |
15 #include "content/common/test_url_fetcher_factory.h" | 15 #include "content/test/test_url_fetcher_factory.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 void assert_handler(const std::string& str) { | 22 void assert_handler(const std::string& str) { |
23 LOG(INFO) << "Previous failure was expected, ignoring."; | 23 LOG(INFO) << "Previous failure was expected, ignoring."; |
24 } | 24 } |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 class EnterpriseMetricsEnrollmentTest : public WizardInProcessBrowserTest { | 28 class EnterpriseMetricsEnrollmentTest : public WizardInProcessBrowserTest { |
29 protected: | 29 protected: |
30 EnterpriseMetricsEnrollmentTest() | 30 EnterpriseMetricsEnrollmentTest() |
31 : WizardInProcessBrowserTest( | 31 : WizardInProcessBrowserTest( |
32 WizardController::kEnterpriseEnrollmentScreenName) {} | 32 WizardController::kEnterpriseEnrollmentScreenName) {} |
33 | 33 |
34 virtual void SetUpOnMainThread() OVERRIDE { | 34 virtual void SetUpOnMainThread() OVERRIDE { |
35 WizardInProcessBrowserTest::SetUpOnMainThread(); | 35 WizardInProcessBrowserTest::SetUpOnMainThread(); |
36 | 36 |
37 ASSERT_TRUE(controller() != NULL); | 37 ASSERT_TRUE(controller() != NULL); |
38 | 38 |
39 // Use mock URLFetchers. | |
40 URLFetcher::set_factory(&factory_); | |
41 | |
42 screen_ = controller()->GetEnterpriseEnrollmentScreen(); | 39 screen_ = controller()->GetEnterpriseEnrollmentScreen(); |
43 | 40 |
44 ASSERT_TRUE(screen_ != NULL); | 41 ASSERT_TRUE(screen_ != NULL); |
45 ASSERT_EQ(controller()->current_screen(), screen_); | 42 ASSERT_EQ(controller()->current_screen(), screen_); |
46 } | 43 } |
47 | 44 |
48 virtual void CleanUpOnMainThread() OVERRIDE { | 45 virtual void CleanUpOnMainThread() OVERRIDE { |
49 WizardInProcessBrowserTest::CleanUpOnMainThread(); | 46 WizardInProcessBrowserTest::CleanUpOnMainThread(); |
50 | 47 |
51 // Check that no other counters were sampled. | 48 // Check that no other counters were sampled. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 CheckSample(policy::kMetricEnrollmentNotSupported); | 161 CheckSample(policy::kMetricEnrollmentNotSupported); |
165 } | 162 } |
166 | 163 |
167 IN_PROC_BROWSER_TEST_F(EnterpriseMetricsEnrollmentTest, AuthErrorUnexpected) { | 164 IN_PROC_BROWSER_TEST_F(EnterpriseMetricsEnrollmentTest, AuthErrorUnexpected) { |
168 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); | 165 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); |
169 screen_->OnClientLoginFailure(error); | 166 screen_->OnClientLoginFailure(error); |
170 CheckSample(policy::kMetricEnrollmentNetworkFailed); | 167 CheckSample(policy::kMetricEnrollmentNetworkFailed); |
171 } | 168 } |
172 | 169 |
173 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |