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

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

Issue 15908002: Differential updates for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync to LKGR revision 207804. Created 7 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/component_updater/component_updater_service.h"
6
7 #include <list> 5 #include <list>
8 #include <utility> 6 #include <utility>
9
10 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
11 #include "base/file_util.h" 8 #include "base/file_util.h"
12 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
13 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
14 #include "base/message_loop.h" 11 #include "base/message_loop.h"
15 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stringprintf.h"
14 #include "base/strings/string_number_conversions.h"
16 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/component_updater/component_updater_service.h"
17 #include "chrome/browser/component_updater/test/component_patcher_mock.h"
18 #include "chrome/browser/component_updater/test/component_updater_service_unitte st.h"
19 #include "chrome/browser/component_updater/test/test_installer.h"
17 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
19 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
21 #include "content/public/test/test_browser_thread.h" 24 #include "content/public/test/test_browser_thread.h"
22 #include "content/public/test/test_notification_tracker.h" 25 #include "content/public/test/test_notification_tracker.h"
23 #include "content/test/net/url_request_prepackaged_interceptor.h" 26 #include "content/test/net/url_request_prepackaged_interceptor.h"
24 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
25 #include "libxml/globals.h" 28 #include "libxml/globals.h"
29 #include "net/base/upload_bytes_element_reader.h"
26 #include "net/url_request/url_fetcher.h" 30 #include "net/url_request/url_fetcher.h"
31 #include "net/url_request/url_request.h"
32 #include "net/url_request/url_request_filter.h"
33 #include "net/url_request/url_request_simple_job.h"
27 #include "net/url_request/url_request_test_util.h" 34 #include "net/url_request/url_request_test_util.h"
28 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
29 36
30 using content::BrowserThread; 37 using content::BrowserThread;
31 using content::TestNotificationTracker; 38 using content::TestNotificationTracker;
32 39
33 namespace { 40 TestConfigurator::TestConfigurator()
34 // Overrides some of the component updater behaviors so it is easier to test 41 : times_(1), recheck_time_(0), ondemand_time_(0), cus_(NULL) {
35 // and loops faster. In actual usage it takes hours do to a full cycle. 42 }
36 class TestConfigurator : public ComponentUpdateService::Configurator {
37 public:
38 TestConfigurator()
39 : times_(1), recheck_time_(0), ondemand_time_(0), cus_(NULL) {
40 }
41 43
42 virtual int InitialDelay() OVERRIDE { return 0; } 44 TestConfigurator::~TestConfigurator() {
45 }
43 46
44 typedef std::pair<CrxComponent*, int> CheckAtLoopCount; 47 int TestConfigurator::InitialDelay() { return 0; }
45 48
46 virtual int NextCheckDelay() OVERRIDE { 49 int TestConfigurator::NextCheckDelay() {
47 // This is called when a new full cycle of checking for updates is going 50 // This is called when a new full cycle of checking for updates is going
48 // to happen. In test we normally only test one cycle so it is a good 51 // to happen. In test we normally only test one cycle so it is a good
49 // time to break from the test messageloop Run() method so the test can 52 // time to break from the test messageloop Run() method so the test can
50 // finish. 53 // finish.
51 if (--times_ <= 0) { 54 if (--times_ <= 0) {
52 base::MessageLoop::current()->Quit(); 55 base::MessageLoop::current()->Quit();
53 return 0;
54
55 }
56
57 // Look for checks to issue in the middle of the loop.
58 for (std::list<CheckAtLoopCount>::iterator
59 i = components_to_check_.begin();
60 i != components_to_check_.end(); ) {
61 if (i->second == times_) {
62 cus_->CheckForUpdateSoon(*i->first);
63 i = components_to_check_.erase(i);
64 } else {
65 ++i;
66 }
67 }
68 return 1;
69 }
70
71 virtual int StepDelay() OVERRIDE {
72 return 0; 56 return 0;
73 } 57 }
74 58
75 virtual int MinimumReCheckWait() OVERRIDE { 59 // Look for checks to issue in the middle of the loop.
76 return recheck_time_; 60 for (std::list<CheckAtLoopCount>::iterator
61 i = components_to_check_.begin();
62 i != components_to_check_.end(); ) {
63 if (i->second == times_) {
64 cus_->CheckForUpdateSoon(*i->first);
65 i = components_to_check_.erase(i);
66 } else {
67 ++i;
68 }
77 } 69 }
70 return 1;
71 }
78 72
79 virtual int OnDemandDelay() OVERRIDE { 73 int TestConfigurator::StepDelay() {
80 return ondemand_time_; 74 return 0;
81 } 75 }
82 76
83 virtual GURL UpdateUrl(CrxComponent::UrlSource source) OVERRIDE { 77 int TestConfigurator::MinimumReCheckWait() {
84 switch (source) { 78 return recheck_time_;
85 case CrxComponent::BANDAID: 79 }
86 return GURL("http://localhost/upd");
87 case CrxComponent::CWS_PUBLIC:
88 return GURL("http://localhost/cws");
89 default:
90 return GURL("http://wronghost/bad");
91 };
92 }
93 80
94 virtual const char* ExtraRequestParams() OVERRIDE { return "extra=foo"; } 81 int TestConfigurator::OnDemandDelay() {
82 return ondemand_time_;
83 }
95 84
96 virtual size_t UrlSizeLimit() OVERRIDE { return 256; } 85 GURL TestConfigurator::UpdateUrl(CrxComponent::UrlSource source) {
86 switch (source) {
87 case CrxComponent::BANDAID:
88 return GURL("http://localhost/upd");
89 case CrxComponent::CWS_PUBLIC:
90 return GURL("http://localhost/cws");
91 default:
92 return GURL("http://wronghost/bad");
93 };
94 }
97 95
98 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE { 96 const char* TestConfigurator::ExtraRequestParams() { return "extra=foo"; }
99 return new net::TestURLRequestContextGetter(
100 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
101 }
102 97
103 // Don't use the utility process to decode files. 98 size_t TestConfigurator::UrlSizeLimit() { return 256; }
104 virtual bool InProcess() OVERRIDE { return true; }
105 99
106 virtual void OnEvent(Events event, int extra) OVERRIDE { } 100 net::URLRequestContextGetter* TestConfigurator::RequestContext() {
101 return new net::TestURLRequestContextGetter(
102 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
103 }
107 104
108 // Set how many update checks are called, the default value is just once. 105 // Don't use the utility process to decode files.
109 void SetLoopCount(int times) { times_ = times; } 106 bool TestConfigurator::InProcess() { return true; }
110 107
111 void SetRecheckTime(int seconds) { 108 void TestConfigurator::OnEvent(Events event, int extra) { }
112 recheck_time_ = seconds;
113 }
114 109
115 void SetOnDemandTime(int seconds) { 110 ComponentPatcher* TestConfigurator::CreateComponentPatcher() {
116 ondemand_time_ = seconds; 111 return new MockComponentPatcher();
117 } 112 }
118 113
119 void AddComponentToCheck(CrxComponent* com, int at_loop_iter) { 114 bool TestConfigurator::DeltasEnabled() const {
120 components_to_check_.push_back(std::make_pair(com, at_loop_iter)); 115 return true;
121 } 116 }
122 117
123 void SetComponentUpdateService(ComponentUpdateService* cus) { 118 // Set how many update checks are called, the default value is just once.
124 cus_ = cus; 119 void TestConfigurator::SetLoopCount(int times) { times_ = times; }
125 }
126 120
127 private: 121 void TestConfigurator::SetRecheckTime(int seconds) {
128 int times_; 122 recheck_time_ = seconds;
129 int recheck_time_; 123 }
130 int ondemand_time_;
131 124
132 std::list<CheckAtLoopCount> components_to_check_; 125 void TestConfigurator::SetOnDemandTime(int seconds) {
133 ComponentUpdateService* cus_; 126 ondemand_time_ = seconds;
134 }; 127 }
135 128
136 class TestInstaller : public ComponentInstaller { 129 void TestConfigurator::AddComponentToCheck(CrxComponent* com,
137 public : 130 int at_loop_iter) {
138 explicit TestInstaller() 131 components_to_check_.push_back(std::make_pair(com, at_loop_iter));
139 : error_(0), install_count_(0) { 132 }
140 }
141 133
142 virtual void OnUpdateError(int error) OVERRIDE { 134 void TestConfigurator::SetComponentUpdateService(ComponentUpdateService* cus) {
143 EXPECT_NE(0, error); 135 cus_ = cus;
144 error_ = error; 136 }
145 }
146 137
147 virtual bool Install(const base::DictionaryValue& manifest, 138 ComponentUpdaterTest::ComponentUpdaterTest() : test_config_(NULL) {
148 const base::FilePath& unpack_path) OVERRIDE { 139 // The component updater instance under test.
149 ++install_count_; 140 test_config_ = new TestConfigurator;
150 return file_util::Delete(unpack_path, true); 141 component_updater_.reset(ComponentUpdateServiceFactory(test_config_));
151 } 142 test_config_->SetComponentUpdateService(component_updater_.get());
143 // The test directory is chrome/test/data/components.
144 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
145 test_data_dir_ = test_data_dir_.AppendASCII("components");
152 146
153 int error() const { return error_; } 147 // Subscribe to all component updater notifications.
154 148 const int notifications[] = {
155 int install_count() const { return install_count_; } 149 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED,
156 150 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING,
157 private: 151 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND,
158 int error_; 152 chrome::NOTIFICATION_COMPONENT_UPDATE_READY
159 int install_count_;
160 };
161
162 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and
163 // the RSA public key the following hash:
164 const uint8 jebg_hash[] = {0x94,0x16,0x0b,0x6d,0x41,0x75,0xe9,0xec,0x8e,0xd5,
165 0xfa,0x54,0xb0,0xd2,0xdd,0xa5,0x6e,0x05,0x6b,0xe8,
166 0x73,0x47,0xf6,0xc4,0x11,0x9f,0xbc,0xb3,0x09,0xb3,
167 0x5b,0x40};
168 // component 2 has extension id "abagagagagagagagagagagagagagagag", and
169 // the RSA public key the following hash:
170 const uint8 abag_hash[] = {0x01,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
171 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
172 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
173 0x06,0x01};
174
175 const char expected_crx_url[] =
176 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
177
178 } // namespace
179
180 // Common fixture for all the component updater tests.
181 class ComponentUpdaterTest : public testing::Test {
182 public:
183 enum TestComponents {
184 kTestComponent_abag,
185 kTestComponent_jebg
186 }; 153 };
187 154
188 ComponentUpdaterTest() : test_config_(NULL) { 155 for (int ix = 0; ix != arraysize(notifications); ++ix) {
189 // The component updater instance under test. 156 notification_tracker_.ListenFor(
190 test_config_ = new TestConfigurator; 157 notifications[ix], content::NotificationService::AllSources());
191 component_updater_.reset(ComponentUpdateServiceFactory(test_config_)); 158 }
192 test_config_->SetComponentUpdateService(component_updater_.get()); 159 net::URLFetcher::SetEnableInterceptionForTests(true);
193 // The test directory is chrome/test/data/components. 160 }
194 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
195 test_data_dir_ = test_data_dir_.AppendASCII("components");
196 161
197 // Subscribe to all component updater notifications. 162 ComponentUpdaterTest::~ComponentUpdaterTest() {
198 const int notifications[] = { 163 net::URLFetcher::SetEnableInterceptionForTests(false);
199 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, 164 }
200 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING,
201 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND,
202 chrome::NOTIFICATION_COMPONENT_UPDATE_READY
203 };
204 165
205 for (int ix = 0; ix != arraysize(notifications); ++ix) { 166 void ComponentUpdaterTest::TearDown() {
206 notification_tracker_.ListenFor( 167 xmlCleanupGlobals();
207 notifications[ix], content::NotificationService::AllSources()); 168 }
208 }
209 net::URLFetcher::SetEnableInterceptionForTests(true);
210 }
211 169
212 virtual ~ComponentUpdaterTest() { 170 ComponentUpdateService* ComponentUpdaterTest::component_updater() {
213 net::URLFetcher::SetEnableInterceptionForTests(false); 171 return component_updater_.get();
214 } 172 }
215
216 virtual void TearDown() {
217 xmlCleanupGlobals();
218 }
219
220 ComponentUpdateService* component_updater() {
221 return component_updater_.get();
222 }
223 173
224 // Makes the full path to a component updater test file. 174 // Makes the full path to a component updater test file.
225 const base::FilePath test_file(const char* file) { 175 const base::FilePath ComponentUpdaterTest::test_file(const char* file) {
226 return test_data_dir_.AppendASCII(file); 176 return test_data_dir_.AppendASCII(file);
177 }
178
179 TestNotificationTracker& ComponentUpdaterTest::notification_tracker() {
180 return notification_tracker_;
181 }
182
183 TestConfigurator* ComponentUpdaterTest::test_configurator() {
184 return test_config_;
185 }
186
187 ComponentUpdateService::Status ComponentUpdaterTest::RegisterComponent(
188 CrxComponent* com,
189 TestComponents component,
190 const Version& version,
191 TestInstaller* installer) {
192 if (component == kTestComponent_abag) {
193 com->name = "test_abag";
194 com->pk_hash.assign(abag_hash, abag_hash + arraysize(abag_hash));
195 } else if (component == kTestComponent_jebg) {
196 com->name = "test_jebg";
197 com->pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
198 } else {
199 com->name = "test_ihfo";
200 com->pk_hash.assign(ihfo_hash, ihfo_hash + arraysize(ihfo_hash));
227 } 201 }
228 202 com->version = version;
229 TestNotificationTracker& notification_tracker() { 203 com->installer = installer;
230 return notification_tracker_; 204 return component_updater_->RegisterComponent(*com);
231 } 205 }
232
233 TestConfigurator* test_configurator() {
234 return test_config_;
235 }
236
237 ComponentUpdateService::Status RegisterComponent(CrxComponent* com,
238 TestComponents component,
239 const Version& version) {
240 if (component == kTestComponent_abag) {
241 com->name = "test_abag";
242 com->pk_hash.assign(abag_hash, abag_hash + arraysize(abag_hash));
243 } else {
244 com->name = "test_jebg";
245 com->pk_hash.assign(jebg_hash, jebg_hash + arraysize(jebg_hash));
246 }
247 com->version = version;
248 TestInstaller* installer = new TestInstaller;
249 com->installer = installer;
250 test_installers_.push_back(installer);
251 return component_updater_->RegisterComponent(*com);
252 }
253
254 private:
255 scoped_ptr<ComponentUpdateService> component_updater_;
256 base::FilePath test_data_dir_;
257 TestNotificationTracker notification_tracker_;
258 TestConfigurator* test_config_;
259 // ComponentInstaller objects to delete after each test.
260 ScopedVector<TestInstaller> test_installers_;
261 };
262 206
263 // Verify that our test fixture work and the component updater can 207 // Verify that our test fixture work and the component updater can
264 // be created and destroyed with no side effects. 208 // be created and destroyed with no side effects.
265 TEST_F(ComponentUpdaterTest, VerifyFixture) { 209 TEST_F(ComponentUpdaterTest, VerifyFixture) {
266 EXPECT_TRUE(component_updater() != NULL); 210 EXPECT_TRUE(component_updater() != NULL);
267 EXPECT_EQ(0ul, notification_tracker().size()); 211 EXPECT_EQ(0ul, notification_tracker().size());
268 } 212 }
269 213
270 // Verify that the component updater can be caught in a quick 214 // Verify that the component updater can be caught in a quick
271 // start-shutdown situation. Failure of this test will be a crash. Also 215 // start-shutdown situation. Failure of this test will be a crash. Also
(...skipping 16 matching lines...) Expand all
288 base::MessageLoop message_loop; 232 base::MessageLoop message_loop;
289 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 233 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
290 content::TestBrowserThread file_thread(BrowserThread::FILE); 234 content::TestBrowserThread file_thread(BrowserThread::FILE);
291 content::TestBrowserThread io_thread(BrowserThread::IO); 235 content::TestBrowserThread io_thread(BrowserThread::IO);
292 236
293 io_thread.StartIOThread(); 237 io_thread.StartIOThread();
294 file_thread.Start(); 238 file_thread.Start();
295 239
296 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 240 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
297 241
242 TestInstaller installer;
298 CrxComponent com; 243 CrxComponent com;
299 EXPECT_EQ(ComponentUpdateService::kOk, 244 EXPECT_EQ(ComponentUpdateService::kOk,
300 RegisterComponent(&com, kTestComponent_abag, Version("1.1"))); 245 RegisterComponent(&com,
246 kTestComponent_abag,
247 Version("1.1"),
248 &installer));
301 249
302 const GURL expected_update_url( 250 const GURL expected_update_url(
303 "http://localhost/upd?extra=foo&x=id%3D" 251 "http://localhost/upd?extra=foo"
304 "abagagagagagagagagagagagagagagag%26v%3D1.1%26uc"); 252 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D1.1%26fp%3D%26uc");
305 253
306 interceptor.SetResponse(expected_update_url, 254 interceptor.SetResponse(expected_update_url,
307 test_file("updatecheck_reply_1.xml")); 255 test_file("updatecheck_reply_1.xml"));
308 256
309 // We loop twice, but there are no updates so we expect two sleep messages. 257 // We loop twice, but there are no updates so we expect two sleep messages.
310 test_configurator()->SetLoopCount(2); 258 test_configurator()->SetLoopCount(2);
311 component_updater()->Start(); 259 component_updater()->Start();
312 260
313 ASSERT_EQ(1ul, notification_tracker().size()); 261 ASSERT_EQ(1ul, notification_tracker().size());
314 TestNotificationTracker::Event ev1 = notification_tracker().at(0); 262 TestNotificationTracker::Event ev1 = notification_tracker().at(0);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 base::MessageLoop message_loop; 315 base::MessageLoop message_loop;
368 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 316 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
369 content::TestBrowserThread file_thread(BrowserThread::FILE); 317 content::TestBrowserThread file_thread(BrowserThread::FILE);
370 content::TestBrowserThread io_thread(BrowserThread::IO); 318 content::TestBrowserThread io_thread(BrowserThread::IO);
371 319
372 io_thread.StartIOThread(); 320 io_thread.StartIOThread();
373 file_thread.Start(); 321 file_thread.Start();
374 322
375 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 323 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
376 324
325 TestInstaller installer1;
377 CrxComponent com1; 326 CrxComponent com1;
378 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); 327 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9"), &installer1);
328 TestInstaller installer2;
379 CrxComponent com2; 329 CrxComponent com2;
380 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); 330 RegisterComponent(&com2, kTestComponent_abag, Version("2.2"), &installer2);
381 331
382 const GURL expected_update_url_1( 332 const GURL expected_update_url_1(
383 "http://localhost/upd?extra=foo&x=id%3D" 333 "http://localhost/upd?extra=foo"
384 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" 334 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26fp%3D%26uc"
385 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); 335 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc");
386 336
387 const GURL expected_update_url_2( 337 const GURL expected_update_url_2(
388 "http://localhost/upd?extra=foo&x=id%3D" 338 "http://localhost/upd?extra=foo"
389 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" 339 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc"
390 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26uc"); 340 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26fp%3D%26uc");
391 341
392 interceptor.SetResponse(expected_update_url_1, 342 interceptor.SetResponse(expected_update_url_1,
393 test_file("updatecheck_reply_1.xml")); 343 test_file("updatecheck_reply_1.xml"));
394 interceptor.SetResponse(expected_update_url_2, 344 interceptor.SetResponse(expected_update_url_2,
395 test_file("updatecheck_reply_1.xml")); 345 test_file("updatecheck_reply_1.xml"));
396 interceptor.SetResponse(GURL(expected_crx_url), 346 interceptor.SetResponse(GURL(expected_crx_url),
397 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); 347 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"));
398 348
399 test_configurator()->SetLoopCount(2); 349 test_configurator()->SetLoopCount(2);
400 350
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 base::MessageLoop message_loop; 382 base::MessageLoop message_loop;
433 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 383 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
434 content::TestBrowserThread file_thread(BrowserThread::FILE); 384 content::TestBrowserThread file_thread(BrowserThread::FILE);
435 content::TestBrowserThread io_thread(BrowserThread::IO); 385 content::TestBrowserThread io_thread(BrowserThread::IO);
436 386
437 io_thread.StartIOThread(); 387 io_thread.StartIOThread();
438 file_thread.Start(); 388 file_thread.Start();
439 389
440 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 390 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
441 391
392 TestInstaller installer1;
442 CrxComponent com1; 393 CrxComponent com1;
443 RegisterComponent(&com1, kTestComponent_abag, Version("2.2")); 394 RegisterComponent(&com1, kTestComponent_abag, Version("2.2"), &installer1);
395 TestInstaller installer2;
444 CrxComponent com2; 396 CrxComponent com2;
445 com2.source = CrxComponent::CWS_PUBLIC; 397 com2.source = CrxComponent::CWS_PUBLIC;
446 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9")); 398 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9"), &installer2);
447 399
448 const GURL expected_update_url_1( 400 const GURL expected_update_url_1(
449 "http://localhost/upd?extra=foo&x=id%3D" 401 "http://localhost/upd?extra=foo&x=id%3D"
450 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); 402 "abagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc");
451 403
452 const GURL expected_update_url_2( 404 const GURL expected_update_url_2(
453 "http://localhost/cws?extra=foo&x=id%3D" 405 "http://localhost/cws?extra=foo&x=id%3D"
454 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); 406 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26fp%3D%26uc");
455 407
456 interceptor.SetResponse(expected_update_url_1, 408 interceptor.SetResponse(expected_update_url_1,
457 test_file("updatecheck_reply_3.xml")); 409 test_file("updatecheck_reply_3.xml"));
458 interceptor.SetResponse(expected_update_url_2, 410 interceptor.SetResponse(expected_update_url_2,
459 test_file("updatecheck_reply_1.xml")); 411 test_file("updatecheck_reply_1.xml"));
460 interceptor.SetResponse(GURL(expected_crx_url), 412 interceptor.SetResponse(GURL(expected_crx_url),
461 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); 413 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"));
462 414
463 test_configurator()->SetLoopCount(3); 415 test_configurator()->SetLoopCount(3);
464 416
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 base::MessageLoop message_loop; 456 base::MessageLoop message_loop;
505 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 457 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
506 content::TestBrowserThread file_thread(BrowserThread::FILE); 458 content::TestBrowserThread file_thread(BrowserThread::FILE);
507 content::TestBrowserThread io_thread(BrowserThread::IO); 459 content::TestBrowserThread io_thread(BrowserThread::IO);
508 460
509 io_thread.StartIOThread(); 461 io_thread.StartIOThread();
510 file_thread.Start(); 462 file_thread.Start();
511 463
512 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 464 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
513 465
466 TestInstaller installer;
514 CrxComponent com; 467 CrxComponent com;
515 RegisterComponent(&com, kTestComponent_jebg, Version("0.9")); 468 RegisterComponent(&com, kTestComponent_jebg, Version("0.9"), &installer);
516 469
517 const GURL expected_update_url( 470 const GURL expected_update_url(
518 "http://localhost/upd?extra=foo&x=id%3D" 471 "http://localhost/upd?extra=foo&x=id%3D"
519 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); 472 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26fp%3D%26uc");
520 473
521 interceptor.SetResponse(expected_update_url, 474 interceptor.SetResponse(expected_update_url,
522 test_file("updatecheck_reply_2.xml")); 475 test_file("updatecheck_reply_2.xml"));
523 interceptor.SetResponse(GURL(expected_crx_url), 476 interceptor.SetResponse(GURL(expected_crx_url),
524 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); 477 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"));
525 478
526 test_configurator()->SetLoopCount(1); 479 test_configurator()->SetLoopCount(1);
527 component_updater()->Start(); 480 component_updater()->Start();
528 message_loop.Run(); 481 message_loop.Run();
529 482
(...skipping 14 matching lines...) Expand all
544 base::MessageLoop message_loop; 497 base::MessageLoop message_loop;
545 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 498 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
546 content::TestBrowserThread file_thread(BrowserThread::FILE); 499 content::TestBrowserThread file_thread(BrowserThread::FILE);
547 content::TestBrowserThread io_thread(BrowserThread::IO); 500 content::TestBrowserThread io_thread(BrowserThread::IO);
548 501
549 io_thread.StartIOThread(); 502 io_thread.StartIOThread();
550 file_thread.Start(); 503 file_thread.Start();
551 504
552 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 505 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
553 506
507 TestInstaller installer1;
554 CrxComponent com1; 508 CrxComponent com1;
555 RegisterComponent(&com1, kTestComponent_abag, Version("2.2")); 509 RegisterComponent(&com1, kTestComponent_abag, Version("2.2"), &installer1);
510 TestInstaller installer2;
556 CrxComponent com2; 511 CrxComponent com2;
557 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9")); 512 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9"), &installer2);
558 513
559 const GURL expected_update_url_1( 514 const GURL expected_update_url_1(
560 "http://localhost/upd?extra=foo&x=id%3D" 515 "http://localhost/upd?extra=foo"
561 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" 516 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc"
562 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); 517 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26fp%3D%26uc");
563 518
564 const GURL expected_update_url_2( 519 const GURL expected_update_url_2(
565 "http://localhost/upd?extra=foo&x=id%3D" 520 "http://localhost/upd?extra=foo"
566 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" 521 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26fp%3D%26uc"
567 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); 522 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc");
568 523
569 interceptor.SetResponse(expected_update_url_1, 524 interceptor.SetResponse(expected_update_url_1,
570 test_file("updatecheck_reply_empty")); 525 test_file("updatecheck_reply_empty"));
571 interceptor.SetResponse(expected_update_url_2, 526 interceptor.SetResponse(expected_update_url_2,
572 test_file("updatecheck_reply_1.xml")); 527 test_file("updatecheck_reply_1.xml"));
573 interceptor.SetResponse(GURL(expected_crx_url), 528 interceptor.SetResponse(GURL(expected_crx_url),
574 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); 529 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"));
575 // Test success. 530 // Test success.
576 test_configurator()->SetLoopCount(2); 531 test_configurator()->SetLoopCount(2);
577 test_configurator()->AddComponentToCheck(&com2, 1); 532 test_configurator()->AddComponentToCheck(&com2, 1);
(...skipping 28 matching lines...) Expand all
606 test_configurator()->SetOnDemandTime(60 * 60); 561 test_configurator()->SetOnDemandTime(60 * 60);
607 EXPECT_EQ(ComponentUpdateService::kError, 562 EXPECT_EQ(ComponentUpdateService::kError,
608 component_updater()->CheckForUpdateSoon(com2)); 563 component_updater()->CheckForUpdateSoon(com2));
609 // Okay, now reset to 0 for the other tests. 564 // Okay, now reset to 0 for the other tests.
610 test_configurator()->SetOnDemandTime(0); 565 test_configurator()->SetOnDemandTime(0);
611 component_updater()->Stop(); 566 component_updater()->Stop();
612 567
613 // Test a few error cases. NOTE: We don't have callbacks for 568 // Test a few error cases. NOTE: We don't have callbacks for
614 // when the updates failed yet. 569 // when the updates failed yet.
615 const GURL expected_update_url_3( 570 const GURL expected_update_url_3(
616 "http://localhost/upd?extra=foo&x=id%3D" 571 "http://localhost/upd?extra=foo"
617 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26uc&x=id%3D" 572 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26fp%3D%26uc"
618 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); 573 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc");
619 574
620 // No update: error from no server response 575 // No update: error from no server response
621 interceptor.SetResponse(expected_update_url_3, 576 interceptor.SetResponse(expected_update_url_3,
622 test_file("updatecheck_reply_empty")); 577 test_file("updatecheck_reply_empty"));
623 notification_tracker().Reset(); 578 notification_tracker().Reset();
624 test_configurator()->SetLoopCount(1); 579 test_configurator()->SetLoopCount(1);
625 component_updater()->Start(); 580 component_updater()->Start();
626 EXPECT_EQ(ComponentUpdateService::kOk, 581 EXPECT_EQ(ComponentUpdateService::kOk,
627 component_updater()->CheckForUpdateSoon(com2)); 582 component_updater()->CheckForUpdateSoon(com2));
628 583
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 base::MessageLoop message_loop; 615 base::MessageLoop message_loop;
661 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); 616 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
662 content::TestBrowserThread file_thread(BrowserThread::FILE); 617 content::TestBrowserThread file_thread(BrowserThread::FILE);
663 content::TestBrowserThread io_thread(BrowserThread::IO); 618 content::TestBrowserThread io_thread(BrowserThread::IO);
664 619
665 io_thread.StartIOThread(); 620 io_thread.StartIOThread();
666 file_thread.Start(); 621 file_thread.Start();
667 622
668 content::URLLocalHostRequestPrepackagedInterceptor interceptor; 623 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
669 624
625 TestInstaller installer1;
670 CrxComponent com1; 626 CrxComponent com1;
671 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); 627 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9"), &installer1);
628 TestInstaller installer2;
672 CrxComponent com2; 629 CrxComponent com2;
673 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); 630 RegisterComponent(&com2, kTestComponent_abag, Version("2.2"), &installer2);
674 631
675 // Start with 0.9, and update to 1.0 632 // Start with 0.9, and update to 1.0
676 const GURL expected_update_url_1( 633 const GURL expected_update_url_1(
677 "http://localhost/upd?extra=foo&x=id%3D" 634 "http://localhost/upd?extra=foo"
678 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" 635 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26fp%3D%26uc"
679 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); 636 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc");
680 637
681 const GURL expected_update_url_2( 638 const GURL expected_update_url_2(
682 "http://localhost/upd?extra=foo&x=id%3D" 639 "http://localhost/upd?extra=foo"
683 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" 640 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc"
684 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26uc"); 641 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26fp%3D%26uc");
685 642
686 interceptor.SetResponse(expected_update_url_1, 643 interceptor.SetResponse(expected_update_url_1,
687 test_file("updatecheck_reply_1.xml")); 644 test_file("updatecheck_reply_1.xml"));
688 interceptor.SetResponse(expected_update_url_2, 645 interceptor.SetResponse(expected_update_url_2,
689 test_file("updatecheck_reply_1.xml")); 646 test_file("updatecheck_reply_1.xml"));
690 interceptor.SetResponse(GURL(expected_crx_url), 647 interceptor.SetResponse(GURL(expected_crx_url),
691 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); 648 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"));
692 649
693 // Loop twice to issue two checks: (1) with original 0.9 version 650 // Loop twice to issue two checks: (1) with original 0.9 version
694 // and (2) with the updated 1.0 version. 651 // and (2) with the updated 1.0 version.
(...skipping 20 matching lines...) Expand all
715 TestNotificationTracker::Event ev2 = notification_tracker().at(2); 672 TestNotificationTracker::Event ev2 = notification_tracker().at(2);
716 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATE_READY, ev2.type); 673 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATE_READY, ev2.type);
717 674
718 TestNotificationTracker::Event ev3 = notification_tracker().at(3); 675 TestNotificationTracker::Event ev3 = notification_tracker().at(3);
719 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type); 676 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type);
720 677
721 TestNotificationTracker::Event ev4 = notification_tracker().at(4); 678 TestNotificationTracker::Event ev4 = notification_tracker().at(4);
722 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev4.type); 679 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev4.type);
723 680
724 // Now re-register, pretending to be an even newer version (2.2) 681 // Now re-register, pretending to be an even newer version (2.2)
682 TestInstaller installer3;
725 component_updater()->Stop(); 683 component_updater()->Stop();
726 EXPECT_EQ(ComponentUpdateService::kReplaced, 684 EXPECT_EQ(ComponentUpdateService::kReplaced,
727 RegisterComponent(&com1, kTestComponent_jebg, Version("2.2"))); 685 RegisterComponent(&com1,
686 kTestComponent_jebg,
687 Version("2.2"),
688 &installer3));
728 689
729 // Check that we send out 2.2 as our version. 690 // Check that we send out 2.2 as our version.
730 // Interceptor's hit count should go up by 1. 691 // Interceptor's hit count should go up by 1.
731 const GURL expected_update_url_3( 692 const GURL expected_update_url_3(
732 "http://localhost/upd?extra=foo&x=id%3D" 693 "http://localhost/upd?extra=foo"
733 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D2.2%26uc&x=id%3D" 694 "&x=id%3Djebgalgnebhfojomionfpkfelancnnkf%26v%3D2.2%26fp%3D%26uc"
734 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); 695 "&x=id%3Dabagagagagagagagagagagagagagagag%26v%3D2.2%26fp%3D%26uc");
735 696
736 interceptor.SetResponse(expected_update_url_3, 697 interceptor.SetResponse(expected_update_url_3,
737 test_file("updatecheck_reply_1.xml")); 698 test_file("updatecheck_reply_1.xml"));
738 699
739 notification_tracker().Reset(); 700 notification_tracker().Reset();
740 701
741 // Loop once just to notice the check happening with the re-register version. 702 // Loop once just to notice the check happening with the re-register version.
742 test_configurator()->SetLoopCount(1); 703 test_configurator()->SetLoopCount(1);
743 component_updater()->Start(); 704 component_updater()->Start();
744 message_loop.Run(); 705 message_loop.Run();
745 706
746 ASSERT_EQ(2ul, notification_tracker().size()); 707 ASSERT_EQ(2ul, notification_tracker().size());
747 708
748 ev0 = notification_tracker().at(0); 709 ev0 = notification_tracker().at(0);
749 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, ev0.type); 710 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, ev0.type);
750 711
751 ev1 = notification_tracker().at(1); 712 ev1 = notification_tracker().at(1);
752 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev1.type); 713 EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev1.type);
753 714
754 EXPECT_EQ(4, interceptor.GetHitCount()); 715 EXPECT_EQ(4, interceptor.GetHitCount());
755 716
756 // The test harness's Register() function creates a new installer, 717 // We created a new installer, so the counts go back to 0.
757 // so the counts go back to 0.
758 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->error()); 718 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->error());
759 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->install_count()); 719 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->install_count());
760 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->error()); 720 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->error());
761 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->install_count()); 721 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->install_count());
762 722
763 component_updater()->Stop(); 723 component_updater()->Stop();
764 } 724 }
725
726 // Verify that component installation falls back to downloading and installing
727 // a full update if the differential update fails (in this case, because the
728 // installer does not know about the existing files). We do two loops; the final
729 // loop should do nothing.
730 // We also check that exactly 4 network requests are issued:
731 // 1- update check (loop 1)
732 // 2- download differential crx
733 // 3- download full crx
734 // 4- update check (loop 2 - no update available)
735 TEST_F(ComponentUpdaterTest, DifferentialUpdateFails) {
736 base::MessageLoop message_loop;
737 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
738 content::TestBrowserThread file_thread(BrowserThread::FILE);
739 content::TestBrowserThread io_thread(BrowserThread::IO);
740
741 io_thread.StartIOThread();
742 file_thread.Start();
743
744 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
745
746 TestInstaller installer;
747 CrxComponent com;
748 RegisterComponent(&com, kTestComponent_ihfo, Version("1.0"), &installer);
749
750 const GURL expected_update_url_1(
751 "http://localhost/upd?extra=foo"
752 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D1.0%26fp%3D%26uc");
753 const GURL expected_update_url_2(
754 "http://localhost/upd?extra=foo"
755 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D2.0%26fp%3Df22%26uc");
756 const GURL expected_crx_url_1(
757 "http://localhost/download/ihfokbkgjpifnbbojhneepfflplebdkc_1.crx");
758 const GURL expected_crx_url_1_diff_2(
759 "http://localhost/download/ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx");
760 const GURL expected_crx_url_2(
761 "http://localhost/download/ihfokbkgjpifnbbojhneepfflplebdkc_2.crx");
762
763 interceptor.SetResponse(expected_update_url_1,
764 test_file("updatecheck_diff_reply_2.xml"));
765 interceptor.SetResponse(expected_update_url_2,
766 test_file("updatecheck_diff_reply_3.xml"));
767 interceptor.SetResponse(expected_crx_url_1,
768 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1.crx"));
769 interceptor.SetResponse(
770 expected_crx_url_1_diff_2,
771 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx"));
772 interceptor.SetResponse(expected_crx_url_2,
773 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_2.crx"));
774
775 test_configurator()->SetLoopCount(2);
776
777 component_updater()->Start();
778 message_loop.Run();
779
780 // A failed differential update does not count as a failed install.
781 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error());
782 EXPECT_EQ(1, static_cast<TestInstaller*>(com.installer)->install_count());
783
784 EXPECT_EQ(4, interceptor.GetHitCount());
785
786 component_updater()->Stop();
787 }
788
789 // Verify that we successfully propagate a patcher error.
790 // ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad.crx contains an incorrect
791 // patching instruction that should fail.
792 TEST_F(ComponentUpdaterTest, DifferentialUpdateFailErrorcode) {
793 base::MessageLoop message_loop;
794 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
795 content::TestBrowserThread file_thread(BrowserThread::FILE);
796 content::TestBrowserThread io_thread(BrowserThread::IO);
797
798 io_thread.StartIOThread();
799 file_thread.Start();
800
801 content::URLLocalHostRequestPrepackagedInterceptor interceptor;
802
803 VersionedTestInstaller installer;
804 CrxComponent com;
805 RegisterComponent(&com, kTestComponent_ihfo, Version("0.0"), &installer);
806
807 const GURL expected_update_url_0(
808 "http://localhost/upd?extra=foo"
809 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D0.0%26fp%3D%26uc");
810 const GURL expected_update_url_1(
811 "http://localhost/upd?extra=foo"
812 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D1.0%26fp%3D1%26uc");
813 const GURL expected_update_url_2(
814 "http://localhost/upd?extra=foo"
815 "&x=id%3Dihfokbkgjpifnbbojhneepfflplebdkc%26v%3D2.0%26fp%3Df22%26uc");
816 const GURL expected_crx_url_1(
817 "http://localhost/download/ihfokbkgjpifnbbojhneepfflplebdkc_1.crx");
818 const GURL expected_crx_url_1_diff_2(
819 "http://localhost/download/ihfokbkgjpifnbbojhneepfflplebdkc_1to2.crx");
820 const GURL expected_crx_url_2(
821 "http://localhost/download/ihfokbkgjpifnbbojhneepfflplebdkc_2.crx");
822
823 interceptor.SetResponse(expected_update_url_0,
824 test_file("updatecheck_diff_reply_1.xml"));
825 interceptor.SetResponse(expected_update_url_1,
826 test_file("updatecheck_diff_reply_2.xml"));
827 interceptor.SetResponse(expected_update_url_2,
828 test_file("updatecheck_diff_reply_3.xml"));
829 interceptor.SetResponse(expected_crx_url_1,
830 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1.crx"));
831 interceptor.SetResponse(
832 expected_crx_url_1_diff_2,
833 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_1to2_bad.crx"));
834 interceptor.SetResponse(expected_crx_url_2,
835 test_file("ihfokbkgjpifnbbojhneepfflplebdkc_2.crx"));
836
837 test_configurator()->SetLoopCount(3);
838
839 component_updater()->Start();
840 message_loop.Run();
841
842 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error());
843 EXPECT_EQ(2, static_cast<TestInstaller*>(com.installer)->install_count());
844
845 EXPECT_EQ(6, interceptor.GetHitCount());
846
847 component_updater()->Stop();
848 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698