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

Side by Side Diff: chrome/browser/policy/device_token_fetcher_unittest.cc

Issue 6705031: Send policy blobs to session_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_temp_dir.h" 8 #include "base/memory/scoped_temp_dir.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/net/gaia/token_service.h" 10 #include "chrome/browser/net/gaia/token_service.h"
11 #include "chrome/browser/policy/cloud_policy_cache.h"
12 #include "chrome/browser/policy/device_management_service.h" 11 #include "chrome/browser/policy/device_management_service.h"
13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 12 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
14 #include "chrome/browser/policy/mock_device_management_backend.h" 13 #include "chrome/browser/policy/mock_device_management_backend.h"
14 #include "chrome/browser/policy/user_policy_cache.h"
15 #include "chrome/common/net/gaia/gaia_constants.h" 15 #include "chrome/common/net/gaia/gaia_constants.h"
16 #include "chrome/test/testing_profile.h" 16 #include "chrome/test/testing_profile.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace policy { 21 namespace policy {
22 22
23 const char kTestToken[] = "device_token_fetcher_test_auth_token"; 23 const char kTestToken[] = "device_token_fetcher_test_auth_token";
24 24
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 class DeviceTokenFetcherTest : public testing::Test { 100 class DeviceTokenFetcherTest : public testing::Test {
101 protected: 101 protected:
102 DeviceTokenFetcherTest() 102 DeviceTokenFetcherTest()
103 : ui_thread_(BrowserThread::UI, &loop_), 103 : ui_thread_(BrowserThread::UI, &loop_),
104 file_thread_(BrowserThread::FILE, &loop_) { 104 file_thread_(BrowserThread::FILE, &loop_) {
105 EXPECT_TRUE(temp_user_data_dir_.CreateUniqueTempDir()); 105 EXPECT_TRUE(temp_user_data_dir_.CreateUniqueTempDir());
106 } 106 }
107 107
108 virtual void SetUp() { 108 virtual void SetUp() {
109 cache_.reset(new CloudPolicyCache( 109 cache_.reset(new UserPolicyCache(
110 temp_user_data_dir_.path().AppendASCII("DeviceTokenFetcherTest"))); 110 temp_user_data_dir_.path().AppendASCII("DeviceTokenFetcherTest")));
111 service_.set_backend(&backend_); 111 service_.set_backend(&backend_);
112 } 112 }
113 113
114 virtual void TearDown() { 114 virtual void TearDown() {
115 loop_.RunAllPending(); 115 loop_.RunAllPending();
116 } 116 }
117 117
118 MessageLoop loop_; 118 MessageLoop loop_;
119 MockDeviceManagementBackend backend_; 119 MockDeviceManagementBackend backend_;
120 MockDeviceManagementService service_; 120 MockDeviceManagementService service_;
121 scoped_ptr<CloudPolicyCache> cache_; 121 scoped_ptr<CloudPolicyCacheBase> cache_;
122 ScopedTempDir temp_user_data_dir_; 122 ScopedTempDir temp_user_data_dir_;
123 123
124 private: 124 private:
125 BrowserThread ui_thread_; 125 BrowserThread ui_thread_;
126 BrowserThread file_thread_; 126 BrowserThread file_thread_;
127 }; 127 };
128 128
129 TEST_F(DeviceTokenFetcherTest, FetchToken) { 129 TEST_F(DeviceTokenFetcherTest, FetchToken) {
130 testing::InSequence s; 130 testing::InSequence s;
131 EXPECT_CALL(backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce( 131 EXPECT_CALL(backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 fetcher.FetchToken("fake_auth_token", "fake_device_id", 186 fetcher.FetchToken("fake_auth_token", "fake_device_id",
187 em::DeviceRegisterRequest::USER, "fake_machine_id"); 187 em::DeviceRegisterRequest::USER, "fake_machine_id");
188 loop_.RunAllPending(); 188 loop_.RunAllPending();
189 Mock::VerifyAndClearExpectations(&observer); 189 Mock::VerifyAndClearExpectations(&observer);
190 EXPECT_EQ("", fetcher.GetDeviceToken()); 190 EXPECT_EQ("", fetcher.GetDeviceToken());
191 EXPECT_TRUE(cache_->is_unmanaged()); 191 EXPECT_TRUE(cache_->is_unmanaged());
192 fetcher.RemoveObserver(&observer); 192 fetcher.RemoveObserver(&observer);
193 } 193 }
194 194
195 } // namespace policy 195 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.cc ('k') | chrome/browser/policy/profile_policy_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698