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

Unified Diff: chrome/browser/chromeos/system/device_disabling_manager_unittest.cc

Issue 2403053003: Remove unused email from install attributes and add support for AD. (Closed)
Patch Set: Address Maksim's comments. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system/device_disabling_manager_unittest.cc
diff --git a/chrome/browser/chromeos/system/device_disabling_manager_unittest.cc b/chrome/browser/chromeos/system/device_disabling_manager_unittest.cc
index c8c5fa3f57abd351853d01d40564b87ec12ad837..97482cad9350c9e13ec1cf48881a1fceeb8c6cfd 100644
--- a/chrome/browser/chromeos/system/device_disabling_manager_unittest.cc
+++ b/chrome/browser/chromeos/system/device_disabling_manager_unittest.cc
@@ -56,10 +56,6 @@ class DeviceDisablingManagerTestBase : public testing::Test,
virtual void CreateDeviceDisablingManager();
virtual void DestroyDeviceDisablingManager();
-
- void UpdateInstallAttributes(const std::string& enrollment_domain,
- const std::string& registration_user,
- policy::DeviceMode device_mode);
void LogIn();
// DeviceDisablingManager::Delegate:
@@ -70,7 +66,14 @@ class DeviceDisablingManagerTestBase : public testing::Test,
return device_disabling_manager_.get();
}
+ // Configure install attributes.
+ void SetUnowned();
+ void SetEnterpriseOwned();
+ void SetConsumerOwned();
+
private:
+ chromeos::StubInstallAttributes* GetInstallAttributes();
+
chromeos::ScopedStubInstallAttributes install_attributes_;
chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
chromeos::ScopedTestCrosSettings test_cros_settings_;
@@ -81,7 +84,7 @@ class DeviceDisablingManagerTestBase : public testing::Test,
};
DeviceDisablingManagerTestBase::DeviceDisablingManagerTestBase()
- : install_attributes_("", "", "", policy::DEVICE_MODE_NOT_SET) {
+ : install_attributes_(ScopedStubInstallAttributes::CreateUnset()) {
}
void DeviceDisablingManagerTestBase::TearDown() {
@@ -99,25 +102,31 @@ void DeviceDisablingManagerTestBase::DestroyDeviceDisablingManager() {
device_disabling_manager_.reset();
}
-void DeviceDisablingManagerTestBase::UpdateInstallAttributes(
- const std::string& enrollment_domain,
- const std::string& registration_user,
- policy::DeviceMode device_mode) {
- chromeos::StubInstallAttributes* install_attributes =
- static_cast<chromeos::StubInstallAttributes*>(
- TestingBrowserProcess::GetGlobal()
- ->platform_part()
- ->browser_policy_connector_chromeos()
- ->GetInstallAttributes());
- install_attributes->SetDomain(enrollment_domain);
- install_attributes->SetRegistrationUser(registration_user);
- install_attributes->SetMode(device_mode);
-}
-
void DeviceDisablingManagerTestBase::LogIn() {
fake_user_manager_.AddUser(AccountId::FromUserEmail(kTestUser));
}
+void DeviceDisablingManagerTestBase::SetUnowned() {
+ GetInstallAttributes()->Clear();
+}
+
+void DeviceDisablingManagerTestBase::SetEnterpriseOwned() {
+ GetInstallAttributes()->SetEnterprise(kEnrollmentDomain, "fake-id");
+}
+
+void DeviceDisablingManagerTestBase::SetConsumerOwned() {
+ GetInstallAttributes()->SetConsumer();
+}
+
+chromeos::StubInstallAttributes*
+DeviceDisablingManagerTestBase::GetInstallAttributes() {
+ return static_cast<chromeos::StubInstallAttributes*>(
+ TestingBrowserProcess::GetGlobal()
+ ->platform_part()
+ ->browser_policy_connector_chromeos()
+ ->GetInstallAttributes());
+}
+
// Base class for tests that verify device disabling behavior during OOBE, when
// the device is not owned yet.
class DeviceDisablingManagerOOBETest : public DeviceDisablingManagerTestBase {
@@ -216,9 +225,7 @@ TEST_F(DeviceDisablingManagerOOBETest, NotDisabledWhenTurnedOffByFlag) {
// Verifies that the device is not considered disabled during OOBE when it is
// already enrolled, even if the device is marked as disabled.
TEST_F(DeviceDisablingManagerOOBETest, NotDisabledWhenEnterpriseOwned) {
- UpdateInstallAttributes(kEnrollmentDomain,
- kTestUser,
- policy::DEVICE_MODE_ENTERPRISE);
+ SetEnterpriseOwned();
SetDeviceDisabled(true);
CheckWhetherDeviceDisabledDuringOOBE();
EXPECT_FALSE(device_disabled());
@@ -227,9 +234,7 @@ TEST_F(DeviceDisablingManagerOOBETest, NotDisabledWhenEnterpriseOwned) {
// Verifies that the device is not considered disabled during OOBE when it is
// already owned by a consumer, even if the device is marked as disabled.
TEST_F(DeviceDisablingManagerOOBETest, NotDisabledWhenConsumerOwned) {
- UpdateInstallAttributes(std::string() /* enrollment_domain */,
- std::string() /* registration_user */,
- policy::DEVICE_MODE_CONSUMER);
+ SetConsumerOwned();
SetDeviceDisabled(true);
CheckWhetherDeviceDisabledDuringOOBE();
EXPECT_FALSE(device_disabled());
@@ -262,9 +267,6 @@ class DeviceDisablingManagerTest : public DeviceDisablingManagerTestBase,
// DeviceDisablingManager::Observer:
MOCK_METHOD1(OnDisabledMessageChanged, void(const std::string&));
- void SetUnowned();
- void SetEnterpriseOwned();
- void SetConsumerOwned();
void MakeCrosSettingsTrusted();
void SetDeviceDisabled(bool disabled);
@@ -299,24 +301,6 @@ void DeviceDisablingManagerTest::DestroyDeviceDisablingManager() {
DeviceDisablingManagerTestBase::DestroyDeviceDisablingManager();
}
-void DeviceDisablingManagerTest::SetUnowned() {
- UpdateInstallAttributes(std::string() /* enrollment_domain */,
- std::string() /* registration_user */,
- policy::DEVICE_MODE_NOT_SET);
-}
-
-void DeviceDisablingManagerTest::SetEnterpriseOwned() {
- UpdateInstallAttributes(kEnrollmentDomain,
- kTestUser,
- policy::DEVICE_MODE_ENTERPRISE);
-}
-
-void DeviceDisablingManagerTest::SetConsumerOwned() {
- UpdateInstallAttributes(std::string() /* enrollment_domain */,
- std::string() /* registration_user */,
- policy::DEVICE_MODE_CONSUMER);
-}
-
void DeviceDisablingManagerTest::MakeCrosSettingsTrusted() {
scoped_refptr<ownership::MockOwnerKeyUtil> owner_key_util(
new ownership::MockOwnerKeyUtil);

Powered by Google App Engine
This is Rietveld 408576698