Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: chrome/browser/component_updater/test/component_updater_service_unittest.h

Issue 493953002: Componentize component_updater: Move a bunch of tests to component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST _H_ 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST _H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST _H_ 6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST _H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/component_updater/test/test_configurator.h"
15 #include "chrome/browser/component_updater/test/url_request_post_interceptor.h"
16 #include "components/component_updater/component_updater_service.h" 14 #include "components/component_updater/component_updater_service.h"
15 #include "components/component_updater/test/test_configurator.h"
16 #include "components/component_updater/test/url_request_post_interceptor.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 17 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "content/test/net/url_request_prepackaged_interceptor.h" 18 #include "content/test/net/url_request_prepackaged_interceptor.h"
19 #include "net/url_request/url_request_test_util.h" 19 #include "net/url_request/url_request_test_util.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace component_updater { 23 namespace component_updater {
24 24
25 class TestInstaller; 25 class TestInstaller;
26 26
27 // Intercepts HTTP GET requests sent to "localhost". 27 // Intercepts HTTP GET requests sent to "localhost".
28 typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor; 28 typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor;
29 29
30 // Intercepts HTTP POST requests sent to "localhost2".
31 class InterceptorFactory : public URLRequestPostInterceptorFactory {
32 public:
33 InterceptorFactory();
34 ~InterceptorFactory();
35
36 URLRequestPostInterceptor* CreateInterceptor();
37
38 private:
39 DISALLOW_COPY_AND_ASSIGN(InterceptorFactory);
40 };
41
42 class PartialMatch : public URLRequestPostInterceptor::RequestMatcher {
43 public:
44 explicit PartialMatch(const std::string& expected) : expected_(expected) {}
45 virtual bool Match(const std::string& actual) const OVERRIDE;
46
47 private:
48 const std::string expected_;
49
50 DISALLOW_COPY_AND_ASSIGN(PartialMatch);
51 };
52
53 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and
54 // the RSA public key the following hash:
55 const uint8 jebg_hash[] = {0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec,
56 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5,
57 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4,
58 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40};
59 // component 2 has extension id "abagagagagagagagagagagagagagagag", and
60 // the RSA public key the following hash:
61 const uint8 abag_hash[] = {0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
62 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
63 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
64 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01};
65 // component 3 has extension id "ihfokbkgjpifnbbojhneepfflplebdkc", and
66 // the RSA public key the following hash:
67 const uint8 ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e,
68 0x97, 0xd4, 0x4f, 0x55, 0xbf, 0xb4, 0x13, 0xa2,
69 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b,
70 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17};
71
72 class ComponentUpdaterTest : public testing::Test { 30 class ComponentUpdaterTest : public testing::Test {
73 public: 31 public:
74 enum TestComponents { 32 enum TestComponents {
75 kTestComponent_abag, 33 kTestComponent_abag,
76 kTestComponent_jebg, 34 kTestComponent_jebg,
77 kTestComponent_ihfo, 35 kTestComponent_ihfo,
78 }; 36 };
79 37
80 ComponentUpdaterTest(); 38 ComponentUpdaterTest();
81 39
(...skipping 19 matching lines...) Expand all
101 void RunThreads(); 59 void RunThreads();
102 void RunThreadsUntilIdle(); 60 void RunThreadsUntilIdle();
103 61
104 scoped_ptr<InterceptorFactory> interceptor_factory_; 62 scoped_ptr<InterceptorFactory> interceptor_factory_;
105 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory. 63 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory.
106 64
107 scoped_ptr<GetInterceptor> get_interceptor_; 65 scoped_ptr<GetInterceptor> get_interceptor_;
108 66
109 private: 67 private:
110 TestConfigurator* test_config_; 68 TestConfigurator* test_config_;
111 base::FilePath test_data_dir_;
112 content::TestBrowserThreadBundle thread_bundle_; 69 content::TestBrowserThreadBundle thread_bundle_;
113 scoped_ptr<ComponentUpdateService> component_updater_; 70 scoped_ptr<ComponentUpdateService> component_updater_;
114 }; 71 };
115 72
116 const char expected_crx_url[] = 73 const char expected_crx_url[] =
117 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"; 74 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
118 75
119 class MockServiceObserver : public ServiceObserver { 76 class MockServiceObserver : public ServiceObserver {
120 public: 77 public:
121 MockServiceObserver(); 78 MockServiceObserver();
122 ~MockServiceObserver(); 79 ~MockServiceObserver();
123 MOCK_METHOD2(OnEvent, void(Events event, const std::string&)); 80 MOCK_METHOD2(OnEvent, void(Events event, const std::string&));
124 }; 81 };
125 82
126 class OnDemandTester { 83 class OnDemandTester {
127 public: 84 public:
128 static ComponentUpdateService::Status OnDemand( 85 static ComponentUpdateService::Status OnDemand(
129 ComponentUpdateService* cus, 86 ComponentUpdateService* cus,
130 const std::string& component_id); 87 const std::string& component_id);
131 }; 88 };
132 89
133 } // namespace component_updater 90 } // namespace component_updater
134 91
135 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT EST_H_ 92 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT EST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698