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

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

Issue 6310012: Allow policy refresh rate to be configured through policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test. Created 9 years, 11 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) 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 ASSERT_FALSE(fetcher_->IsTokenValid()); 217 ASSERT_FALSE(fetcher_->IsTokenValid());
218 } 218 }
219 219
220 TEST_F(DeviceTokenFetcherTest, FetchWithNonManagedUsername) { 220 TEST_F(DeviceTokenFetcherTest, FetchWithNonManagedUsername) {
221 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(0); 221 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(0);
222 SimulateSuccessfulLoginAndRunPending("___@gmail.com"); 222 SimulateSuccessfulLoginAndRunPending("___@gmail.com");
223 ASSERT_FALSE(fetcher_->IsTokenPending()); 223 ASSERT_FALSE(fetcher_->IsTokenPending());
224 ASSERT_FALSE(fetcher_->IsTokenValid()); 224 ASSERT_FALSE(fetcher_->IsTokenValid());
225 } 225 }
226 226
227 TEST_F(DeviceTokenFetcherTest, RestartImmediately) {
228 // Create a token.
229 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
230 MockDeviceManagementBackendSucceedRegister());
231 SimulateSuccessfulLoginAndRunPending(kTestManagedDomainUsername);
232 ASSERT_FALSE(fetcher_->IsTokenPending());
233 std::string device_token = fetcher_->GetDeviceToken();
234
235 // Restart a new fetcher immediately without calling StartFetching(). The
236 // existing token should not be loaded, but rather a new token generated.
237 FilePath token_path;
238 GetDeviceTokenPath(fetcher_, &token_path);
239 scoped_refptr<TestingDeviceTokenFetcher> fetcher2(
240 new TestingDeviceTokenFetcher(
241 backend_.get(), profile_.get(), token_path));
242 fetcher2->Restart();
243 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
244 MockDeviceManagementBackendSucceedRegister());
245 fetcher2->SimulateLogin(kTestManagedDomainUsername);
246 loop_.RunAllPending();
247 ASSERT_FALSE(fetcher2->IsTokenPending());
248 ASSERT_NE(device_token, fetcher2->GetDeviceToken());
249 }
250
227 } // namespace policy 251 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.cc ('k') | chrome/browser/policy/profile_policy_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698