Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector_browsertest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Rebased. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(account.user_id); 381 user_manager_->CreateKioskAppUser(
382 AccountId::FromUserEmail(account.user_id));
382 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( 383 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly(
383 Return(true)); 384 Return(true));
384 } 385 }
385 386
386 protected: 387 protected:
387 // Convenience method. 388 // Convenience method.
388 int64 ActivePeriodMilliseconds() { 389 int64 ActivePeriodMilliseconds() {
389 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; 390 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000;
390 } 391 }
391 392
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 // Check that after enabling location reporting again, an error is reported 766 // Check that after enabling location reporting again, an error is reported
766 // if no valid fix is available. 767 // if no valid fix is available.
767 SetMockPositionToReturnNext(invalid_fix); 768 SetMockPositionToReturnNext(invalid_fix);
768 settings_helper_.SetBoolean(chromeos::kReportDeviceLocation, true); 769 settings_helper_.SetBoolean(chromeos::kReportDeviceLocation, true);
769 // Allow the new pref to propagate to the status collector. 770 // Allow the new pref to propagate to the status collector.
770 message_loop_.RunUntilIdle(); 771 message_loop_.RunUntilIdle();
771 CheckThatALocationErrorIsReported(); 772 CheckThatALocationErrorIsReported();
772 } 773 }
773 774
774 TEST_F(DeviceStatusCollectorTest, ReportUsers) { 775 TEST_F(DeviceStatusCollectorTest, ReportUsers) {
775 user_manager_->CreatePublicAccountUser("public@localhost"); 776 const AccountId public_user(AccountId::FromUserEmail("public@localhost"));
776 user_manager_->AddUserWithAffiliation("user0@managed.com", true); 777 const AccountId user0(AccountId::FromUserEmail("user0@managed.com"));
777 user_manager_->AddUserWithAffiliation("user1@managed.com", true); 778 const AccountId user1(AccountId::FromUserEmail("user1@managed.com"));
778 user_manager_->AddUserWithAffiliation("user2@managed.com", true); 779 const AccountId user2(AccountId::FromUserEmail("user2@managed.com"));
779 user_manager_->AddUserWithAffiliation("user3@unmanaged.com", false); 780 const AccountId user3(AccountId::FromUserEmail("user3@unmanaged.com"));
780 user_manager_->AddUserWithAffiliation("user4@managed.com", true); 781 const AccountId user4(AccountId::FromUserEmail("user4@managed.com"));
781 user_manager_->AddUserWithAffiliation("user5@managed.com", true); 782 const AccountId user5(AccountId::FromUserEmail("user5@managed.com"));
783
784 user_manager_->CreatePublicAccountUser(public_user);
785 user_manager_->AddUserWithAffiliation(user0, true);
786 user_manager_->AddUserWithAffiliation(user1, true);
787 user_manager_->AddUserWithAffiliation(user2, true);
788 user_manager_->AddUserWithAffiliation(user3, false);
789 user_manager_->AddUserWithAffiliation(user4, true);
790 user_manager_->AddUserWithAffiliation(user5, true);
782 791
783 // Verify that users are reported by default. 792 // Verify that users are reported by default.
784 GetStatus(); 793 GetStatus();
785 EXPECT_EQ(6, status_.user_size()); 794 EXPECT_EQ(6, status_.user_size());
786 795
787 // Verify that users are reported after enabling the setting. 796 // Verify that users are reported after enabling the setting.
788 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, true); 797 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, true);
789 GetStatus(); 798 GetStatus();
790 EXPECT_EQ(6, status_.user_size()); 799 EXPECT_EQ(6, status_.user_size());
791 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(0).type()); 800 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(0).type());
792 EXPECT_EQ("user0@managed.com", status_.user(0).email()); 801 EXPECT_EQ(user0.GetUserEmail(), status_.user(0).email());
793 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(1).type()); 802 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(1).type());
794 EXPECT_EQ("user1@managed.com", status_.user(1).email()); 803 EXPECT_EQ(user1.GetUserEmail(), status_.user(1).email());
795 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(2).type()); 804 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(2).type());
796 EXPECT_EQ("user2@managed.com", status_.user(2).email()); 805 EXPECT_EQ(user2.GetUserEmail(), status_.user(2).email());
797 EXPECT_EQ(em::DeviceUser::USER_TYPE_UNMANAGED, status_.user(3).type()); 806 EXPECT_EQ(em::DeviceUser::USER_TYPE_UNMANAGED, status_.user(3).type());
798 EXPECT_FALSE(status_.user(3).has_email()); 807 EXPECT_FALSE(status_.user(3).has_email());
799 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(4).type()); 808 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(4).type());
800 EXPECT_EQ("user4@managed.com", status_.user(4).email()); 809 EXPECT_EQ(user4.GetUserEmail(), status_.user(4).email());
801 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(5).type()); 810 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(5).type());
802 EXPECT_EQ("user5@managed.com", status_.user(5).email()); 811 EXPECT_EQ(user5.GetUserEmail(), status_.user(5).email());
803 812
804 // Verify that users are no longer reported if setting is disabled. 813 // Verify that users are no longer reported if setting is disabled.
805 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, false); 814 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, false);
806 GetStatus(); 815 GetStatus();
807 EXPECT_EQ(0, status_.user_size()); 816 EXPECT_EQ(0, status_.user_size());
808 } 817 }
809 818
810 TEST_F(DeviceStatusCollectorTest, TestVolumeInfo) { 819 TEST_F(DeviceStatusCollectorTest, TestVolumeInfo) {
811 std::vector<std::string> expected_mount_points; 820 std::vector<std::string> expected_mount_points;
812 std::vector<em::VolumeInfo> expected_volume_info; 821 std::vector<em::VolumeInfo> expected_volume_info;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 1295
1287 // Switch the policy on and verify the interface list is present. 1296 // Switch the policy on and verify the interface list is present.
1288 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1297 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1289 GetStatus(); 1298 GetStatus();
1290 1299
1291 VerifyNetworkReporting(); 1300 VerifyNetworkReporting();
1292 } 1301 }
1293 1302
1294 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) { 1303 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) {
1295 // Report netowork state for public accounts. 1304 // Report netowork state for public accounts.
1296 user_manager_->CreatePublicAccountUser(kPublicAccountId); 1305 user_manager_->CreatePublicAccountUser(
1306 AccountId::FromUserEmail(kPublicAccountId));
1297 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) 1307 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
1298 .WillRepeatedly(Return(true)); 1308 .WillRepeatedly(Return(true));
1299 1309
1300 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1310 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1301 GetStatus(); 1311 GetStatus();
1302 VerifyNetworkReporting(); 1312 VerifyNetworkReporting();
1303 } 1313 }
1304 1314
1305 } // namespace policy 1315 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698