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

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: Rearrange device settings list. 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..ec3c8a64f637bd07842bb3f4c98ac4e076483289 100644
--- a/chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc
+++ b/chrome/browser/chromeos/attestation/platform_verification_flow_unittest.cc
@@ -11,16 +11,13 @@
#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/settings/device_settings_test_helper.h"
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/common/pref_names.h"
#include "chromeos/attestation/mock_attestation_flow.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/dbus/fake_cryptohome_client.h"
#include "chromeos/settings/cros_settings_names.h"
-#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
using testing::_;
@@ -131,16 +128,16 @@ class CustomFakeCryptohomeClient : public FakeCryptohomeClient {
} // namespace
-class PlatformVerificationFlowTest : public ::testing::Test {
+class PlatformVerificationFlowTest : public chromeos::OwnerSettingsTestBase {
public:
PlatformVerificationFlowTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_),
- certificate_success_(true),
+ : certificate_success_(true),
fake_certificate_index_(0),
sign_challenge_success_(true),
result_(PlatformVerificationFlow::INTERNAL_ERROR) {}
void SetUp() {
+ chromeos::OwnerSettingsTestBase::SetUp();
// Create a verifier for tests to call.
verifier_ = new PlatformVerificationFlow(&mock_attestation_flow_,
&mock_async_caller_,
@@ -151,20 +148,9 @@ 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);
- }
-
- void TearDown() {
- // Restore the real DeviceSettingsProvider.
- CrosSettings* cros_settings = CrosSettings::Get();
- cros_settings->RemoveSettingsProvider(&stub_settings_provider_);
- cros_settings->AddSettingsProvider(device_settings_provider_);
+ ReplaceProvider(kAttestationForContentProtectionEnabled);
+ owner_settings_service_->SetBoolean(kAttestationForContentProtectionEnabled,
+ true);
}
void ExpectAttestationFlow() {
@@ -231,16 +217,10 @@ class PlatformVerificationFlowTest : public ::testing::Test {
}
protected:
- base::MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
StrictMock<MockAttestationFlow> mock_attestation_flow_;
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 +257,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