Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |
| OLD | NEW |