Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / components / update_client / test / test_configurator.h
blob4943cca6685b255d967026d3881bf4851a4e7498
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 #ifndef COMPONENTS_UPDATE_CLIENT_TEST_TEST_CONFIGURATOR_H_
6 #define COMPONENTS_UPDATE_CLIENT_TEST_TEST_CONFIGURATOR_H_
8 #include <string>
9 #include <utility>
10 #include <vector>
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/update_client/configurator.h"
17 #include "net/url_request/url_request_test_util.h"
19 class GURL;
21 namespace base {
22 class SequencedTaskRunner;
23 class SingleThreadTaskRunner;
24 } // namespace base
26 namespace update_client {
28 #define POST_INTERCEPT_SCHEME "https"
29 #define POST_INTERCEPT_HOSTNAME "localhost2"
30 #define POST_INTERCEPT_PATH "/update2"
32 struct CrxComponent;
34 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and
35 // the RSA public key the following hash:
36 const uint8_t jebg_hash[] = {0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec,
37 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5,
38 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4,
39 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40};
40 // component 2 has extension id "abagagagagagagagagagagagagagagag", and
41 // the RSA public key the following hash:
42 const uint8_t abag_hash[] = {0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
43 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
44 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
45 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01};
46 // component 3 has extension id "ihfokbkgjpifnbbojhneepfflplebdkc", and
47 // the RSA public key the following hash:
48 const uint8_t ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e,
49 0x97, 0xd4, 0x4f, 0x55, 0xbf, 0xb4, 0x13, 0xa2,
50 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b,
51 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17};
53 class TestConfigurator : public Configurator {
54 public:
55 TestConfigurator(
56 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner,
57 const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
58 ~TestConfigurator() override;
60 // Overrrides for Configurator.
61 int InitialDelay() const override;
62 int NextCheckDelay() override;
63 int StepDelay() const override;
64 int StepDelayMedium() override;
65 int MinimumReCheckWait() const override;
66 int OnDemandDelay() const override;
67 std::vector<GURL> UpdateUrl() const override;
68 std::vector<GURL> PingUrl() const override;
69 base::Version GetBrowserVersion() const override;
70 std::string GetChannel() const override;
71 std::string GetLang() const override;
72 std::string GetOSLongName() const override;
73 std::string ExtraRequestParams() const override;
74 size_t UrlSizeLimit() const override;
75 net::URLRequestContextGetter* RequestContext() const override;
76 scoped_refptr<OutOfProcessPatcher> CreateOutOfProcessPatcher() const override;
77 bool DeltasEnabled() const override;
78 bool UseBackgroundDownloader() const override;
79 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
80 const override;
81 scoped_refptr<base::SingleThreadTaskRunner> GetSingleThreadTaskRunner()
82 const override;
84 void SetLoopCount(int times);
85 void SetRecheckTime(int seconds);
86 void SetOnDemandTime(int seconds);
87 void SetQuitClosure(const base::Closure& quit_closure);
88 void SetInitialDelay(int seconds);
90 private:
91 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
92 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
94 int initial_time_;
95 int times_;
96 int recheck_time_;
97 int ondemand_time_;
99 scoped_refptr<net::TestURLRequestContextGetter> context_;
100 base::Closure quit_closure_;
102 DISALLOW_COPY_AND_ASSIGN(TestConfigurator);
105 } // namespace update_client
107 #endif // COMPONENTS_UPDATE_CLIENT_TEST_TEST_CONFIGURATOR_H_