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

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: Rebase Created 5 years, 8 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..2607ace7cd84157a9f94fb0a4a99ec2b54323a67 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/scoped_cros_settings_test_helper.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -434,15 +434,9 @@ 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);
+ ScopedCrosSettingsTestHelper settings_helper(false);
+ settings_helper.ReplaceProvider(kPolicyMissingMitigationMode);
+ settings_helper.SetBoolean(kPolicyMissingMitigationMode, true);
// Initialize login state for this test to verify the login state is changed
// to SAFE_MODE.
@@ -468,9 +462,6 @@ 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);
}
// Test the case that login switches to SafeMode and the Owner logs in, which
@@ -493,15 +484,9 @@ 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);
+ ScopedCrosSettingsTestHelper settings_helper(false);
+ settings_helper.ReplaceProvider(kPolicyMissingMitigationMode);
+ settings_helper.SetBoolean(kPolicyMissingMitigationMode, true);
// Initialize login state for this test to verify the login state is changed
// to SAFE_MODE.
@@ -526,9 +511,6 @@ 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);
}
TEST_F(CryptohomeAuthenticatorTest, DriveFailedMount) {

Powered by Google App Engine
This is Rietveld 408576698