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

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: Fix Win GN build. Created 5 years, 1 month 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_account_id(
776 user_manager_->AddUserWithAffiliation("user0@managed.com", true); 777 AccountId::FromUserEmail("public@localhost"));
777 user_manager_->AddUserWithAffiliation("user1@managed.com", true); 778 const AccountId account_id0(AccountId::FromUserEmail("user0@managed.com"));
778 user_manager_->AddUserWithAffiliation("user2@managed.com", true); 779 const AccountId account_id1(AccountId::FromUserEmail("user1@managed.com"));
779 user_manager_->AddUserWithAffiliation("user3@unmanaged.com", false); 780 const AccountId account_id2(AccountId::FromUserEmail("user2@managed.com"));
780 user_manager_->AddUserWithAffiliation("user4@managed.com", true); 781 const AccountId account_id3(AccountId::FromUserEmail("user3@unmanaged.com"));
781 user_manager_->AddUserWithAffiliation("user5@managed.com", true); 782 const AccountId account_id4(AccountId::FromUserEmail("user4@managed.com"));
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);
782 792
783 // Verify that users are reported by default. 793 // Verify that users are reported by default.
784 GetStatus(); 794 GetStatus();
785 EXPECT_EQ(6, status_.user_size()); 795 EXPECT_EQ(6, status_.user_size());
786 796
787 // Verify that users are reported after enabling the setting. 797 // Verify that users are reported after enabling the setting.
788 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, true); 798 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, true);
789 GetStatus(); 799 GetStatus();
790 EXPECT_EQ(6, status_.user_size()); 800 EXPECT_EQ(6, status_.user_size());
791 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(0).type()); 801 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(0).type());
792 EXPECT_EQ("user0@managed.com", status_.user(0).email()); 802 EXPECT_EQ(account_id0.GetUserEmail(), status_.user(0).email());
793 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(1).type()); 803 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(1).type());
794 EXPECT_EQ("user1@managed.com", status_.user(1).email()); 804 EXPECT_EQ(account_id1.GetUserEmail(), status_.user(1).email());
795 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(2).type()); 805 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(2).type());
796 EXPECT_EQ("user2@managed.com", status_.user(2).email()); 806 EXPECT_EQ(account_id2.GetUserEmail(), status_.user(2).email());
797 EXPECT_EQ(em::DeviceUser::USER_TYPE_UNMANAGED, status_.user(3).type()); 807 EXPECT_EQ(em::DeviceUser::USER_TYPE_UNMANAGED, status_.user(3).type());
798 EXPECT_FALSE(status_.user(3).has_email()); 808 EXPECT_FALSE(status_.user(3).has_email());
799 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(4).type()); 809 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(4).type());
800 EXPECT_EQ("user4@managed.com", status_.user(4).email()); 810 EXPECT_EQ(account_id4.GetUserEmail(), status_.user(4).email());
801 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(5).type()); 811 EXPECT_EQ(em::DeviceUser::USER_TYPE_MANAGED, status_.user(5).type());
802 EXPECT_EQ("user5@managed.com", status_.user(5).email()); 812 EXPECT_EQ(account_id5.GetUserEmail(), status_.user(5).email());
803 813
804 // Verify that users are no longer reported if setting is disabled. 814 // Verify that users are no longer reported if setting is disabled.
805 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, false); 815 settings_helper_.SetBoolean(chromeos::kReportDeviceUsers, false);
806 GetStatus(); 816 GetStatus();
807 EXPECT_EQ(0, status_.user_size()); 817 EXPECT_EQ(0, status_.user_size());
808 } 818 }
809 819
810 TEST_F(DeviceStatusCollectorTest, TestVolumeInfo) { 820 TEST_F(DeviceStatusCollectorTest, TestVolumeInfo) {
811 std::vector<std::string> expected_mount_points; 821 std::vector<std::string> expected_mount_points;
812 std::vector<em::VolumeInfo> expected_volume_info; 822 std::vector<em::VolumeInfo> expected_volume_info;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 1296
1287 // Switch the policy on and verify the interface list is present. 1297 // Switch the policy on and verify the interface list is present.
1288 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1298 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1289 GetStatus(); 1299 GetStatus();
1290 1300
1291 VerifyNetworkReporting(); 1301 VerifyNetworkReporting();
1292 } 1302 }
1293 1303
1294 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) { 1304 TEST_F(DeviceStatusCollectorNetworkInterfacesTest, ReportIfPublicSession) {
1295 // Report netowork state for public accounts. 1305 // Report netowork state for public accounts.
1296 user_manager_->CreatePublicAccountUser(kPublicAccountId); 1306 user_manager_->CreatePublicAccountUser(
1307 AccountId::FromUserEmail(kPublicAccountId));
1297 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) 1308 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
1298 .WillRepeatedly(Return(true)); 1309 .WillRepeatedly(Return(true));
1299 1310
1300 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1311 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1301 GetStatus(); 1312 GetStatus();
1302 VerifyNetworkReporting(); 1313 VerifyNetworkReporting();
1303 } 1314 }
1304 1315
1305 } // namespace policy 1316 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698