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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/login_manager_test.h" | 9 #include "chrome/browser/chromeos/login/login_manager_test.h" |
10 #include "chrome/browser/chromeos/login/startup_utils.h" | 10 #include "chrome/browser/chromeos/login/startup_utils.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 base::RunLoop().RunUntilIdle(); | 91 base::RunLoop().RunUntilIdle(); |
92 } | 92 } |
93 | 93 |
94 #if defined(GOOGLE_CHROME_BUILD) | 94 #if defined(GOOGLE_CHROME_BUILD) |
95 bool HasEasyUnlockApp() const { | 95 bool HasEasyUnlockApp() const { |
96 return HasEasyUnlockAppForProfile(profile()); | 96 return HasEasyUnlockAppForProfile(profile()); |
97 } | 97 } |
98 #endif | 98 #endif |
99 | 99 |
100 // InProcessBrowserTest: | 100 // InProcessBrowserTest: |
101 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 101 virtual void SetUpInProcessBrowserTestFixture() override { |
102 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 102 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
103 .WillRepeatedly(Return(true)); | 103 .WillRepeatedly(Return(true)); |
104 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 104 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
105 | 105 |
106 mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>(); | 106 mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>(); |
107 SetUpBluetoothMock(mock_adapter_, is_bluetooth_adapter_present_); | 107 SetUpBluetoothMock(mock_adapter_, is_bluetooth_adapter_present_); |
108 | 108 |
109 scoped_ptr<DBusThreadManagerSetter> dbus_setter = | 109 scoped_ptr<DBusThreadManagerSetter> dbus_setter = |
110 chromeos::DBusThreadManager::GetSetterForTesting(); | 110 chromeos::DBusThreadManager::GetSetterForTesting(); |
111 power_manager_client_ = new FakePowerManagerClient; | 111 power_manager_client_ = new FakePowerManagerClient; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 EXPECT_TRUE(HasEasyUnlockApp()); | 153 EXPECT_TRUE(HasEasyUnlockApp()); |
154 } | 154 } |
155 #endif | 155 #endif |
156 | 156 |
157 class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest { | 157 class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest { |
158 public: | 158 public: |
159 EasyUnlockServiceNoBluetoothTest() {} | 159 EasyUnlockServiceNoBluetoothTest() {} |
160 virtual ~EasyUnlockServiceNoBluetoothTest() {} | 160 virtual ~EasyUnlockServiceNoBluetoothTest() {} |
161 | 161 |
162 // InProcessBrowserTest: | 162 // InProcessBrowserTest: |
163 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 163 virtual void SetUpInProcessBrowserTestFixture() override { |
164 set_is_bluetooth_adapter_present(false); | 164 set_is_bluetooth_adapter_present(false); |
165 EasyUnlockServiceTest::SetUpInProcessBrowserTestFixture(); | 165 EasyUnlockServiceTest::SetUpInProcessBrowserTestFixture(); |
166 } | 166 } |
167 | 167 |
168 private: | 168 private: |
169 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceNoBluetoothTest); | 169 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceNoBluetoothTest); |
170 }; | 170 }; |
171 | 171 |
172 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceNoBluetoothTest, NoService) { | 172 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceNoBluetoothTest, NoService) { |
173 EXPECT_FALSE(service()->IsAllowed()); | 173 EXPECT_FALSE(service()->IsAllowed()); |
174 #if defined(GOOGLE_CHROME_BUILD) | 174 #if defined(GOOGLE_CHROME_BUILD) |
175 EXPECT_FALSE(HasEasyUnlockApp()); | 175 EXPECT_FALSE(HasEasyUnlockApp()); |
176 #endif | 176 #endif |
177 } | 177 } |
178 | 178 |
179 class EasyUnlockServiceFinchEnabledTest : public EasyUnlockServiceTest { | 179 class EasyUnlockServiceFinchEnabledTest : public EasyUnlockServiceTest { |
180 public: | 180 public: |
181 EasyUnlockServiceFinchEnabledTest() {} | 181 EasyUnlockServiceFinchEnabledTest() {} |
182 virtual ~EasyUnlockServiceFinchEnabledTest() {} | 182 virtual ~EasyUnlockServiceFinchEnabledTest() {} |
183 | 183 |
184 // InProcessBrowserTest: | 184 // InProcessBrowserTest: |
185 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 185 virtual void SetUpCommandLine(CommandLine* command_line) override { |
186 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 186 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
187 "EasyUnlock/Enable/"); | 187 "EasyUnlock/Enable/"); |
188 } | 188 } |
189 | 189 |
190 private: | 190 private: |
191 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceFinchEnabledTest); | 191 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceFinchEnabledTest); |
192 }; | 192 }; |
193 | 193 |
194 // Tests that policy can override finch to turn easy unlock off. | 194 // Tests that policy can override finch to turn easy unlock off. |
195 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceFinchEnabledTest, PolicyOveride) { | 195 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceFinchEnabledTest, PolicyOveride) { |
(...skipping 15 matching lines...) Expand all Loading... |
211 EXPECT_TRUE(HasEasyUnlockApp()); | 211 EXPECT_TRUE(HasEasyUnlockApp()); |
212 #endif | 212 #endif |
213 } | 213 } |
214 | 214 |
215 class EasyUnlockServiceFinchDisabledTest : public EasyUnlockServiceTest { | 215 class EasyUnlockServiceFinchDisabledTest : public EasyUnlockServiceTest { |
216 public: | 216 public: |
217 EasyUnlockServiceFinchDisabledTest() {} | 217 EasyUnlockServiceFinchDisabledTest() {} |
218 virtual ~EasyUnlockServiceFinchDisabledTest() {} | 218 virtual ~EasyUnlockServiceFinchDisabledTest() {} |
219 | 219 |
220 // InProcessBrowserTest: | 220 // InProcessBrowserTest: |
221 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 221 virtual void SetUpCommandLine(CommandLine* command_line) override { |
222 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 222 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
223 "EasyUnlock/Disable/"); | 223 "EasyUnlock/Disable/"); |
224 } | 224 } |
225 | 225 |
226 private: | 226 private: |
227 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceFinchDisabledTest); | 227 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceFinchDisabledTest); |
228 }; | 228 }; |
229 | 229 |
230 // Tests that easy unlock is off when finch is disabled and policy overrides | 230 // Tests that easy unlock is off when finch is disabled and policy overrides |
231 // finch. | 231 // finch. |
(...skipping 11 matching lines...) Expand all Loading... |
243 EXPECT_TRUE(HasEasyUnlockApp()); | 243 EXPECT_TRUE(HasEasyUnlockApp()); |
244 #endif | 244 #endif |
245 } | 245 } |
246 | 246 |
247 class EasyUnlockServiceMultiProfileTest : public LoginManagerTest { | 247 class EasyUnlockServiceMultiProfileTest : public LoginManagerTest { |
248 public: | 248 public: |
249 EasyUnlockServiceMultiProfileTest() : LoginManagerTest(false) {} | 249 EasyUnlockServiceMultiProfileTest() : LoginManagerTest(false) {} |
250 virtual ~EasyUnlockServiceMultiProfileTest() {} | 250 virtual ~EasyUnlockServiceMultiProfileTest() {} |
251 | 251 |
252 // InProcessBrowserTest: | 252 // InProcessBrowserTest: |
253 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 253 virtual void SetUpInProcessBrowserTestFixture() override { |
254 LoginManagerTest::SetUpInProcessBrowserTestFixture(); | 254 LoginManagerTest::SetUpInProcessBrowserTestFixture(); |
255 | 255 |
256 mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>(); | 256 mock_adapter_ = new testing::NiceMock<MockBluetoothAdapter>(); |
257 SetUpBluetoothMock(mock_adapter_, true); | 257 SetUpBluetoothMock(mock_adapter_, true); |
258 } | 258 } |
259 | 259 |
260 private: | 260 private: |
261 scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_; | 261 scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_; |
262 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceMultiProfileTest); | 262 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceMultiProfileTest); |
263 }; | 263 }; |
(...skipping 21 matching lines...) Expand all Loading... |
285 Profile* secondary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( | 285 Profile* secondary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( |
286 secondary_user->username_hash()); | 286 secondary_user->username_hash()); |
287 | 287 |
288 EXPECT_TRUE(EasyUnlockService::Get(primary_profile)->IsAllowed()); | 288 EXPECT_TRUE(EasyUnlockService::Get(primary_profile)->IsAllowed()); |
289 EXPECT_FALSE(EasyUnlockService::Get(secondary_profile)->IsAllowed()); | 289 EXPECT_FALSE(EasyUnlockService::Get(secondary_profile)->IsAllowed()); |
290 #if defined(GOOGLE_CHROME_BUILD) | 290 #if defined(GOOGLE_CHROME_BUILD) |
291 EXPECT_TRUE(HasEasyUnlockAppForProfile(primary_profile)); | 291 EXPECT_TRUE(HasEasyUnlockAppForProfile(primary_profile)); |
292 EXPECT_FALSE(HasEasyUnlockAppForProfile(secondary_profile)); | 292 EXPECT_FALSE(HasEasyUnlockAppForProfile(secondary_profile)); |
293 #endif | 293 #endif |
294 } | 294 } |
OLD | NEW |