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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 ASSERT_TRUE(PathService::Override(chromeos::FILE_INSTALL_ATTRIBUTES, | 465 ASSERT_TRUE(PathService::Override(chromeos::FILE_INSTALL_ATTRIBUTES, |
466 install_attrs_file)); | 466 install_attrs_file)); |
467 } | 467 } |
468 | 468 |
469 void SetUpPolicy() { | 469 void SetUpPolicy() { |
470 // Configure two device-local accounts in device settings. | 470 // Configure two device-local accounts in device settings. |
471 DevicePolicyBuilder device_policy; | 471 DevicePolicyBuilder device_policy; |
472 device_policy.policy_data().set_public_key_version(1); | 472 device_policy.policy_data().set_public_key_version(1); |
473 em::ChromeDeviceSettingsProto& proto(device_policy.payload()); | 473 em::ChromeDeviceSettingsProto& proto(device_policy.payload()); |
474 proto.mutable_show_user_names()->set_show_user_names(true); | 474 proto.mutable_show_user_names()->set_show_user_names(true); |
475 proto.mutable_device_local_accounts()->add_account()->set_id(kAccountId1); | 475 em::DeviceLocalAccountInfoProto* account1 = |
476 proto.mutable_device_local_accounts()->add_account()->set_id(kAccountId2); | 476 proto.mutable_device_local_accounts()->add_account(); |
| 477 account1->set_account_id(kAccountId1); |
| 478 account1->set_type( |
| 479 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
| 480 em::DeviceLocalAccountInfoProto* account2 = |
| 481 proto.mutable_device_local_accounts()->add_account(); |
| 482 account2->set_account_id(kAccountId2); |
| 483 account2->set_type( |
| 484 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
477 device_policy.Build(); | 485 device_policy.Build(); |
478 session_manager_client_.set_device_policy(device_policy.GetBlob()); | 486 session_manager_client_.set_device_policy(device_policy.GetBlob()); |
479 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, | 487 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, |
480 std::string(), proto.SerializeAsString()); | 488 std::string(), proto.SerializeAsString()); |
481 | 489 |
482 // Install the owner key. | 490 // Install the owner key. |
483 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); | 491 base::FilePath owner_key_file = temp_dir_.path().AppendASCII("owner.key"); |
484 std::vector<uint8> owner_key_bits; | 492 std::vector<uint8> owner_key_bits; |
485 ASSERT_TRUE(device_policy.signing_key()->ExportPublicKey(&owner_key_bits)); | 493 ASSERT_TRUE(device_policy.signing_key()->ExportPublicKey(&owner_key_bits)); |
486 ASSERT_EQ( | 494 ASSERT_EQ( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DevicePolicyChange) { | 601 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DevicePolicyChange) { |
594 // Wait until the login screen is up. | 602 // Wait until the login screen is up. |
595 NotificationWatcher(chrome::NOTIFICATION_USER_LIST_CHANGED, | 603 NotificationWatcher(chrome::NOTIFICATION_USER_LIST_CHANGED, |
596 base::Bind(&IsKnownUser, kAccountId1)).Run(); | 604 base::Bind(&IsKnownUser, kAccountId1)).Run(); |
597 NotificationWatcher(chrome::NOTIFICATION_USER_LIST_CHANGED, | 605 NotificationWatcher(chrome::NOTIFICATION_USER_LIST_CHANGED, |
598 base::Bind(&IsKnownUser, kAccountId2)).Run(); | 606 base::Bind(&IsKnownUser, kAccountId2)).Run(); |
599 | 607 |
600 // Update policy to remove kAccountId2. | 608 // Update policy to remove kAccountId2. |
601 em::ChromeDeviceSettingsProto policy; | 609 em::ChromeDeviceSettingsProto policy; |
602 policy.mutable_show_user_names()->set_show_user_names(true); | 610 policy.mutable_show_user_names()->set_show_user_names(true); |
603 policy.mutable_device_local_accounts()->add_account()->set_id(kAccountId1); | 611 em::DeviceLocalAccountInfoProto* account1 = |
| 612 policy.mutable_device_local_accounts()->add_account(); |
| 613 account1->set_account_id(kAccountId1); |
| 614 account1->set_type( |
| 615 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
604 | 616 |
605 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), | 617 test_server_.UpdatePolicy(dm_protocol::kChromeDevicePolicyType, std::string(), |
606 policy.SerializeAsString()); | 618 policy.SerializeAsString()); |
607 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); | 619 g_browser_process->policy_service()->RefreshPolicies(base::Closure()); |
608 | 620 |
609 // Make sure the second device-local account disappears. | 621 // Make sure the second device-local account disappears. |
610 NotificationWatcher(chrome::NOTIFICATION_USER_LIST_CHANGED, | 622 NotificationWatcher(chrome::NOTIFICATION_USER_LIST_CHANGED, |
611 base::Bind(&IsNotKnownUser, kAccountId2)).Run(); | 623 base::Bind(&IsNotKnownUser, kAccountId2)).Run(); |
612 } | 624 } |
613 | 625 |
(...skipping 26 matching lines...) Expand all Loading... |
640 | 652 |
641 TabStripModel* tabs = browser->tab_strip_model(); | 653 TabStripModel* tabs = browser->tab_strip_model(); |
642 ASSERT_TRUE(tabs); | 654 ASSERT_TRUE(tabs); |
643 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); | 655 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); |
644 EXPECT_EQ(expected_tab_count, tabs->count()); | 656 EXPECT_EQ(expected_tab_count, tabs->count()); |
645 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) | 657 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) |
646 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); | 658 EXPECT_EQ(GURL(kStartupURLs[i]), tabs->GetWebContentsAt(i)->GetURL()); |
647 } | 659 } |
648 | 660 |
649 } // namespace policy | 661 } // namespace policy |
OLD | NEW |