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

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

Issue 74893002: Changed the update protocol for component updater from v2 to v3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback from cdn@ Created 7 years, 1 month 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 <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "chrome/browser/component_updater/component_updater_service.h" 18 #include "chrome/browser/component_updater/component_updater_service.h"
19 #include "chrome/browser/component_updater/test/component_patcher_mock.h" 19 #include "chrome/browser/component_updater/test/component_patcher_mock.h"
20 #include "chrome/browser/component_updater/test/url_request_post_interceptor.h" 20 #include "chrome/browser/component_updater/test/url_request_post_interceptor.h"
21 #include "content/public/test/test_browser_thread_bundle.h" 21 #include "content/public/test/test_browser_thread_bundle.h"
22 #include "content/test/net/url_request_prepackaged_interceptor.h"
22 #include "net/url_request/url_request_test_util.h" 23 #include "net/url_request/url_request_test_util.h"
23 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 class TestInstaller; 27 class TestInstaller;
27 28
28 namespace component_updater { 29 namespace component_updater {
29 30
30 // Intercepts HTTP POST requests sent to |localhost2|. 31 // Intercepts HTTP GET requests sent to "localhost".
32 typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor;
33
34 // Intercepts HTTP POST requests sent to "localhost2".
31 class InterceptorFactory : public URLRequestPostInterceptorFactory { 35 class InterceptorFactory : public URLRequestPostInterceptorFactory {
32 public: 36 public:
33 InterceptorFactory(); 37 InterceptorFactory();
34 ~InterceptorFactory(); 38 ~InterceptorFactory();
35 39
36 URLRequestPostInterceptor* CreateInterceptor(); 40 URLRequestPostInterceptor* CreateInterceptor();
37 41
38 private: 42 private:
39 DISALLOW_COPY_AND_ASSIGN(InterceptorFactory); 43 DISALLOW_COPY_AND_ASSIGN(InterceptorFactory);
40 }; 44 };
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 ComponentUpdateService::Status RegisterComponent(CrxComponent* com, 145 ComponentUpdateService::Status RegisterComponent(CrxComponent* com,
142 TestComponents component, 146 TestComponents component,
143 const Version& version, 147 const Version& version,
144 TestInstaller* installer); 148 TestInstaller* installer);
145 149
146 protected: 150 protected:
147 void RunThreads(); 151 void RunThreads();
148 void RunThreadsUntilIdle(); 152 void RunThreadsUntilIdle();
149 153
150 scoped_ptr<component_updater::InterceptorFactory> interceptor_factory_; 154 scoped_ptr<component_updater::InterceptorFactory> interceptor_factory_;
155 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory.
151 156
157 scoped_ptr<GetInterceptor> get_interceptor_;
152 private: 158 private:
153 TestConfigurator* test_config_; 159 TestConfigurator* test_config_;
154 base::FilePath test_data_dir_; 160 base::FilePath test_data_dir_;
155 content::TestBrowserThreadBundle thread_bundle_; 161 content::TestBrowserThreadBundle thread_bundle_;
156 scoped_ptr<ComponentUpdateService> component_updater_; 162 scoped_ptr<ComponentUpdateService> component_updater_;
157 }; 163 };
158 164
159 const char expected_crx_url[] = 165 const char expected_crx_url[] =
160 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"; 166 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
161 167
162 class MockComponentObserver : public ComponentObserver { 168 class MockComponentObserver : public ComponentObserver {
163 public: 169 public:
164 MockComponentObserver(); 170 MockComponentObserver();
165 ~MockComponentObserver(); 171 ~MockComponentObserver();
166 MOCK_METHOD2(OnEvent, void(Events event, int extra)); 172 MOCK_METHOD2(OnEvent, void(Events event, int extra));
167 }; 173 };
168 174
169 class OnDemandTester { 175 class OnDemandTester {
170 public: 176 public:
171 static ComponentUpdateService::Status OnDemand( 177 static ComponentUpdateService::Status OnDemand(
172 ComponentUpdateService* cus, const std::string& component_id); 178 ComponentUpdateService* cus, const std::string& component_id);
173 }; 179 };
174 180
175 } // namespace component_updater 181 } // namespace component_updater
176 182
177 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT EST_H_ 183 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITT EST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698