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

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

Issue 23868021: Prepare ExternalPolicyDataUpdater and ResourceCache for blocking pool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-uploading due to rietveld flake. Created 7 years, 3 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 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>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 } // namespace 67 } // namespace
68 68
69 class ComponentCloudPolicyUpdaterTest : public testing::Test { 69 class ComponentCloudPolicyUpdaterTest : public testing::Test {
70 protected: 70 protected:
71 virtual void SetUp() OVERRIDE; 71 virtual void SetUp() OVERRIDE;
72 virtual void TearDown() OVERRIDE; 72 virtual void TearDown() OVERRIDE;
73 73
74 scoped_ptr<em::PolicyFetchResponse> CreateResponse(); 74 scoped_ptr<em::PolicyFetchResponse> CreateResponse();
75 75
76 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
76 base::ScopedTempDir temp_dir_; 77 base::ScopedTempDir temp_dir_;
77 scoped_ptr<ResourceCache> cache_; 78 scoped_ptr<ResourceCache> cache_;
78 scoped_ptr<ComponentCloudPolicyStore> store_; 79 scoped_ptr<ComponentCloudPolicyStore> store_;
79 MockComponentCloudPolicyStoreDelegate store_delegate_; 80 MockComponentCloudPolicyStoreDelegate store_delegate_;
80 net::TestURLFetcherFactory fetcher_factory_; 81 net::TestURLFetcherFactory fetcher_factory_;
81 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
82 scoped_ptr<ExternalPolicyDataFetcherBackend> fetcher_backend_; 82 scoped_ptr<ExternalPolicyDataFetcherBackend> fetcher_backend_;
83 scoped_ptr<ComponentCloudPolicyUpdater> updater_; 83 scoped_ptr<ComponentCloudPolicyUpdater> updater_;
84 ComponentPolicyBuilder builder_; 84 ComponentPolicyBuilder builder_;
85 PolicyBundle expected_bundle_; 85 PolicyBundle expected_bundle_;
86 }; 86 };
87 87
88 void ComponentCloudPolicyUpdaterTest::SetUp() { 88 void ComponentCloudPolicyUpdaterTest::SetUp() {
89 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 89 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
90 cache_.reset(new ResourceCache(temp_dir_.path())); 90 task_runner_ = new base::TestSimpleTaskRunner();
91 cache_.reset(new ResourceCache(temp_dir_.path(), task_runner_));
91 store_.reset(new ComponentCloudPolicyStore(&store_delegate_, cache_.get())); 92 store_.reset(new ComponentCloudPolicyStore(&store_delegate_, cache_.get()));
92 store_->SetCredentials(ComponentPolicyBuilder::kFakeUsername, 93 store_->SetCredentials(ComponentPolicyBuilder::kFakeUsername,
93 ComponentPolicyBuilder::kFakeToken); 94 ComponentPolicyBuilder::kFakeToken);
94 fetcher_factory_.set_remove_fetcher_on_delete(true); 95 fetcher_factory_.set_remove_fetcher_on_delete(true);
95 task_runner_ = new base::TestSimpleTaskRunner();
96 fetcher_backend_.reset(new ExternalPolicyDataFetcherBackend( 96 fetcher_backend_.reset(new ExternalPolicyDataFetcherBackend(
97 task_runner_, 97 task_runner_,
98 scoped_refptr<net::URLRequestContextGetter>())); 98 scoped_refptr<net::URLRequestContextGetter>()));
99 updater_.reset(new ComponentCloudPolicyUpdater( 99 updater_.reset(new ComponentCloudPolicyUpdater(
100 task_runner_, 100 task_runner_,
101 fetcher_backend_->CreateFrontend(task_runner_), 101 fetcher_backend_->CreateFrontend(task_runner_),
102 store_.get())); 102 store_.get()));
103 ASSERT_EQ(store_->policy().end(), store_->policy().begin()); 103 ASSERT_EQ(store_->policy().end(), store_->policy().begin());
104 104
105 builder_.policy_data().set_policy_type( 105 builder_.policy_data().set_policy_type(
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } // namespace policy 335 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698