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

Unified Diff: chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc

Issue 1019283004: Switch to direct use of OwnerSettingsServiceChromeOS::Set() in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use settings provider to set read-only device settings. 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/login/auth/cryptohome_authenticator_unittest.cc
diff --git a/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc b/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc
index c3dcd6efa41dae8ac656587166be77daf17e635f..85ea44536ca2d409cb5ac7f4a7c98a8eb4e36832 100644
--- a/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc
+++ b/chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc
@@ -22,7 +22,7 @@
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
-#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
+#include "chrome/browser/chromeos/settings/settings_provider_test_base.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -127,10 +127,12 @@ scoped_ptr<crypto::RSAPrivateKey> CreateOwnerKeyInSlot(PK11SlotInfo* slot) {
} // namespace
-class CryptohomeAuthenticatorTest : public testing::Test {
+class CryptohomeAuthenticatorTest : public testing::Test,
+ public chromeos::SettingsProviderTestBase {
public:
CryptohomeAuthenticatorTest()
- : user_context_("me@nowhere.org"),
+ : chromeos::SettingsProviderTestBase(false),
+ user_context_("me@nowhere.org"),
user_manager_(new user_manager::FakeUserManager()),
user_manager_enabler_(user_manager_),
mock_caller_(NULL),
@@ -434,15 +436,8 @@ TEST_F(CryptohomeAuthenticatorTest, ResolveOwnerNeededFailedMount) {
// and succeeded but we are in safe mode and the current user is not owner.
state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE);
SetOwnerState(false, false);
- // Remove the real DeviceSettingsProvider and replace it with a stub.
- CrosSettingsProvider* device_settings_provider =
- CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo);
- EXPECT_TRUE(device_settings_provider != NULL);
- EXPECT_TRUE(
- CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider));
- StubCrosSettingsProvider stub_settings_provider;
- CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider);
- CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode, true);
+ ReplaceProvider(kPolicyMissingMitigationMode);
Mattias Nissler (ping if slow) 2015/03/30 14:45:46 If you made your helper into a ScopedCrosSettingsT
+ stub_settings_provider_.SetBoolean(kPolicyMissingMitigationMode, true);
// Initialize login state for this test to verify the login state is changed
// to SAFE_MODE.
@@ -468,9 +463,7 @@ TEST_F(CryptohomeAuthenticatorTest, ResolveOwnerNeededFailedMount) {
// Unset global objects used by this test.
fake_cryptohome_client_->set_unmount_result(true);
LoginState::Shutdown();
- EXPECT_TRUE(
- CrosSettings::Get()->RemoveSettingsProvider(&stub_settings_provider));
- CrosSettings::Get()->AddSettingsProvider(device_settings_provider);
+ RestoreProvider();
}
// Test the case that login switches to SafeMode and the Owner logs in, which
@@ -493,15 +486,8 @@ TEST_F(CryptohomeAuthenticatorTest, ResolveOwnerNeededSuccess) {
// and succeeded but we are in safe mode and the current user is not owner.
state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE);
SetOwnerState(false, false);
- // Remove the real DeviceSettingsProvider and replace it with a stub.
- CrosSettingsProvider* device_settings_provider =
- CrosSettings::Get()->GetProvider(chromeos::kReportDeviceVersionInfo);
- EXPECT_TRUE(device_settings_provider != NULL);
- EXPECT_TRUE(
- CrosSettings::Get()->RemoveSettingsProvider(device_settings_provider));
- StubCrosSettingsProvider stub_settings_provider;
- CrosSettings::Get()->AddSettingsProvider(&stub_settings_provider);
- CrosSettings::Get()->SetBoolean(kPolicyMissingMitigationMode, true);
+ ReplaceProvider(kPolicyMissingMitigationMode);
+ stub_settings_provider_.SetBoolean(kPolicyMissingMitigationMode, true);
// Initialize login state for this test to verify the login state is changed
// to SAFE_MODE.
@@ -526,9 +512,7 @@ TEST_F(CryptohomeAuthenticatorTest, ResolveOwnerNeededSuccess) {
// Unset global objects used by this test.
fake_cryptohome_client_->set_unmount_result(true);
LoginState::Shutdown();
- EXPECT_TRUE(
- CrosSettings::Get()->RemoveSettingsProvider(&stub_settings_provider));
- CrosSettings::Get()->AddSettingsProvider(device_settings_provider);
+ RestoreProvider();
}
TEST_F(CryptohomeAuthenticatorTest, DriveFailedMount) {

Powered by Google App Engine
This is Rietveld 408576698