1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/update_client/test/test_configurator.h"
7 #include "base/run_loop.h"
8 #include "base/version.h"
9 #include "components/update_client/component_patcher_operation.h"
12 namespace update_client
{
16 std::vector
<GURL
> MakeDefaultUrls() {
17 std::vector
<GURL
> urls
;
18 urls
.push_back(GURL(POST_INTERCEPT_SCHEME
19 "://" POST_INTERCEPT_HOSTNAME POST_INTERCEPT_PATH
));
25 TestConfigurator::TestConfigurator(
26 const scoped_refptr
<base::SequencedTaskRunner
>& worker_task_runner
,
27 const scoped_refptr
<base::SingleThreadTaskRunner
>& network_task_runner
)
28 : worker_task_runner_(worker_task_runner
),
33 context_(new net::TestURLRequestContextGetter(network_task_runner
)) {
36 TestConfigurator::~TestConfigurator() {
39 int TestConfigurator::InitialDelay() const {
43 int TestConfigurator::NextCheckDelay() {
44 // This is called when a new full cycle of checking for updates is going
45 // to happen. In test we normally only test one cycle so it is a good
46 // time to break from the test messageloop Run() method so the test can
55 int TestConfigurator::StepDelay() const {
59 int TestConfigurator::StepDelayMedium() {
60 return NextCheckDelay();
63 int TestConfigurator::MinimumReCheckWait() const {
67 int TestConfigurator::OnDemandDelay() const {
68 return ondemand_time_
;
71 std::vector
<GURL
> TestConfigurator::UpdateUrl() const {
72 return MakeDefaultUrls();
75 std::vector
<GURL
> TestConfigurator::PingUrl() const {
79 base::Version
TestConfigurator::GetBrowserVersion() const {
80 // Needs to be larger than the required version in tested component manifests.
81 return base::Version("30.0");
84 std::string
TestConfigurator::GetChannel() const {
85 return "fake_channel_string";
88 std::string
TestConfigurator::GetLang() const {
92 std::string
TestConfigurator::GetOSLongName() const {
93 return "Fake Operating System";
96 std::string
TestConfigurator::ExtraRequestParams() const {
97 return "extra=\"foo\"";
100 size_t TestConfigurator::UrlSizeLimit() const {
104 net::URLRequestContextGetter
* TestConfigurator::RequestContext() const {
105 return context_
.get();
108 scoped_refptr
<OutOfProcessPatcher
> TestConfigurator::CreateOutOfProcessPatcher()
113 bool TestConfigurator::DeltasEnabled() const {
117 bool TestConfigurator::UseBackgroundDownloader() const {
121 // Set how many update checks are called, the default value is just once.
122 void TestConfigurator::SetLoopCount(int times
) {
126 void TestConfigurator::SetRecheckTime(int seconds
) {
127 recheck_time_
= seconds
;
130 void TestConfigurator::SetOnDemandTime(int seconds
) {
131 ondemand_time_
= seconds
;
134 void TestConfigurator::SetQuitClosure(const base::Closure
& quit_closure
) {
135 quit_closure_
= quit_closure
;
138 void TestConfigurator::SetInitialDelay(int seconds
) {
139 initial_time_
= seconds
;
142 scoped_refptr
<base::SequencedTaskRunner
>
143 TestConfigurator::GetSequencedTaskRunner() const {
144 DCHECK(worker_task_runner_
.get());
145 return worker_task_runner_
;
148 scoped_refptr
<base::SingleThreadTaskRunner
>
149 TestConfigurator::GetSingleThreadTaskRunner() const {
150 // This is NULL because tests do not use the background downloader.
154 } // namespace update_client