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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/device_token_fetcher_unittest.cc
diff --git a/chrome/browser/policy/device_token_fetcher_unittest.cc b/chrome/browser/policy/device_token_fetcher_unittest.cc
index f4a7e231d0f5f6e8aa99af4de8e6b3e9af339e55..28d11b0fc6b6d08961e854365884e414a851b350 100644
--- a/chrome/browser/policy/device_token_fetcher_unittest.cc
+++ b/chrome/browser/policy/device_token_fetcher_unittest.cc
@@ -224,4 +224,28 @@ TEST_F(DeviceTokenFetcherTest, FetchWithNonManagedUsername) {
ASSERT_FALSE(fetcher_->IsTokenValid());
}
+TEST_F(DeviceTokenFetcherTest, RestartImmediately) {
+ // Create a token.
+ EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
+ MockDeviceManagementBackendSucceedRegister());
+ SimulateSuccessfulLoginAndRunPending(kTestManagedDomainUsername);
+ ASSERT_FALSE(fetcher_->IsTokenPending());
+ std::string device_token = fetcher_->GetDeviceToken();
+
+ // Restart a new fetcher immediately without calling StartFetching(). The
+ // existing token should not be loaded, but rather a new token generated.
+ FilePath token_path;
+ GetDeviceTokenPath(fetcher_, &token_path);
+ scoped_refptr<TestingDeviceTokenFetcher> fetcher2(
+ new TestingDeviceTokenFetcher(
+ backend_.get(), profile_.get(), token_path));
+ fetcher2->Restart();
+ EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
+ MockDeviceManagementBackendSucceedRegister());
+ fetcher2->SimulateLogin(kTestManagedDomainUsername);
+ loop_.RunAllPending();
+ ASSERT_FALSE(fetcher2->IsTokenPending());
+ ASSERT_NE(device_token, fetcher2->GetDeviceToken());
+}
+
} // namespace policy
« 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