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

Unified Diff: chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc

Issue 985093002: Fix up Owner settings on first load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: based off mattias' patch that injects CrosSettings for testing Created 5 years, 9 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/ownership/owner_settings_service_chromeos_unittest.cc
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc
index a06337e392af313fa0a01d4d4800c38b49a320ff..1d9f6ddb9db0d76f7d533ed86cd04610083b8296 100644
--- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc
+++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos_unittest.cc
@@ -13,6 +13,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
+#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/device_settings_provider.h"
#include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
#include "chrome/common/chrome_paths.h"
@@ -90,6 +91,7 @@ class OwnerSettingsServiceChromeOSTest : public DeviceSettingsTestBase {
void SetUp() override {
DeviceSettingsTestBase::SetUp();
+
provider_.reset(new DeviceSettingsProvider(base::Bind(&OnPrefChanged),
&device_settings_service_));
owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
@@ -108,7 +110,9 @@ class OwnerSettingsServiceChromeOSTest : public DeviceSettingsTestBase {
ReloadDeviceSettings();
}
- void TearDown() override { DeviceSettingsTestBase::TearDown(); }
+ void TearDown() override {
+ DeviceSettingsTestBase::TearDown();
+ }
void TestSingleSet(OwnerSettingsServiceChromeOS* service,
const std::string& setting,
@@ -123,6 +127,7 @@ class OwnerSettingsServiceChromeOSTest : public DeviceSettingsTestBase {
management_settings_set_ = success;
}
+ protected:
OwnerSettingsServiceChromeOS* service_;
ScopedTestingLocalState local_state_;
scoped_ptr<DeviceSettingsProvider> provider_;
@@ -321,4 +326,56 @@ TEST_F(OwnerSettingsServiceChromeOSNoOwnerTest, SingleSetTest) {
ASSERT_FALSE(service_->SetBoolean(kAccountsPrefAllowGuest, false));
}
+class OwnerSettingsServiceChromeOSTakeOwnerTest
+ : public OwnerSettingsServiceChromeOSTest {
+ public:
+ OwnerSettingsServiceChromeOSTakeOwnerTest() {}
+ ~OwnerSettingsServiceChromeOSTakeOwnerTest() override {}
+
+ void SetUp() override {
+ DeviceSettingsTestBase::SetUp();
+
+ owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
+ InitOwner(device_policy_.policy_data().username(), false);
+ FlushDeviceSettings();
+
+ service_ = OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(
+ profile_.get());
+ ASSERT_TRUE(service_);
+ ASSERT_FALSE(service_->IsOwner());
+
+ device_policy_.policy_data().set_management_mode(
+ em::PolicyData::LOCAL_OWNER);
+ device_policy_.Build();
+ device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
+ ReloadDeviceSettings();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOSTakeOwnerTest);
+};
+
+TEST_F(OwnerSettingsServiceChromeOSTakeOwnerTest, SingleSetTest) {
+ bool wildcard_match = false;
+ EXPECT_FALSE(
+ cros_settings_.FindEmailInList(kAccountsPrefUsers,
+ device_policy_.policy_data().username(),
+ &wildcard_match));
+
+ base::RunLoop loop;
+ scoped_ptr<CrosSettings::ObserverSubscription> subscription =
+ cros_settings_.AddSettingsObserver(
+ kAccountsPrefUsers,
+ base::Bind(&base::RunLoop::Quit, base::Unretained(&loop)));
+ service_->OnTPMTokenReady(true);
+ ReloadDeviceSettings();
+ loop.Run();
+
+ wildcard_match = false;
+ EXPECT_TRUE(
+ cros_settings_.FindEmailInList(kAccountsPrefUsers,
+ device_policy_.policy_data().username(),
+ &wildcard_match));
+ EXPECT_FALSE(wildcard_match);
+}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698