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

Side by Side Diff: chrome/browser/policy/cloud/component_cloud_policy_updater_unittest.cc

Issue 70863002: Refactored the ComponentCloudPolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/cloud/component_cloud_policy_updater.h" 5 #include "chrome/browser/policy/cloud/component_cloud_policy_updater.h"
6 6
7 #include <string> 7 #include <string>
bartfab (slow) 2013/11/14 14:13:12 Nit: Already included by header now.
Joao da Silva 2013/11/14 14:56:41 Done.
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/sha1.h" 13 #include "base/sha1.h"
14 #include "base/test/test_simple_task_runner.h" 14 #include "base/test/test_simple_task_runner.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 16 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
17 #include "chrome/browser/policy/cloud/component_cloud_policy_store.h" 17 #include "chrome/browser/policy/cloud/component_cloud_policy_store.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // Update the policy fetch response before the download has finished. The new 325 // Update the policy fetch response before the download has finished. The new
326 // policy fetch response has no download URL. 326 // policy fetch response has no download URL.
327 builder_.payload().Clear(); 327 builder_.payload().Clear();
328 updater_->UpdateExternalPolicy(CreateResponse()); 328 updater_->UpdateExternalPolicy(CreateResponse());
329 task_runner_->RunUntilIdle(); 329 task_runner_->RunUntilIdle();
330 330
331 // Verify that the download is no longer running. 331 // Verify that the download is no longer running.
332 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0)); 332 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0));
333 } 333 }
334 334
335 TEST_F(ComponentCloudPolicyUpdaterTest, CancelUpdate) {
336 // Submit a policy fetch response with a valid download URL.
337 updater_->UpdateExternalPolicy(CreateResponse());
338 task_runner_->RunUntilIdle();
339
340 // Verify that the download has been started.
341 EXPECT_TRUE(fetcher_factory_.GetFetcherByID(0));
342
343 // Now cancel that update before the download completes.
344 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()).Times(0);
345 updater_->CancelUpdate(
346 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, kTestExtension));
347 task_runner_->RunUntilIdle();
348 Mock::VerifyAndClearExpectations(&store_delegate_);
349 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0));
350 }
351
335 } // namespace policy 352 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698