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

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>
8
9 #include "base/callback.h" 7 #include "base/callback.h"
10 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
11 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
12 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
13 #include "base/sha1.h" 11 #include "base/sha1.h"
14 #include "base/test/test_simple_task_runner.h" 12 #include "base/test/test_simple_task_runner.h"
15 #include "base/values.h" 13 #include "base/values.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 14 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
17 #include "chrome/browser/policy/cloud/component_cloud_policy_store.h" 15 #include "chrome/browser/policy/cloud/component_cloud_policy_store.h"
18 #include "chrome/browser/policy/cloud/external_policy_data_fetcher.h" 16 #include "chrome/browser/policy/cloud/external_policy_data_fetcher.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // Update the policy fetch response before the download has finished. The new 323 // Update the policy fetch response before the download has finished. The new
326 // policy fetch response has no download URL. 324 // policy fetch response has no download URL.
327 builder_.payload().Clear(); 325 builder_.payload().Clear();
328 updater_->UpdateExternalPolicy(CreateResponse()); 326 updater_->UpdateExternalPolicy(CreateResponse());
329 task_runner_->RunUntilIdle(); 327 task_runner_->RunUntilIdle();
330 328
331 // Verify that the download is no longer running. 329 // Verify that the download is no longer running.
332 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0)); 330 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0));
333 } 331 }
334 332
333 TEST_F(ComponentCloudPolicyUpdaterTest, CancelUpdate) {
334 // Submit a policy fetch response with a valid download URL.
335 updater_->UpdateExternalPolicy(CreateResponse());
336 task_runner_->RunUntilIdle();
337
338 // Verify that the download has been started.
339 EXPECT_TRUE(fetcher_factory_.GetFetcherByID(0));
340
341 // Now cancel that update before the download completes.
342 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()).Times(0);
343 updater_->CancelUpdate(
344 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, kTestExtension));
345 task_runner_->RunUntilIdle();
346 Mock::VerifyAndClearExpectations(&store_delegate_);
347 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0));
348 }
349
335 } // namespace policy 350 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/component_cloud_policy_updater.cc ('k') | chrome/browser/policy/configuration_policy_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698