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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos_unittest.cc

Issue 24869003: cryptohome: Move stateless wrapper functions out of CryptohomeLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 *out = result; 53 *out = result;
54 loop->Quit(); 54 loop->Quit();
55 } 55 }
56 56
57 class DeviceCloudPolicyManagerChromeOSTest 57 class DeviceCloudPolicyManagerChromeOSTest
58 : public chromeos::DeviceSettingsTestBase { 58 : public chromeos::DeviceSettingsTestBase {
59 protected: 59 protected:
60 DeviceCloudPolicyManagerChromeOSTest() 60 DeviceCloudPolicyManagerChromeOSTest()
61 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()), 61 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()),
62 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), 62 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()),
63 install_attributes_(cryptohome_library_.get(), 63 install_attributes_(fake_cryptohome_client_.get()),
64 fake_cryptohome_client_.get()),
65 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, 64 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
66 &install_attributes_)), 65 &install_attributes_)),
67 manager_(make_scoped_ptr(store_), 66 manager_(make_scoped_ptr(store_),
68 loop_.message_loop_proxy(), 67 loop_.message_loop_proxy(),
69 &install_attributes_) { 68 &install_attributes_) {
70 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */); 69 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */);
71 } 70 }
72 71
73 virtual void SetUp() OVERRIDE { 72 virtual void SetUp() OVERRIDE {
74 DeviceSettingsTestBase::SetUp(); 73 DeviceSettingsTestBase::SetUp();
75 chrome::RegisterLocalState(local_state_.registry()); 74 chrome::RegisterLocalState(local_state_.registry());
76 manager_.Init(); 75 manager_.Init();
77 76
78 // DeviceOAuth2TokenService uses the system request context to fetch 77 // DeviceOAuth2TokenService uses the system request context to fetch
79 // OAuth tokens, then writes the token to local state, encrypting it 78 // OAuth tokens, then writes the token to local state, encrypting it
80 // first with methods in CryptohomeLibrary. 79 // first with methods in CryptohomeLibrary.
81 request_context_getter_ = new net::TestURLRequestContextGetter( 80 request_context_getter_ = new net::TestURLRequestContextGetter(
82 loop_.message_loop_proxy()); 81 loop_.message_loop_proxy());
83 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( 82 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(
84 request_context_getter_.get()); 83 request_context_getter_.get());
85 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); 84 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
86 chromeos::DeviceOAuth2TokenServiceFactory::Initialize(); 85 chromeos::DeviceOAuth2TokenServiceFactory::Initialize();
86 // TODO(satorux): Remove CryptohomeLibrary::SetForTest() when it's ready.
87 // (removing it now breaks the unit test). crbug.com/141016.
87 chromeos::CryptohomeLibrary::SetForTest(cryptohome_library_.get()); 88 chromeos::CryptohomeLibrary::SetForTest(cryptohome_library_.get());
88 url_fetcher_response_code_ = 200; 89 url_fetcher_response_code_ = 200;
89 url_fetcher_response_string_ = "{\"access_token\":\"accessToken4Test\"," 90 url_fetcher_response_string_ = "{\"access_token\":\"accessToken4Test\","
90 "\"expires_in\":1234," 91 "\"expires_in\":1234,"
91 "\"refresh_token\":\"refreshToken4Test\"}"; 92 "\"refresh_token\":\"refreshToken4Test\"}";
92 } 93 }
93 94
94 virtual void TearDown() OVERRIDE { 95 virtual void TearDown() OVERRIDE {
95 manager_.Shutdown(); 96 manager_.Shutdown();
96 DeviceSettingsTestBase::TearDown(); 97 DeviceSettingsTestBase::TearDown();
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { 491 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) {
491 loaded_blob_.clear(); 492 loaded_blob_.clear();
492 RunTest(); 493 RunTest();
493 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); 494 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR);
494 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, 495 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR,
495 status_.store_status()); 496 status_.store_status());
496 } 497 }
497 498
498 } // namespace 499 } // namespace
499 } // namespace policy 500 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698