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

Unified Diff: chrome/browser/chromeos/attestation/platform_verification_flow_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/attestation/platform_verification_flow_unittest.cc
diff --git a/chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc b/chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc
index fb5ac95a2e502224aecae40751e31063040f7e6f..0e053d90dab8b7f03779be8f2ec13c96fa30d49a 100644
--- a/chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc
+++ b/chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc
@@ -11,9 +11,8 @@
#include "chrome/browser/chromeos/attestation/fake_certificate.h"
#include "chrome/browser/chromeos/attestation/platform_verification_flow.h"
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/settings/device_settings_service.h"
-#include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
+#include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h"
+#include "chrome/browser/chromeos/settings/settings_provider_test_base.h"
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/common/pref_names.h"
#include "chromeos/attestation/mock_attestation_flow.h"
@@ -131,7 +130,8 @@ class CustomFakeCryptohomeClient : public FakeCryptohomeClient {
} // namespace
-class PlatformVerificationFlowTest : public ::testing::Test {
+class PlatformVerificationFlowTest : public ::testing::Test,
+ public chromeos::SettingsProviderTestBase {
public:
PlatformVerificationFlowTest()
: ui_thread_(content::BrowserThread::UI, &message_loop_),
@@ -151,21 +151,13 @@ class PlatformVerificationFlowTest : public ::testing::Test {
callback_ = base::Bind(&PlatformVerificationFlowTest::FakeChallengeCallback,
base::Unretained(this));
- // Configure the global cros_settings.
- CrosSettings* cros_settings = CrosSettings::Get();
- device_settings_provider_ =
- cros_settings->GetProvider(kAttestationForContentProtectionEnabled);
- cros_settings->RemoveSettingsProvider(device_settings_provider_);
- cros_settings->AddSettingsProvider(&stub_settings_provider_);
- cros_settings->SetBoolean(kAttestationForContentProtectionEnabled, true);
+ ReplaceProvider(kAttestationForContentProtectionEnabled);
+ InitOwnerSettingsService(nullptr);
+ owner_settings_service_->SetBoolean(kAttestationForContentProtectionEnabled,
+ true);
}
- void TearDown() {
- // Restore the real DeviceSettingsProvider.
- CrosSettings* cros_settings = CrosSettings::Get();
- cros_settings->RemoveSettingsProvider(&stub_settings_provider_);
- cros_settings->AddSettingsProvider(device_settings_provider_);
- }
+ void TearDown() { RestoreProvider(); }
void ExpectAttestationFlow() {
// When consent is not given or the feature is disabled, it is important
@@ -237,10 +229,6 @@ class PlatformVerificationFlowTest : public ::testing::Test {
cryptohome::MockAsyncMethodCaller mock_async_caller_;
CustomFakeCryptohomeClient fake_cryptohome_client_;
FakeDelegate fake_delegate_;
- CrosSettingsProvider* device_settings_provider_;
- StubCrosSettingsProvider stub_settings_provider_;
- ScopedTestDeviceSettingsService test_device_settings_service_;
- ScopedTestCrosSettings test_cros_settings_;
scoped_refptr<PlatformVerificationFlow> verifier_;
// Controls result of FakeGetCertificate.
@@ -277,8 +265,8 @@ TEST_F(PlatformVerificationFlowTest, NotPermittedByUser) {
}
TEST_F(PlatformVerificationFlowTest, FeatureDisabledByPolicy) {
- CrosSettings::Get()->SetBoolean(kAttestationForContentProtectionEnabled,
- false);
+ owner_settings_service_->SetBoolean(kAttestationForContentProtectionEnabled,
+ false);
verifier_->ChallengePlatformKey(NULL, kTestID, kTestChallenge, callback_);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(PlatformVerificationFlow::POLICY_REJECTED, result_);

Powered by Google App Engine
This is Rietveld 408576698