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.
7 #include "base/run_loop.h"
8 #include "base/version.h"
9 #include "chrome/browser/component_updater/component_patcher_operation.h"
10 #include "chrome/browser/component_updater/test/test_configurator.h"
11 #include "content/public/browser/browser_thread.h"
14 using content::BrowserThread;
16 namespace component_updater {
18 TestConfigurator::TestConfigurator()
23 context_(new net::TestURLRequestContextGetter(
24 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))) {
27 TestConfigurator::~TestConfigurator() {
30 int TestConfigurator::InitialDelay() const {
34 int TestConfigurator::NextCheckDelay() {
35 // This is called when a new full cycle of checking for updates is going
36 // to happen. In test we normally only test one cycle so it is a good
37 // time to break from the test messageloop Run() method so the test can
46 int TestConfigurator::StepDelay() const {
50 int TestConfigurator::StepDelayMedium() {
51 return NextCheckDelay();
54 int TestConfigurator::MinimumReCheckWait() const {
58 int TestConfigurator::OnDemandDelay() const {
59 return ondemand_time_;
62 GURL TestConfigurator::UpdateUrl() const {
63 return GURL(POST_INTERCEPT_SCHEME
64 "://" POST_INTERCEPT_HOSTNAME POST_INTERCEPT_PATH);
67 GURL TestConfigurator::PingUrl() const {
71 base::Version TestConfigurator::GetBrowserVersion() const {
72 // Needs to be larger than the required version in tested component manifests.
73 return base::Version("30.0");
76 std::string TestConfigurator::GetChannel() const {
77 return "fake_channel_string";
80 std::string TestConfigurator::GetLang() const {
84 std::string TestConfigurator::GetOSLongName() const {
85 return "Fake Operating System";
88 std::string TestConfigurator::ExtraRequestParams() const {
89 return "extra=\"foo\"";
92 size_t TestConfigurator::UrlSizeLimit() const {
96 net::URLRequestContextGetter* TestConfigurator::RequestContext() const {
97 return context_.get();
100 scoped_refptr<OutOfProcessPatcher> TestConfigurator::CreateOutOfProcessPatcher()
105 bool TestConfigurator::DeltasEnabled() const {
109 bool TestConfigurator::UseBackgroundDownloader() const {
113 // Set how many update checks are called, the default value is just once.
114 void TestConfigurator::SetLoopCount(int times) {
118 void TestConfigurator::SetRecheckTime(int seconds) {
119 recheck_time_ = seconds;
122 void TestConfigurator::SetOnDemandTime(int seconds) {
123 ondemand_time_ = seconds;
126 void TestConfigurator::SetQuitClosure(const base::Closure& quit_closure) {
127 quit_closure_ = quit_closure;
130 void TestConfigurator::SetInitialDelay(int seconds) {
131 initial_time_ = seconds;
134 scoped_refptr<base::SequencedTaskRunner>
135 TestConfigurator::GetSequencedTaskRunner() const {
136 return content::BrowserThread::GetBlockingPool()
137 ->GetSequencedTaskRunnerWithShutdownBehavior(
138 content::BrowserThread::GetBlockingPool()->GetSequenceToken(),
139 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
142 scoped_refptr<base::SingleThreadTaskRunner>
143 TestConfigurator::GetSingleThreadTaskRunner() const {
144 return content::BrowserThread::GetMessageLoopProxyForThread(
145 content::BrowserThread::FILE);
148 } // namespace component_updater