Home | History | Annotate | Download | only in test
      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.
      4 
      5 #ifndef COMPONENTS_COMPONENT_UPDATER_TEST_TEST_CONFIGURATOR_H_
      6 #define COMPONENTS_COMPONENT_UPDATER_TEST_TEST_CONFIGURATOR_H_
      7 
      8 #include <string>
      9 #include <utility>
     10 #include <vector>
     11 
     12 #include "base/callback.h"
     13 #include "base/compiler_specific.h"
     14 #include "base/macros.h"
     15 #include "base/memory/ref_counted.h"
     16 #include "components/component_updater/component_updater_configurator.h"
     17 #include "net/url_request/url_request_test_util.h"
     18 
     19 class GURL;
     20 
     21 namespace base {
     22 class SequencedTaskRunner;
     23 class SingleThreadTaskRunner;
     24 }  // namespace base
     25 
     26 namespace component_updater {
     27 
     28 #define POST_INTERCEPT_SCHEME "https"
     29 #define POST_INTERCEPT_HOSTNAME "localhost2"
     30 #define POST_INTERCEPT_PATH "/update2"
     31 
     32 struct CrxComponent;
     33 
     34 class TestConfigurator : public Configurator {
     35  public:
     36   TestConfigurator(
     37       const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner,
     38       const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
     39   virtual ~TestConfigurator();
     40 
     41   // Overrrides for Configurator.
     42   virtual int InitialDelay() const OVERRIDE;
     43   virtual int NextCheckDelay() OVERRIDE;
     44   virtual int StepDelay() const OVERRIDE;
     45   virtual int StepDelayMedium() OVERRIDE;
     46   virtual int MinimumReCheckWait() const OVERRIDE;
     47   virtual int OnDemandDelay() const OVERRIDE;
     48   virtual std::vector<GURL> UpdateUrl() const OVERRIDE;
     49   virtual std::vector<GURL> PingUrl() const OVERRIDE;
     50   virtual base::Version GetBrowserVersion() const OVERRIDE;
     51   virtual std::string GetChannel() const OVERRIDE;
     52   virtual std::string GetLang() const OVERRIDE;
     53   virtual std::string GetOSLongName() const OVERRIDE;
     54   virtual std::string ExtraRequestParams() const OVERRIDE;
     55   virtual size_t UrlSizeLimit() const OVERRIDE;
     56   virtual net::URLRequestContextGetter* RequestContext() const OVERRIDE;
     57   virtual scoped_refptr<OutOfProcessPatcher> CreateOutOfProcessPatcher()
     58       const OVERRIDE;
     59   virtual bool DeltasEnabled() const OVERRIDE;
     60   virtual bool UseBackgroundDownloader() const OVERRIDE;
     61   virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
     62       const OVERRIDE;
     63   virtual scoped_refptr<base::SingleThreadTaskRunner>
     64       GetSingleThreadTaskRunner() const OVERRIDE;
     65 
     66   void SetLoopCount(int times);
     67   void SetRecheckTime(int seconds);
     68   void SetOnDemandTime(int seconds);
     69   void SetQuitClosure(const base::Closure& quit_closure);
     70   void SetInitialDelay(int seconds);
     71 
     72  private:
     73   scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
     74   scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
     75 
     76   int initial_time_;
     77   int times_;
     78   int recheck_time_;
     79   int ondemand_time_;
     80 
     81   scoped_refptr<net::TestURLRequestContextGetter> context_;
     82   base::Closure quit_closure_;
     83 
     84   DISALLOW_COPY_AND_ASSIGN(TestConfigurator);
     85 };
     86 
     87 }  // namespace component_updater
     88 
     89 #endif  // COMPONENTS_COMPONENT_UPDATER_TEST_TEST_CONFIGURATOR_H_
     90