| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 5 #include "chrome/browser/component_updater/component_updater_service.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 virtual int StepDelay() OVERRIDE { | 49 virtual int StepDelay() OVERRIDE { |
| 50 return 0; | 50 return 0; |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual int MinimumReCheckWait() OVERRIDE { | 53 virtual int MinimumReCheckWait() OVERRIDE { |
| 54 return 0; | 54 return 0; |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual GURL UpdateUrl() OVERRIDE { return GURL("http://localhost/upd"); } | 57 virtual GURL UpdateUrl() OVERRIDE { return GURL("http://localhost/upd"); } |
| 58 | 58 |
| 59 virtual const char* ExtraRequestParams() OVERRIDE { return "extra=foo"; } |
| 60 |
| 59 virtual size_t UrlSizeLimit() OVERRIDE { return 256; } | 61 virtual size_t UrlSizeLimit() OVERRIDE { return 256; } |
| 60 | 62 |
| 61 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE { | 63 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE { |
| 62 return new TestURLRequestContextGetter(); | 64 return new TestURLRequestContextGetter(); |
| 63 } | 65 } |
| 64 | 66 |
| 65 // Don't use the utility process to decode files. | 67 // Don't use the utility process to decode files. |
| 66 virtual bool InProcess() OVERRIDE { return true; } | 68 virtual bool InProcess() OVERRIDE { return true; } |
| 67 | 69 |
| 68 virtual void OnEvent(Events event, int extra) OVERRIDE { } | 70 virtual void OnEvent(Events event, int extra) OVERRIDE { } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 io_thread.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); | 233 io_thread.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
| 232 file_thread.Start(); | 234 file_thread.Start(); |
| 233 | 235 |
| 234 scoped_refptr<ComponentUpdateInterceptor> | 236 scoped_refptr<ComponentUpdateInterceptor> |
| 235 interceptor(new ComponentUpdateInterceptor()); | 237 interceptor(new ComponentUpdateInterceptor()); |
| 236 | 238 |
| 237 CrxComponent com; | 239 CrxComponent com; |
| 238 RegisterComponent(&com, kTestComponent_abag, Version("1.1")); | 240 RegisterComponent(&com, kTestComponent_abag, Version("1.1")); |
| 239 | 241 |
| 240 const char expected_update_url[] = | 242 const char expected_update_url[] = |
| 241 "http://localhost/upd?x=id%3D" | 243 "http://localhost/upd?extra=foo&x=id%3D" |
| 242 "abagagagagagagagagagagagagagagag%26v%3D1.1%26uc"; | 244 "abagagagagagagagagagagagagagagag%26v%3D1.1%26uc"; |
| 243 | 245 |
| 244 interceptor->SetResponse(expected_update_url, | 246 interceptor->SetResponse(expected_update_url, |
| 245 header_ok_reply, | 247 header_ok_reply, |
| 246 test_file("updatecheck_reply_1.xml")); | 248 test_file("updatecheck_reply_1.xml")); |
| 247 | 249 |
| 248 // We loop twice, but there are no updates so we expect two sleep messages. | 250 // We loop twice, but there are no updates so we expect two sleep messages. |
| 249 test_configurator()->SetLoopCount(2); | 251 test_configurator()->SetLoopCount(2); |
| 250 component_updater()->Start(); | 252 component_updater()->Start(); |
| 251 | 253 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 319 |
| 318 scoped_refptr<ComponentUpdateInterceptor> | 320 scoped_refptr<ComponentUpdateInterceptor> |
| 319 interceptor(new ComponentUpdateInterceptor()); | 321 interceptor(new ComponentUpdateInterceptor()); |
| 320 | 322 |
| 321 CrxComponent com1; | 323 CrxComponent com1; |
| 322 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); | 324 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); |
| 323 CrxComponent com2; | 325 CrxComponent com2; |
| 324 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); | 326 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); |
| 325 | 327 |
| 326 const char expected_update_url_1[] = | 328 const char expected_update_url_1[] = |
| 327 "http://localhost/upd?x=id%3D" | 329 "http://localhost/upd?extra=foo&x=id%3D" |
| 328 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" | 330 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" |
| 329 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"; | 331 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"; |
| 330 | 332 |
| 331 const char expected_update_url_2[] = | 333 const char expected_update_url_2[] = |
| 332 "http://localhost/upd?x=id%3D" | 334 "http://localhost/upd?extra=foo&x=id%3D" |
| 333 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" | 335 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" |
| 334 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26uc"; | 336 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26uc"; |
| 335 | 337 |
| 336 interceptor->SetResponse(expected_update_url_1, header_ok_reply, | 338 interceptor->SetResponse(expected_update_url_1, header_ok_reply, |
| 337 test_file("updatecheck_reply_1.xml")); | 339 test_file("updatecheck_reply_1.xml")); |
| 338 interceptor->SetResponse(expected_update_url_2, header_ok_reply, | 340 interceptor->SetResponse(expected_update_url_2, header_ok_reply, |
| 339 test_file("updatecheck_reply_1.xml")); | 341 test_file("updatecheck_reply_1.xml")); |
| 340 interceptor->SetResponse(expected_crx_url, header_ok_reply, | 342 interceptor->SetResponse(expected_crx_url, header_ok_reply, |
| 341 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); | 343 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); |
| 342 | 344 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 io_thread.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); | 383 io_thread.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
| 382 file_thread.Start(); | 384 file_thread.Start(); |
| 383 | 385 |
| 384 scoped_refptr<ComponentUpdateInterceptor> | 386 scoped_refptr<ComponentUpdateInterceptor> |
| 385 interceptor(new ComponentUpdateInterceptor()); | 387 interceptor(new ComponentUpdateInterceptor()); |
| 386 | 388 |
| 387 CrxComponent com; | 389 CrxComponent com; |
| 388 RegisterComponent(&com, kTestComponent_jebg, Version("0.9")); | 390 RegisterComponent(&com, kTestComponent_jebg, Version("0.9")); |
| 389 | 391 |
| 390 const char expected_update_url[] = | 392 const char expected_update_url[] = |
| 391 "http://localhost/upd?x=id%3D" | 393 "http://localhost/upd?extra=foo&x=id%3D" |
| 392 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"; | 394 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"; |
| 393 | 395 |
| 394 interceptor->SetResponse(expected_update_url, | 396 interceptor->SetResponse(expected_update_url, |
| 395 header_ok_reply, | 397 header_ok_reply, |
| 396 test_file("updatecheck_reply_2.xml")); | 398 test_file("updatecheck_reply_2.xml")); |
| 397 interceptor->SetResponse(expected_crx_url, header_ok_reply, | 399 interceptor->SetResponse(expected_crx_url, header_ok_reply, |
| 398 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); | 400 test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); |
| 399 | 401 |
| 400 test_configurator()->SetLoopCount(1); | 402 test_configurator()->SetLoopCount(1); |
| 401 component_updater()->Start(); | 403 component_updater()->Start(); |
| 402 message_loop.Run(); | 404 message_loop.Run(); |
| 403 | 405 |
| 404 EXPECT_EQ(1, interceptor->hit_count()); | 406 EXPECT_EQ(1, interceptor->hit_count()); |
| 405 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); | 407 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->error()); |
| 406 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); | 408 EXPECT_EQ(0, static_cast<TestInstaller*>(com.installer)->install_count()); |
| 407 | 409 |
| 408 component_updater()->Stop(); | 410 component_updater()->Stop(); |
| 409 } | 411 } |
| OLD | NEW |