OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 em::DeviceLocation location = status_.device_location(); | 371 em::DeviceLocation location = status_.device_location(); |
372 EXPECT_TRUE(location.has_error_code()); | 372 EXPECT_TRUE(location.has_error_code()); |
373 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, | 373 EXPECT_EQ(em::DeviceLocation::ERROR_CODE_POSITION_UNAVAILABLE, |
374 location.error_code()); | 374 location.error_code()); |
375 } | 375 } |
376 | 376 |
377 void MockRunningKioskApp(const DeviceLocalAccount& account) { | 377 void MockRunningKioskApp(const DeviceLocalAccount& account) { |
378 std::vector<DeviceLocalAccount> accounts; | 378 std::vector<DeviceLocalAccount> accounts; |
379 accounts.push_back(account); | 379 accounts.push_back(account); |
380 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); | 380 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); |
381 user_manager_->CreateKioskAppUser( | 381 user_manager_->CreateKioskAppUser(account.user_id); |
382 AccountId::FromUserEmail(account.user_id)); | |
383 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( | 382 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( |
384 Return(true)); | 383 Return(true)); |
385 } | 384 } |
386 | 385 |
387 protected: | 386 protected: |
388 // Convenience method. | 387 // Convenience method. |
389 int64 ActivePeriodMilliseconds() { | 388 int64 ActivePeriodMilliseconds() { |
390 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; | 389 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; |
391 } | 390 } |
392 | 391 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 // Check that after enabling location reporting again, an error is reported | 765 // Check that after enabling location reporting again, an error is reported |
767 // if no valid fix is available. | 766 // if no valid fix is available. |
768 SetMockPositionToReturnNext(invalid_fix); | 767 SetMockPositionToReturnNext(invalid_fix); |
769 settings_helper_.SetBoolean(chromeos::kReportDeviceLocation, true); | 768 settings_helper_.SetBoolean(chromeos::kReportDeviceLocation, true); |
770 // Allow the new pref to propagate to the status collector. | 769 // Allow the new pref to propagate to the status collector. |
771 message_loop_.RunUntilIdle(); | 770 message_loop_.RunUntilIdle(); |
772 CheckThatALocationErrorIsReported(); | 771 CheckThatALocationErrorIsReported(); |
773 } | 772 } |
774 | 773 |
775 TEST_F(DeviceStatusCollectorTest, ReportUsers) { | 774 TEST_F(DeviceStatusCollectorTest, ReportUsers) { |
776 const AccountId public_account_id( | 775 user_manager_->CreatePublicAccountUser("public@localhost"); |
777 AccountId::FromUserEmail("public@localhost")); | 776 user_manager_->AddUserWithAffiliation("user0@managed.com", true); |
778 const AccountId account_id0(AccountId::FromUserEmail("user0@managed.com")); | 777 user_manager_->AddUserWithAffiliation("user1@managed.com", true); |
779 const AccountId account_id1(AccountId::FromUserEmail("user1@managed.com")); | 778 user_manager_->AddUserWithAffiliation("user2@managed.com", true); |
780 const AccountId account_id2(AccountId::FromUserEmail("user2@managed.com")); | 779 user_manager_->AddUserWithAffiliation("user3@unmanaged.com", false); |
781 const AccountId account_id3(AccountId::FromUserEmail("user3@unmanaged.com")); | 780 user_manager_->AddUserWithAffiliation("user4@managed.com", true); |
782 const AccountId account_id4(AccountId::FromUserEmail("user4@managed.com")); | 781 user_manager_->AddUserWithAffiliation("user5@managed.com", true); |
783 const AccountId account_id5(AccountId::FromUserEmail("user5@managed.com")); | |
784 | |
785 user_manager_->CreatePublicAccountUser(public_account_id); | |
786 user_manager_->AddUserWithAffiliation(account_id0, true); | |
787 user_manager_->AddUserWithAffiliation(account_id1, true); | |
788 user_manager_->AddUserWithAffiliation(account_id2, true); | |
789 user_manager_->AddUserWithAffiliation(account_id3, false); | |
790 user_manager_->AddUserWithAffiliation(account_id4, true); | |
791 user_manager_->AddUserWithAffiliation(account_id5, true); | |
792 | 782 |
793 // Verify that users are reported by default. | 783 // Verify that users are reported by default. |
794 GetStatus(); | 784 GetStatus(); |
795 EXPECT_EQ(6, status_.user_size()); | 785 EXPECT_EQ(6, status_.user_size()); |
796 | 786 |
797 // Verify that users are reported after enabling the setting. | 787 // Verify that users are reported after enabling the setting. |
798 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, true); | 788 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, true); |
799 GetStatus(); | 789 GetStatus(); |
800 EXPECT_EQ(6, status_.user_size()); | 790 EXPECT_EQ(6, status_.user_size()); |
801 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(0).type()); | 791 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(0).type()); |
802 EXPECT_EQ(account_id0.GetUserEmail(), status_.user(0).email()); | 792 EXPECT_EQ("user0@managed.com", status_.user(0).email()); |
803 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(1).type()); | 793 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(1).type()); |
804 EXPECT_EQ(account_id1.GetUserEmail(), status_.user(1).email()); | 794 EXPECT_EQ("user1@managed.com", status_.user(1).email()); |
805 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(2).type()); | 795 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(2).type()); |
806 EXPECT_EQ(account_id2.GetUserEmail(), status_.user(2).email()); | 796 EXPECT_EQ("user2@managed.com", status_.user(2).email()); |
807 EXPECT_EQ(em::DeviceUser::USER_TYPE_UNMANAGED, status_.user(3).type()); | 797 EXPECT_EQ(em::DeviceUser::USER_TYPE_UNMANAGED, status_.user(3).type()); |
808 EXPECT_FALSE(status_.user(3).has_email()); | 798 EXPECT_FALSE(status_.user(3).has_email()); |
809 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(4).type()); | 799 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(4).type()); |
810 EXPECT_EQ(account_id4.GetUserEmail(), status_.user(4).email()); | 800 EXPECT_EQ("user4@managed.com", status_.user(4).email()); |
811 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(5).type()); | 801 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(5).type()); |
812 EXPECT_EQ(account_id5.GetUserEmail(), status_.user(5).email()); | 802 EXPECT_EQ("user5@managed.com", status_.user(5).email()); |
813 | 803 |
814 // Verify that users are no longer reported if setting is disabled. | 804 // Verify that users are no longer reported if setting is disabled. |
815 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, false); | 805 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, false); |
816 GetStatus(); | 806 GetStatus(); |
817 EXPECT_EQ(0, status_.user_size()); | 807 EXPECT_EQ(0, status_.user_size()); |
818 } | 808 } |
819 | 809 |
820 TEST_F(DeviceStatusCollectorTest, TestVolumeInfo) { | 810 TEST_F(DeviceStatusCollectorTest, TestVolumeInfo) { |
821 std::vector<std::string> expected_mount_points; | 811 std::vector<std::string> expected_mount_points; |
822 std::vector<em::VolumeInfo> expected_volume_info; | 812 std::vector<em::VolumeInfo> expected_volume_info; |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 | 1286 |
1297 // Switch the policy on and verify the interface list is present. | 1287 // Switch the policy on and verify the interface list is present. |
1298 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); | 1288 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); |
1299 GetStatus(); | 1289 GetStatus(); |
1300 | 1290 |
1301 VerifyNetworkReporting(); | 1291 VerifyNetworkReporting(); |
1302 } | 1292 } |
1303 | 1293 |
1304 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) { | 1294 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) { |
1305 // Report netowork state for public accounts. | 1295 // Report netowork state for public accounts. |
1306 user_manager_->CreatePublicAccountUser( | 1296 user_manager_->CreatePublicAccountUser(kPublicAccountId); |
1307 AccountId::FromUserEmail(kPublicAccountId)); | |
1308 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) | 1297 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) |
1309 .WillRepeatedly(Return(true)); | 1298 .WillRepeatedly(Return(true)); |
1310 | 1299 |
1311 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); | 1300 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); |
1312 GetStatus(); | 1301 GetStatus(); |
1313 VerifyNetworkReporting(); | 1302 VerifyNetworkReporting(); |
1314 } | 1303 } |
1315 | 1304 |
1316 } // namespace policy | 1305 } // namespace policy |
OLD | NEW |