| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/system/chromeos/session/logout_confirmation_controller.h" | 11 #include "ash/system/chromeos/session/logout_confirmation_controller.h" |
| 12 #include "ash/system/chromeos/session/logout_confirmation_dialog.h" | 12 #include "ash/system/chromeos/session/logout_confirmation_dialog.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/files/scoped_temp_dir.h" |
| 20 #include "base/json/json_reader.h" | 21 #include "base/json/json_reader.h" |
| 21 #include "base/json/json_writer.h" | 22 #include "base/json/json_writer.h" |
| 22 #include "base/location.h" | 23 #include "base/location.h" |
| 23 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
| 24 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
| 25 #include "base/message_loop/message_loop.h" | 26 #include "base/message_loop/message_loop.h" |
| 26 #include "base/message_loop/message_loop_proxy.h" | 27 #include "base/message_loop/message_loop_proxy.h" |
| 27 #include "base/path_service.h" | 28 #include "base/path_service.h" |
| 28 #include "base/prefs/pref_service.h" | 29 #include "base/prefs/pref_service.h" |
| 29 #include "base/run_loop.h" | 30 #include "base/run_loop.h" |
| 30 #include "base/sequenced_task_runner.h" | 31 #include "base/sequenced_task_runner.h" |
| 31 #include "base/strings/string_number_conversions.h" | 32 #include "base/strings/string_number_conversions.h" |
| 32 #include "base/strings/string_util.h" | 33 #include "base/strings/string_util.h" |
| 33 #include "base/strings/stringprintf.h" | 34 #include "base/strings/stringprintf.h" |
| 34 #include "base/strings/utf_string_conversions.h" | 35 #include "base/strings/utf_string_conversions.h" |
| 36 #include "base/test/scoped_path_override.h" |
| 35 #include "base/values.h" | 37 #include "base/values.h" |
| 36 #include "chrome/browser/browser_process.h" | 38 #include "chrome/browser/browser_process.h" |
| 37 #include "chrome/browser/chrome_notification_types.h" | 39 #include "chrome/browser/chrome_notification_types.h" |
| 38 #include "chrome/browser/chromeos/login/auth/mock_login_status_consumer.h" | 40 #include "chrome/browser/chromeos/login/auth/mock_login_status_consumer.h" |
| 39 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 41 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 40 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" | 42 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" |
| 41 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 43 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 42 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 44 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 43 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 45 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 44 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" | 46 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // Configure and start the test server. | 304 // Configure and start the test server. |
| 303 scoped_ptr<crypto::RSAPrivateKey> signing_key( | 305 scoped_ptr<crypto::RSAPrivateKey> signing_key( |
| 304 PolicyBuilder::CreateTestSigningKey()); | 306 PolicyBuilder::CreateTestSigningKey()); |
| 305 ASSERT_TRUE(test_server_.SetSigningKeyAndSignature( | 307 ASSERT_TRUE(test_server_.SetSigningKeyAndSignature( |
| 306 signing_key.get(), PolicyBuilder::GetTestSigningKeySignature())); | 308 signing_key.get(), PolicyBuilder::GetTestSigningKeySignature())); |
| 307 signing_key.reset(); | 309 signing_key.reset(); |
| 308 test_server_.RegisterClient(PolicyBuilder::kFakeToken, | 310 test_server_.RegisterClient(PolicyBuilder::kFakeToken, |
| 309 PolicyBuilder::kFakeDeviceId); | 311 PolicyBuilder::kFakeDeviceId); |
| 310 ASSERT_TRUE(test_server_.Start()); | 312 ASSERT_TRUE(test_server_.Start()); |
| 311 | 313 |
| 314 ASSERT_TRUE(extension_cache_root_dir_.CreateUniqueTempDir()); |
| 315 extension_cache_root_dir_override_.reset(new base::ScopedPathOverride( |
| 316 chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, |
| 317 extension_cache_root_dir_.path())); |
| 318 ASSERT_TRUE(external_data_cache_dir_.CreateUniqueTempDir()); |
| 319 external_data_cache_dir_override_.reset(new base::ScopedPathOverride( |
| 320 chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTERNAL_DATA, |
| 321 external_data_cache_dir_.path())); |
| 322 |
| 312 BrowserList::AddObserver(this); | 323 BrowserList::AddObserver(this); |
| 313 | 324 |
| 314 DevicePolicyCrosBrowserTest::SetUp(); | 325 DevicePolicyCrosBrowserTest::SetUp(); |
| 315 } | 326 } |
| 316 | 327 |
| 317 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 328 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 318 DevicePolicyCrosBrowserTest::SetUpCommandLine(command_line); | 329 DevicePolicyCrosBrowserTest::SetUpCommandLine(command_line); |
| 319 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 330 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 320 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 331 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 321 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 332 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 426 } |
| 416 | 427 |
| 417 void CheckPublicSessionPresent(const std::string& id) { | 428 void CheckPublicSessionPresent(const std::string& id) { |
| 418 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); | 429 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(id); |
| 419 ASSERT_TRUE(user); | 430 ASSERT_TRUE(user); |
| 420 EXPECT_EQ(id, user->email()); | 431 EXPECT_EQ(id, user->email()); |
| 421 EXPECT_EQ(chromeos::User::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); | 432 EXPECT_EQ(chromeos::User::USER_TYPE_PUBLIC_ACCOUNT, user->GetType()); |
| 422 } | 433 } |
| 423 | 434 |
| 424 base::FilePath GetCacheDirectoryForAccountID(const std::string& account_id) { | 435 base::FilePath GetCacheDirectoryForAccountID(const std::string& account_id) { |
| 425 base::FilePath extension_cache_root_dir; | 436 return extension_cache_root_dir_.path() |
| 426 PathService::Get(chromeos::DIR_DEVICE_LOCAL_ACCOUNT_EXTENSIONS, | 437 .Append(base::HexEncode(account_id.c_str(), account_id.size())); |
| 427 &extension_cache_root_dir); | |
| 428 return extension_cache_root_dir.Append( | |
| 429 base::HexEncode(account_id.c_str(), account_id.size())); | |
| 430 } | 438 } |
| 431 | 439 |
| 432 base::FilePath GetCacheCRXFile(const std::string& account_id, | 440 base::FilePath GetCacheCRXFile(const std::string& account_id, |
| 433 const std::string& id, | 441 const std::string& id, |
| 434 const std::string& version) { | 442 const std::string& version) { |
| 435 return GetCacheDirectoryForAccountID(account_id) | 443 return GetCacheDirectoryForAccountID(account_id) |
| 436 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str())); | 444 .Append(base::StringPrintf("%s-%s.crx", id.c_str(), version.c_str())); |
| 437 } | 445 } |
| 438 | 446 |
| 439 // Returns a profile which can be used for testing. | 447 // Returns a profile which can be used for testing. |
| 440 Profile* GetProfileForTest() { | 448 Profile* GetProfileForTest() { |
| 441 // Any profile can be used here since this test does not test multi profile. | 449 // Any profile can be used here since this test does not test multi profile. |
| 442 return ProfileManager::GetActiveUserProfile(); | 450 return ProfileManager::GetActiveUserProfile(); |
| 443 } | 451 } |
| 444 | 452 |
| 445 const std::string user_id_1_; | 453 const std::string user_id_1_; |
| 446 const std::string user_id_2_; | 454 const std::string user_id_2_; |
| 447 | 455 |
| 448 scoped_ptr<base::RunLoop> run_loop_; | 456 scoped_ptr<base::RunLoop> run_loop_; |
| 449 | 457 |
| 450 UserPolicyBuilder device_local_account_policy_; | 458 UserPolicyBuilder device_local_account_policy_; |
| 451 LocalPolicyTestServer test_server_; | 459 LocalPolicyTestServer test_server_; |
| 452 | 460 |
| 453 private: | 461 private: |
| 462 base::ScopedTempDir extension_cache_root_dir_; |
| 463 base::ScopedTempDir external_data_cache_dir_; |
| 464 scoped_ptr<base::ScopedPathOverride> extension_cache_root_dir_override_; |
| 465 scoped_ptr<base::ScopedPathOverride> external_data_cache_dir_override_; |
| 466 |
| 454 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); | 467 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); |
| 455 }; | 468 }; |
| 456 | 469 |
| 457 static bool IsKnownUser(const std::string& account_id) { | 470 static bool IsKnownUser(const std::string& account_id) { |
| 458 return chromeos::UserManager::Get()->IsKnownUser(account_id); | 471 return chromeos::UserManager::Get()->IsKnownUser(account_id); |
| 459 } | 472 } |
| 460 | 473 |
| 461 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { | 474 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) { |
| 462 AddPublicSessionToDevicePolicy(kAccountId1); | 475 AddPublicSessionToDevicePolicy(kAccountId1); |
| 463 AddPublicSessionToDevicePolicy(kAccountId2); | 476 AddPublicSessionToDevicePolicy(kAccountId2); |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 if (!IsSessionStarted()) { | 1394 if (!IsSessionStarted()) { |
| 1382 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, | 1395 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, |
| 1383 base::Bind(IsSessionStarted)).Wait(); | 1396 base::Bind(IsSessionStarted)).Wait(); |
| 1384 } | 1397 } |
| 1385 } | 1398 } |
| 1386 | 1399 |
| 1387 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, | 1400 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, |
| 1388 TermsOfServiceTest, testing::Bool()); | 1401 TermsOfServiceTest, testing::Bool()); |
| 1389 | 1402 |
| 1390 } // namespace policy | 1403 } // namespace policy |
| OLD | NEW |