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 "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 9 #include "ash/desktop_background/desktop_background_controller_observer.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "chrome/browser/chromeos/login/startup_utils.h" | 21 #include "chrome/browser/chromeos/login/startup_utils.h" |
22 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 22 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
23 #include "chrome/browser/chromeos/login/users/user.h" | 23 #include "chrome/browser/chromeos/login/users/user.h" |
24 #include "chrome/browser/chromeos/login/users/user_manager.h" | 24 #include "chrome/browser/chromeos/login/users/user_manager.h" |
25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 25 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u til.h" | 26 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base_test_u til.h" |
27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" | 28 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" |
29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
Nikita (slow)
2014/05/19 14:27:15
nit: not used
| |
32 #include "chromeos/chromeos_paths.h" | 32 #include "chromeos/chromeos_paths.h" |
33 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
34 #include "chromeos/dbus/cryptohome_client.h" | 34 #include "chromeos/dbus/cryptohome_client.h" |
35 #include "chromeos/dbus/dbus_thread_manager.h" | 35 #include "chromeos/dbus/dbus_thread_manager.h" |
36 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 36 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
37 #include "chromeos/dbus/fake_session_manager_client.h" | 37 #include "chromeos/dbus/fake_session_manager_client.h" |
38 #include "chromeos/dbus/session_manager_client.h" | 38 #include "chromeos/dbus/session_manager_client.h" |
39 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 39 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
40 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
41 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 41 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 } | 124 } |
125 | 125 |
126 const SkBitmap& bitmap = representation.sk_bitmap(); | 126 const SkBitmap& bitmap = representation.sk_bitmap(); |
127 return ComputeAverageColor(bitmap); | 127 return ComputeAverageColor(bitmap); |
128 } | 128 } |
129 | 129 |
130 } // namespace | 130 } // namespace |
131 | 131 |
132 class WallpaperManagerPolicyTest | 132 class WallpaperManagerPolicyTest |
133 : public LoginManagerTest, | 133 : public LoginManagerTest, |
134 public ash::DesktopBackgroundControllerObserver, | 134 public ash::DesktopBackgroundControllerObserver { |
135 public testing::WithParamInterface<bool> { | |
136 protected: | 135 protected: |
137 WallpaperManagerPolicyTest() | 136 WallpaperManagerPolicyTest() |
138 : LoginManagerTest(true), | 137 : LoginManagerTest(true), |
139 wallpaper_change_count_(0), | 138 wallpaper_change_count_(0), |
140 fake_dbus_thread_manager_(new FakeDBusThreadManager), | 139 fake_dbus_thread_manager_(new FakeDBusThreadManager), |
141 fake_session_manager_client_(new FakeSessionManagerClient) { | 140 fake_session_manager_client_(new FakeSessionManagerClient) { |
142 fake_dbus_thread_manager_->SetFakeClients(); | 141 fake_dbus_thread_manager_->SetFakeClients(); |
143 fake_dbus_thread_manager_->SetSessionManagerClient( | 142 fake_dbus_thread_manager_->SetSessionManagerClient( |
144 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | 143 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
145 } | 144 } |
(...skipping 29 matching lines...) Expand all Loading... | |
175 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); | 174 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); |
176 } | 175 } |
177 | 176 |
178 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 177 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
179 // Set the same switches as LoginManagerTest, except that kMultiProfiles is | 178 // Set the same switches as LoginManagerTest, except that kMultiProfiles is |
180 // only set when GetParam() is true and except that kLoginProfile is set | 179 // only set when GetParam() is true and except that kLoginProfile is set |
181 // when GetParam() is false. The latter seems to be required for the sane | 180 // when GetParam() is false. The latter seems to be required for the sane |
182 // start-up of user profiles. | 181 // start-up of user profiles. |
183 command_line->AppendSwitch(switches::kLoginManager); | 182 command_line->AppendSwitch(switches::kLoginManager); |
184 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | 183 command_line->AppendSwitch(switches::kForceLoginManagerInTests); |
185 if (GetParam()) | |
186 command_line->AppendSwitch(::switches::kMultiProfiles); | |
187 else | |
188 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | |
189 } | 184 } |
190 | 185 |
191 virtual void SetUpOnMainThread() OVERRIDE { | 186 virtual void SetUpOnMainThread() OVERRIDE { |
192 LoginManagerTest::SetUpOnMainThread(); | 187 LoginManagerTest::SetUpOnMainThread(); |
193 ash::Shell::GetInstance()-> | 188 ash::Shell::GetInstance()-> |
194 desktop_background_controller()->AddObserver(this); | 189 desktop_background_controller()->AddObserver(this); |
195 | 190 |
196 // Set up policy signing. | 191 // Set up policy signing. |
197 user_policy_builders_[0] = GetUserPolicyBuilder(kTestUsers[0]); | 192 user_policy_builders_[0] = GetUserPolicyBuilder(kTestUsers[0]); |
198 user_policy_builders_[1] = GetUserPolicyBuilder(kTestUsers[1]); | 193 user_policy_builders_[1] = GetUserPolicyBuilder(kTestUsers[1]); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 scoped_ptr<base::RunLoop> run_loop_; | 265 scoped_ptr<base::RunLoop> run_loop_; |
271 int wallpaper_change_count_; | 266 int wallpaper_change_count_; |
272 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; | 267 scoped_ptr<policy::UserPolicyBuilder> user_policy_builders_[2]; |
273 FakeDBusThreadManager* fake_dbus_thread_manager_; | 268 FakeDBusThreadManager* fake_dbus_thread_manager_; |
274 FakeSessionManagerClient* fake_session_manager_client_; | 269 FakeSessionManagerClient* fake_session_manager_client_; |
275 | 270 |
276 private: | 271 private: |
277 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); | 272 DISALLOW_COPY_AND_ASSIGN(WallpaperManagerPolicyTest); |
278 }; | 273 }; |
279 | 274 |
280 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_SetResetClear) { | 275 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_SetResetClear) { |
281 RegisterUser(kTestUsers[0]); | 276 RegisterUser(kTestUsers[0]); |
282 RegisterUser(kTestUsers[1]); | 277 RegisterUser(kTestUsers[1]); |
283 StartupUtils::MarkOobeCompleted(); | 278 StartupUtils::MarkOobeCompleted(); |
284 } | 279 } |
285 | 280 |
286 // Verifies that the wallpaper can be set and re-set through policy and that | 281 // Verifies that the wallpaper can be set and re-set through policy and that |
287 // setting policy for a user that is not logged in doesn't affect the current | 282 // setting policy for a user that is not logged in doesn't affect the current |
288 // user. Also verifies that after the policy has been cleared, the wallpaper | 283 // user. Also verifies that after the policy has been cleared, the wallpaper |
289 // reverts to default. | 284 // reverts to default. |
290 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, SetResetClear) { | 285 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, SetResetClear) { |
291 WallpaperInfo info; | 286 WallpaperInfo info; |
292 LoginUser(kTestUsers[0]); | 287 LoginUser(kTestUsers[0]); |
293 base::RunLoop().RunUntilIdle(); | 288 base::RunLoop().RunUntilIdle(); |
294 | 289 |
295 // First user: Wait until default wallpaper has been loaded (happens | 290 // First user: Wait until default wallpaper has been loaded (happens |
296 // automatically) and store color to recognize it later. | 291 // automatically) and store color to recognize it later. |
297 RunUntilWallpaperChangeCount(1); | 292 RunUntilWallpaperChangeCount(1); |
298 const SkColor original_background_color = GetAverageBackgroundColor(); | 293 const SkColor original_background_color = GetAverageBackgroundColor(); |
299 | 294 |
300 // Second user: Set wallpaper policy to blue image. This should not result in | 295 // Second user: Set wallpaper policy to blue image. This should not result in |
(...skipping 20 matching lines...) Expand all Loading... | |
321 RunUntilWallpaperChangeCount(4); | 316 RunUntilWallpaperChangeCount(4); |
322 GetUserWallpaperInfo(0, &info); | 317 GetUserWallpaperInfo(0, &info); |
323 ASSERT_EQ(User::DEFAULT, info.type); | 318 ASSERT_EQ(User::DEFAULT, info.type); |
324 ASSERT_EQ(original_background_color, GetAverageBackgroundColor()); | 319 ASSERT_EQ(original_background_color, GetAverageBackgroundColor()); |
325 | 320 |
326 // Check wallpaper change count to ensure that setting the second user's | 321 // Check wallpaper change count to ensure that setting the second user's |
327 // wallpaper didn't have any effect. | 322 // wallpaper didn't have any effect. |
328 ASSERT_EQ(4, wallpaper_change_count_); | 323 ASSERT_EQ(4, wallpaper_change_count_); |
329 } | 324 } |
330 | 325 |
331 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, | 326 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, |
332 PRE_PRE_PRE_WallpaperOnLoginScreen) { | 327 PRE_PRE_PRE_WallpaperOnLoginScreen) { |
333 RegisterUser(kTestUsers[0]); | 328 RegisterUser(kTestUsers[0]); |
334 RegisterUser(kTestUsers[1]); | 329 RegisterUser(kTestUsers[1]); |
335 StartupUtils::MarkOobeCompleted(); | 330 StartupUtils::MarkOobeCompleted(); |
336 } | 331 } |
337 | 332 |
338 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, | 333 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, |
339 PRE_PRE_WallpaperOnLoginScreen) { | 334 PRE_PRE_WallpaperOnLoginScreen) { |
340 LoginUser(kTestUsers[0]); | 335 LoginUser(kTestUsers[0]); |
341 | 336 |
342 // Wait until default wallpaper has been loaded. | 337 // Wait until default wallpaper has been loaded. |
343 RunUntilWallpaperChangeCount(1); | 338 RunUntilWallpaperChangeCount(1); |
344 | 339 |
345 // Set wallpaper policy to red image. | 340 // Set wallpaper policy to red image. |
346 InjectPolicy(0, kRedImageFileName); | 341 InjectPolicy(0, kRedImageFileName); |
347 | 342 |
348 // Run until wallpaper has changed. | 343 // Run until wallpaper has changed. |
349 RunUntilWallpaperChangeCount(2); | 344 RunUntilWallpaperChangeCount(2); |
350 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 345 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
351 } | 346 } |
352 | 347 |
353 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_WallpaperOnLoginScreen) { | 348 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_WallpaperOnLoginScreen) { |
354 LoginUser(kTestUsers[1]); | 349 LoginUser(kTestUsers[1]); |
355 | 350 |
356 // Wait until default wallpaper has been loaded. | 351 // Wait until default wallpaper has been loaded. |
357 RunUntilWallpaperChangeCount(1); | 352 RunUntilWallpaperChangeCount(1); |
358 | 353 |
359 // Set wallpaper policy to green image. | 354 // Set wallpaper policy to green image. |
360 InjectPolicy(1, kGreenImageFileName); | 355 InjectPolicy(1, kGreenImageFileName); |
361 | 356 |
362 // Run until wallpaper has changed. | 357 // Run until wallpaper has changed. |
363 RunUntilWallpaperChangeCount(2); | 358 RunUntilWallpaperChangeCount(2); |
364 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); | 359 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); |
365 } | 360 } |
366 | 361 |
367 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, WallpaperOnLoginScreen) { | 362 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, WallpaperOnLoginScreen) { |
368 // Wait for active pod's wallpaper to be loaded. | 363 // Wait for active pod's wallpaper to be loaded. |
369 RunUntilWallpaperChangeCount(1); | 364 RunUntilWallpaperChangeCount(1); |
370 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); | 365 ASSERT_EQ(kGreenImageColor, GetAverageBackgroundColor()); |
371 | 366 |
372 // Select the second pod (belonging to user 1). | 367 // Select the second pod (belonging to user 1). |
373 ASSERT_TRUE(content::ExecuteScript( | 368 ASSERT_TRUE(content::ExecuteScript( |
374 static_cast<chromeos::LoginDisplayHostImpl*>( | 369 static_cast<chromeos::LoginDisplayHostImpl*>( |
375 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()-> | 370 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()-> |
376 web_ui()->GetWebContents(), | 371 web_ui()->GetWebContents(), |
377 "document.getElementsByClassName('pod')[1].focus();")); | 372 "document.getElementsByClassName('pod')[1].focus();")); |
378 RunUntilWallpaperChangeCount(2); | 373 RunUntilWallpaperChangeCount(2); |
379 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 374 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
380 } | 375 } |
381 | 376 |
382 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { | 377 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PRE_PersistOverLogout) { |
383 RegisterUser(kTestUsers[0]); | 378 RegisterUser(kTestUsers[0]); |
384 StartupUtils::MarkOobeCompleted(); | 379 StartupUtils::MarkOobeCompleted(); |
385 } | 380 } |
386 | 381 |
387 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { | 382 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PRE_PersistOverLogout) { |
388 LoginUser(kTestUsers[0]); | 383 LoginUser(kTestUsers[0]); |
389 | 384 |
390 // Wait until default wallpaper has been loaded. | 385 // Wait until default wallpaper has been loaded. |
391 RunUntilWallpaperChangeCount(1); | 386 RunUntilWallpaperChangeCount(1); |
392 | 387 |
393 // Set wallpaper policy to red image. | 388 // Set wallpaper policy to red image. |
394 InjectPolicy(0, kRedImageFileName); | 389 InjectPolicy(0, kRedImageFileName); |
395 | 390 |
396 // Run until wallpaper has changed. | 391 // Run until wallpaper has changed. |
397 RunUntilWallpaperChangeCount(2); | 392 RunUntilWallpaperChangeCount(2); |
398 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 393 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
399 } | 394 } |
400 | 395 |
401 IN_PROC_BROWSER_TEST_P(WallpaperManagerPolicyTest, PersistOverLogout) { | 396 IN_PROC_BROWSER_TEST_F(WallpaperManagerPolicyTest, PersistOverLogout) { |
402 LoginUser(kTestUsers[0]); | 397 LoginUser(kTestUsers[0]); |
403 | 398 |
404 // Wait until wallpaper has been loaded. | 399 // Wait until wallpaper has been loaded. |
405 RunUntilWallpaperChangeCount(1); | 400 RunUntilWallpaperChangeCount(1); |
406 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); | 401 ASSERT_EQ(kRedImageColor, GetAverageBackgroundColor()); |
407 } | 402 } |
408 | 403 |
409 INSTANTIATE_TEST_CASE_P(WallpaperManagerPolicyTestInstantiation, | |
410 WallpaperManagerPolicyTest, testing::Bool()); | |
411 | |
412 } // namespace chromeos | 404 } // namespace chromeos |
OLD | NEW |