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

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

Issue 4967005: No persisted device id/token for unmanaged devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "chrome/browser/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return new DeviceTokenFetcher( 60 return new DeviceTokenFetcher(
61 backend_.get(), 61 backend_.get(),
62 token_dir.Append(FILE_PATH_LITERAL("test-token-file.txt"))); 62 token_dir.Append(FILE_PATH_LITERAL("test-token-file.txt")));
63 } 63 }
64 64
65 static void GetDeviceTokenPath(const DeviceTokenFetcher* fetcher, 65 static void GetDeviceTokenPath(const DeviceTokenFetcher* fetcher,
66 FilePath* path) { 66 FilePath* path) {
67 fetcher->GetDeviceTokenPath(path); 67 fetcher->GetDeviceTokenPath(path);
68 } 68 }
69 69
70 std::string device_id(const DeviceTokenFetcher* fetcher) {
Mattias Nissler (ping if slow) 2010/11/16 18:17:40 const ref return value
Jakob Kummerow (corp) 2010/11/17 10:35:02 Done.
71 return fetcher->device_id_;
72 }
73
70 MessageLoop loop_; 74 MessageLoop loop_;
71 scoped_ptr<MockDeviceManagementBackend> backend_; 75 scoped_ptr<MockDeviceManagementBackend> backend_;
72 ScopedTempDir temp_user_data_dir_; 76 ScopedTempDir temp_user_data_dir_;
73 scoped_refptr<DeviceTokenFetcher> fetcher_; 77 scoped_refptr<DeviceTokenFetcher> fetcher_;
74 78
75 private: 79 private:
76 BrowserThread ui_thread_; 80 BrowserThread ui_thread_;
77 BrowserThread file_thread_; 81 BrowserThread file_thread_;
78 }; 82 };
79 83
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 163
160 TEST_F(DeviceTokenFetcherTest, FailedServerRequest) { 164 TEST_F(DeviceTokenFetcherTest, FailedServerRequest) {
161 backend_->AllShouldFail(); 165 backend_->AllShouldFail();
162 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1); 166 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
163 SimulateSuccessfulLoginAndRunPending(); 167 SimulateSuccessfulLoginAndRunPending();
164 ASSERT_FALSE(fetcher_->IsTokenPending()); 168 ASSERT_FALSE(fetcher_->IsTokenPending());
165 const std::string token(fetcher_->GetDeviceToken()); 169 const std::string token(fetcher_->GetDeviceToken());
166 EXPECT_EQ("", token); 170 EXPECT_EQ("", token);
167 } 171 }
168 172
173 TEST_F(DeviceTokenFetcherTest, UnmanagedDevice) {
174 backend_->UnmanagedDevice();
175 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
176 SimulateSuccessfulLoginAndRunPending();
177 ASSERT_FALSE(fetcher_->IsTokenPending());
178 ASSERT_EQ("", fetcher_->GetDeviceToken());
179 ASSERT_EQ("", device_id(fetcher_));
180 FilePath token_path;
181 GetDeviceTokenPath(fetcher_, &token_path);
182 ASSERT_FALSE(file_util::PathExists(token_path));
183 }
184
169 } // namespace policy 185 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.cc ('k') | chrome/browser/policy/mock_device_management_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698