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_configurator.h"
7 #include "base/version.h"
8 #include "components/update_client/component_patcher_operation.h"
11 namespace update_client
{
15 std::vector
<GURL
> MakeDefaultUrls() {
16 std::vector
<GURL
> urls
;
17 urls
.push_back(GURL(POST_INTERCEPT_SCHEME
18 "://" POST_INTERCEPT_HOSTNAME POST_INTERCEPT_PATH
));
24 TestConfigurator::TestConfigurator(
25 const scoped_refptr
<base::SequencedTaskRunner
>& worker_task_runner
,
26 const scoped_refptr
<base::SingleThreadTaskRunner
>& network_task_runner
)
27 : worker_task_runner_(worker_task_runner
),
30 context_(new net::TestURLRequestContextGetter(network_task_runner
)) {
33 TestConfigurator::~TestConfigurator() {
36 int TestConfigurator::InitialDelay() const {
40 int TestConfigurator::NextCheckDelay() const {
44 int TestConfigurator::StepDelay() const {
48 int TestConfigurator::OnDemandDelay() const {
49 return ondemand_time_
;
52 int TestConfigurator::UpdateDelay() const {
56 std::vector
<GURL
> TestConfigurator::UpdateUrl() const {
57 return MakeDefaultUrls();
60 std::vector
<GURL
> TestConfigurator::PingUrl() const {
64 base::Version
TestConfigurator::GetBrowserVersion() const {
65 // Needs to be larger than the required version in tested component manifests.
66 return base::Version("30.0");
69 std::string
TestConfigurator::GetChannel() const {
70 return "fake_channel_string";
73 std::string
TestConfigurator::GetLang() const {
77 std::string
TestConfigurator::GetOSLongName() const {
78 return "Fake Operating System";
81 std::string
TestConfigurator::ExtraRequestParams() const {
82 return "extra=\"foo\"";
85 net::URLRequestContextGetter
* TestConfigurator::RequestContext() const {
86 return context_
.get();
89 scoped_refptr
<OutOfProcessPatcher
> TestConfigurator::CreateOutOfProcessPatcher()
94 bool TestConfigurator::DeltasEnabled() const {
98 bool TestConfigurator::UseBackgroundDownloader() const {
102 void TestConfigurator::SetOnDemandTime(int seconds
) {
103 ondemand_time_
= seconds
;
106 void TestConfigurator::SetInitialDelay(int seconds
) {
107 initial_time_
= seconds
;
110 scoped_refptr
<base::SequencedTaskRunner
>
111 TestConfigurator::GetSequencedTaskRunner() const {
112 DCHECK(worker_task_runner_
.get());
113 return worker_task_runner_
;
116 scoped_refptr
<base::SingleThreadTaskRunner
>
117 TestConfigurator::GetSingleThreadTaskRunner() const {
118 // This is NULL because tests do not use the background downloader.
122 } // namespace update_client