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