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 "components/policy/core/common/cloud/component_cloud_policy_updater.h" | 5 #include "components/policy/core/common/cloud/component_cloud_policy_updater.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 net::TestURLFetcherFactory fetcher_factory_; | 80 net::TestURLFetcherFactory fetcher_factory_; |
81 std::unique_ptr<ExternalPolicyDataFetcherBackend> fetcher_backend_; | 81 std::unique_ptr<ExternalPolicyDataFetcherBackend> fetcher_backend_; |
82 std::unique_ptr<ComponentCloudPolicyUpdater> updater_; | 82 std::unique_ptr<ComponentCloudPolicyUpdater> updater_; |
83 ComponentPolicyBuilder builder_; | 83 ComponentPolicyBuilder builder_; |
84 PolicyBundle expected_bundle_; | 84 PolicyBundle expected_bundle_; |
85 }; | 85 }; |
86 | 86 |
87 void ComponentCloudPolicyUpdaterTest::SetUp() { | 87 void ComponentCloudPolicyUpdaterTest::SetUp() { |
88 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 88 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
89 task_runner_ = new base::TestSimpleTaskRunner(); | 89 task_runner_ = new base::TestSimpleTaskRunner(); |
90 cache_.reset(new ResourceCache(temp_dir_.path(), task_runner_)); | 90 cache_.reset(new ResourceCache(temp_dir_.GetPath(), task_runner_)); |
91 store_.reset(new ComponentCloudPolicyStore(&store_delegate_, cache_.get())); | 91 store_.reset(new ComponentCloudPolicyStore(&store_delegate_, cache_.get())); |
92 store_->SetCredentials(ComponentPolicyBuilder::kFakeUsername, | 92 store_->SetCredentials(ComponentPolicyBuilder::kFakeUsername, |
93 ComponentPolicyBuilder::kFakeToken); | 93 ComponentPolicyBuilder::kFakeToken); |
94 fetcher_factory_.set_remove_fetcher_on_delete(true); | 94 fetcher_factory_.set_remove_fetcher_on_delete(true); |
95 fetcher_backend_.reset(new ExternalPolicyDataFetcherBackend( | 95 fetcher_backend_.reset(new ExternalPolicyDataFetcherBackend( |
96 task_runner_, | 96 task_runner_, |
97 scoped_refptr<net::URLRequestContextGetter>())); | 97 scoped_refptr<net::URLRequestContextGetter>())); |
98 updater_.reset(new ComponentCloudPolicyUpdater( | 98 updater_.reset(new ComponentCloudPolicyUpdater( |
99 task_runner_, | 99 task_runner_, |
100 fetcher_backend_->CreateFrontend(task_runner_), | 100 fetcher_backend_->CreateFrontend(task_runner_), |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // Now cancel that update before the download completes. | 344 // Now cancel that update before the download completes. |
345 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()).Times(0); | 345 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()).Times(0); |
346 updater_->CancelUpdate( | 346 updater_->CancelUpdate( |
347 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, kTestExtension)); | 347 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, kTestExtension)); |
348 task_runner_->RunUntilIdle(); | 348 task_runner_->RunUntilIdle(); |
349 Mock::VerifyAndClearExpectations(&store_delegate_); | 349 Mock::VerifyAndClearExpectations(&store_delegate_); |
350 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0)); | 350 EXPECT_FALSE(fetcher_factory_.GetFetcherByID(0)); |
351 } | 351 } |
352 | 352 |
353 } // namespace policy | 353 } // namespace policy |
OLD | NEW |