OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const bool enroll_device; | 80 const bool enroll_device; |
81 }; | 81 }; |
82 | 82 |
83 class BlockingLoginTest | 83 class BlockingLoginTest |
84 : public InProcessBrowserTest, | 84 : public InProcessBrowserTest, |
85 public content::NotificationObserver, | 85 public content::NotificationObserver, |
86 public testing::WithParamInterface<BlockingLoginTestParam> { | 86 public testing::WithParamInterface<BlockingLoginTestParam> { |
87 public: | 87 public: |
88 BlockingLoginTest() : profile_added_(NULL) {} | 88 BlockingLoginTest() : profile_added_(NULL) {} |
89 | 89 |
90 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 90 virtual void SetUpCommandLine(CommandLine* command_line) override { |
91 // Initialize the test server early, so that we can use its base url for | 91 // Initialize the test server early, so that we can use its base url for |
92 // the command line flags. | 92 // the command line flags. |
93 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 93 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
94 | 94 |
95 // Use the login manager screens and the gaia auth extension. | 95 // Use the login manager screens and the gaia auth extension. |
96 command_line->AppendSwitch(switches::kLoginManager); | 96 command_line->AppendSwitch(switches::kLoginManager); |
97 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | 97 command_line->AppendSwitch(switches::kForceLoginManagerInTests); |
98 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 98 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
99 command_line->AppendSwitchASCII(::switches::kAuthExtensionPath, | 99 command_line->AppendSwitchASCII(::switches::kAuthExtensionPath, |
100 "gaia_auth"); | 100 "gaia_auth"); |
101 | 101 |
102 // Redirect requests to gaia and the policy server to the test server. | 102 // Redirect requests to gaia and the policy server to the test server. |
103 command_line->AppendSwitchASCII(::switches::kGaiaUrl, | 103 command_line->AppendSwitchASCII(::switches::kGaiaUrl, |
104 embedded_test_server()->base_url().spec()); | 104 embedded_test_server()->base_url().spec()); |
105 command_line->AppendSwitchASCII(::switches::kLsoUrl, | 105 command_line->AppendSwitchASCII(::switches::kLsoUrl, |
106 embedded_test_server()->base_url().spec()); | 106 embedded_test_server()->base_url().spec()); |
107 command_line->AppendSwitchASCII( | 107 command_line->AppendSwitchASCII( |
108 policy::switches::kDeviceManagementUrl, | 108 policy::switches::kDeviceManagementUrl, |
109 embedded_test_server()->GetURL("/device_management").spec()); | 109 embedded_test_server()->GetURL("/device_management").spec()); |
110 } | 110 } |
111 | 111 |
112 virtual void SetUpOnMainThread() OVERRIDE { | 112 virtual void SetUpOnMainThread() override { |
113 fake_gaia_.Initialize(); | 113 fake_gaia_.Initialize(); |
114 | 114 |
115 embedded_test_server()->RegisterRequestHandler( | 115 embedded_test_server()->RegisterRequestHandler( |
116 base::Bind(&BlockingLoginTest::HandleRequest, base::Unretained(this))); | 116 base::Bind(&BlockingLoginTest::HandleRequest, base::Unretained(this))); |
117 embedded_test_server()->RegisterRequestHandler( | 117 embedded_test_server()->RegisterRequestHandler( |
118 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); | 118 base::Bind(&FakeGaia::HandleRequest, base::Unretained(&fake_gaia_))); |
119 | 119 |
120 registrar_.Add(this, | 120 registrar_.Add(this, |
121 chrome::NOTIFICATION_PROFILE_ADDED, | 121 chrome::NOTIFICATION_PROFILE_ADDED, |
122 content::NotificationService::AllSources()); | 122 content::NotificationService::AllSources()); |
123 } | 123 } |
124 | 124 |
125 virtual void TearDownOnMainThread() OVERRIDE { | 125 virtual void TearDownOnMainThread() override { |
126 RunUntilIdle(); | 126 RunUntilIdle(); |
127 EXPECT_TRUE(responses_.empty()); | 127 EXPECT_TRUE(responses_.empty()); |
128 STLDeleteElements(&responses_); | 128 STLDeleteElements(&responses_); |
129 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 129 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
130 } | 130 } |
131 | 131 |
132 virtual void Observe(int type, | 132 virtual void Observe(int type, |
133 const content::NotificationSource& source, | 133 const content::NotificationSource& source, |
134 const content::NotificationDetails& details) OVERRIDE { | 134 const content::NotificationDetails& details) override { |
135 ASSERT_EQ(chrome::NOTIFICATION_PROFILE_ADDED, type); | 135 ASSERT_EQ(chrome::NOTIFICATION_PROFILE_ADDED, type); |
136 ASSERT_FALSE(profile_added_); | 136 ASSERT_FALSE(profile_added_); |
137 profile_added_ = content::Source<Profile>(source).ptr(); | 137 profile_added_ = content::Source<Profile>(source).ptr(); |
138 } | 138 } |
139 | 139 |
140 void RunUntilIdle() { | 140 void RunUntilIdle() { |
141 base::RunLoop().RunUntilIdle(); | 141 base::RunLoop().RunUntilIdle(); |
142 } | 142 } |
143 | 143 |
144 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector() { | 144 policy::BrowserPolicyConnectorChromeOS* browser_policy_connector() { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 { 3, kUsernameOtherDomain, true }, | 347 { 3, kUsernameOtherDomain, true }, |
348 { 4, kUsernameOtherDomain, true }, | 348 { 4, kUsernameOtherDomain, true }, |
349 { 5, kUsernameOtherDomain, true }, | 349 { 5, kUsernameOtherDomain, true }, |
350 }; | 350 }; |
351 | 351 |
352 INSTANTIATE_TEST_CASE_P(BlockingLoginTestInstance, | 352 INSTANTIATE_TEST_CASE_P(BlockingLoginTestInstance, |
353 BlockingLoginTest, | 353 BlockingLoginTest, |
354 testing::ValuesIn(kBlockinLoginTestCases)); | 354 testing::ValuesIn(kBlockinLoginTestCases)); |
355 | 355 |
356 } // namespace chromeos | 356 } // namespace chromeos |
OLD | NEW |