| OLD | NEW |
| 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" | 5 #include "chrome/browser/component_updater/component_updater_service.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // are generated. | 287 // are generated. |
| 288 TEST_F(ComponentUpdaterTest, CheckCrxSleep) { | 288 TEST_F(ComponentUpdaterTest, CheckCrxSleep) { |
| 289 MessageLoop message_loop; | 289 MessageLoop message_loop; |
| 290 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 290 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 291 content::TestBrowserThread file_thread(BrowserThread::FILE); | 291 content::TestBrowserThread file_thread(BrowserThread::FILE); |
| 292 content::TestBrowserThread io_thread(BrowserThread::IO); | 292 content::TestBrowserThread io_thread(BrowserThread::IO); |
| 293 | 293 |
| 294 io_thread.StartIOThread(); | 294 io_thread.StartIOThread(); |
| 295 file_thread.Start(); | 295 file_thread.Start(); |
| 296 | 296 |
| 297 content::URLRequestPrepackagedInterceptor interceptor; | 297 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 298 | 298 |
| 299 CrxComponent com; | 299 CrxComponent com; |
| 300 EXPECT_EQ(ComponentUpdateService::kOk, | 300 EXPECT_EQ(ComponentUpdateService::kOk, |
| 301 RegisterComponent(&com, kTestComponent_abag, Version("1.1"))); | 301 RegisterComponent(&com, kTestComponent_abag, Version("1.1"))); |
| 302 | 302 |
| 303 const GURL expected_update_url( | 303 const GURL expected_update_url( |
| 304 "http://localhost/upd?extra=foo&x=id%3D" | 304 "http://localhost/upd?extra=foo&x=id%3D" |
| 305 "abagagagagagagagagagagagagagagag%26v%3D1.1%26uc"); | 305 "abagagagagagagagagagagagagagagag%26v%3D1.1%26uc"); |
| 306 | 306 |
| 307 interceptor.SetResponse(expected_update_url, | 307 interceptor.SetResponse(expected_update_url, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // 3- second manifest check. | 366 // 3- second manifest check. |
| 367 TEST_F(ComponentUpdaterTest, InstallCrx) { | 367 TEST_F(ComponentUpdaterTest, InstallCrx) { |
| 368 MessageLoop message_loop; | 368 MessageLoop message_loop; |
| 369 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 369 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 370 content::TestBrowserThread file_thread(BrowserThread::FILE); | 370 content::TestBrowserThread file_thread(BrowserThread::FILE); |
| 371 content::TestBrowserThread io_thread(BrowserThread::IO); | 371 content::TestBrowserThread io_thread(BrowserThread::IO); |
| 372 | 372 |
| 373 io_thread.StartIOThread(); | 373 io_thread.StartIOThread(); |
| 374 file_thread.Start(); | 374 file_thread.Start(); |
| 375 | 375 |
| 376 content::URLRequestPrepackagedInterceptor interceptor; | 376 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 377 | 377 |
| 378 CrxComponent com1; | 378 CrxComponent com1; |
| 379 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); | 379 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); |
| 380 CrxComponent com2; | 380 CrxComponent com2; |
| 381 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); | 381 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); |
| 382 | 382 |
| 383 const GURL expected_update_url_1( | 383 const GURL expected_update_url_1( |
| 384 "http://localhost/upd?extra=foo&x=id%3D" | 384 "http://localhost/upd?extra=foo&x=id%3D" |
| 385 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" | 385 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" |
| 386 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); | 386 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // checks to different urls, each only containing one component. | 431 // checks to different urls, each only containing one component. |
| 432 TEST_F(ComponentUpdaterTest, InstallCrxTwoSources) { | 432 TEST_F(ComponentUpdaterTest, InstallCrxTwoSources) { |
| 433 MessageLoop message_loop; | 433 MessageLoop message_loop; |
| 434 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 434 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 435 content::TestBrowserThread file_thread(BrowserThread::FILE); | 435 content::TestBrowserThread file_thread(BrowserThread::FILE); |
| 436 content::TestBrowserThread io_thread(BrowserThread::IO); | 436 content::TestBrowserThread io_thread(BrowserThread::IO); |
| 437 | 437 |
| 438 io_thread.StartIOThread(); | 438 io_thread.StartIOThread(); |
| 439 file_thread.Start(); | 439 file_thread.Start(); |
| 440 | 440 |
| 441 content::URLRequestPrepackagedInterceptor interceptor; | 441 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 442 | 442 |
| 443 CrxComponent com1; | 443 CrxComponent com1; |
| 444 RegisterComponent(&com1, kTestComponent_abag, Version("2.2")); | 444 RegisterComponent(&com1, kTestComponent_abag, Version("2.2")); |
| 445 CrxComponent com2; | 445 CrxComponent com2; |
| 446 com2.source = CrxComponent::CWS_PUBLIC; | 446 com2.source = CrxComponent::CWS_PUBLIC; |
| 447 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9")); | 447 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9")); |
| 448 | 448 |
| 449 const GURL expected_update_url_1( | 449 const GURL expected_update_url_1( |
| 450 "http://localhost/upd?extra=foo&x=id%3D" | 450 "http://localhost/upd?extra=foo&x=id%3D" |
| 451 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); | 451 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 // version is much higher than of chrome. | 503 // version is much higher than of chrome. |
| 504 TEST_F(ComponentUpdaterTest, ProdVersionCheck) { | 504 TEST_F(ComponentUpdaterTest, ProdVersionCheck) { |
| 505 MessageLoop message_loop; | 505 MessageLoop message_loop; |
| 506 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 506 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 507 content::TestBrowserThread file_thread(BrowserThread::FILE); | 507 content::TestBrowserThread file_thread(BrowserThread::FILE); |
| 508 content::TestBrowserThread io_thread(BrowserThread::IO); | 508 content::TestBrowserThread io_thread(BrowserThread::IO); |
| 509 | 509 |
| 510 io_thread.StartIOThread(); | 510 io_thread.StartIOThread(); |
| 511 file_thread.Start(); | 511 file_thread.Start(); |
| 512 | 512 |
| 513 content::URLRequestPrepackagedInterceptor interceptor; | 513 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 514 | 514 |
| 515 CrxComponent com; | 515 CrxComponent com; |
| 516 RegisterComponent(&com, kTestComponent_jebg, Version("0.9")); | 516 RegisterComponent(&com, kTestComponent_jebg, Version("0.9")); |
| 517 | 517 |
| 518 const GURL expected_update_url( | 518 const GURL expected_update_url( |
| 519 "http://localhost/upd?extra=foo&x=id%3D" | 519 "http://localhost/upd?extra=foo&x=id%3D" |
| 520 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); | 520 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); |
| 521 | 521 |
| 522 interceptor.SetResponse(expected_update_url, | 522 interceptor.SetResponse(expected_update_url, |
| 523 test_file("updatecheck_reply_2.xml")); | 523 test_file("updatecheck_reply_2.xml")); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 543 // - This triggers a second loop, which has a reply that triggers an install. | 543 // - This triggers a second loop, which has a reply that triggers an install. |
| 544 TEST_F(ComponentUpdaterTest, CheckForUpdateSoon) { | 544 TEST_F(ComponentUpdaterTest, CheckForUpdateSoon) { |
| 545 MessageLoop message_loop; | 545 MessageLoop message_loop; |
| 546 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 546 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 547 content::TestBrowserThread file_thread(BrowserThread::FILE); | 547 content::TestBrowserThread file_thread(BrowserThread::FILE); |
| 548 content::TestBrowserThread io_thread(BrowserThread::IO); | 548 content::TestBrowserThread io_thread(BrowserThread::IO); |
| 549 | 549 |
| 550 io_thread.StartIOThread(); | 550 io_thread.StartIOThread(); |
| 551 file_thread.Start(); | 551 file_thread.Start(); |
| 552 | 552 |
| 553 content::URLRequestPrepackagedInterceptor interceptor; | 553 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 554 | 554 |
| 555 CrxComponent com1; | 555 CrxComponent com1; |
| 556 RegisterComponent(&com1, kTestComponent_abag, Version("2.2")); | 556 RegisterComponent(&com1, kTestComponent_abag, Version("2.2")); |
| 557 CrxComponent com2; | 557 CrxComponent com2; |
| 558 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9")); | 558 RegisterComponent(&com2, kTestComponent_jebg, Version("0.9")); |
| 559 | 559 |
| 560 const GURL expected_update_url_1( | 560 const GURL expected_update_url_1( |
| 561 "http://localhost/upd?extra=foo&x=id%3D" | 561 "http://localhost/upd?extra=foo&x=id%3D" |
| 562 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" | 562 "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D" |
| 563 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); | 563 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 // with a different version. | 659 // with a different version. |
| 660 TEST_F(ComponentUpdaterTest, CheckReRegistration) { | 660 TEST_F(ComponentUpdaterTest, CheckReRegistration) { |
| 661 MessageLoop message_loop; | 661 MessageLoop message_loop; |
| 662 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 662 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 663 content::TestBrowserThread file_thread(BrowserThread::FILE); | 663 content::TestBrowserThread file_thread(BrowserThread::FILE); |
| 664 content::TestBrowserThread io_thread(BrowserThread::IO); | 664 content::TestBrowserThread io_thread(BrowserThread::IO); |
| 665 | 665 |
| 666 io_thread.StartIOThread(); | 666 io_thread.StartIOThread(); |
| 667 file_thread.Start(); | 667 file_thread.Start(); |
| 668 | 668 |
| 669 content::URLRequestPrepackagedInterceptor interceptor; | 669 content::URLLocalHostRequestPrepackagedInterceptor interceptor; |
| 670 | 670 |
| 671 CrxComponent com1; | 671 CrxComponent com1; |
| 672 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); | 672 RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); |
| 673 CrxComponent com2; | 673 CrxComponent com2; |
| 674 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); | 674 RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); |
| 675 | 675 |
| 676 // Start with 0.9, and update to 1.0 | 676 // Start with 0.9, and update to 1.0 |
| 677 const GURL expected_update_url_1( | 677 const GURL expected_update_url_1( |
| 678 "http://localhost/upd?extra=foo&x=id%3D" | 678 "http://localhost/upd?extra=foo&x=id%3D" |
| 679 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" | 679 "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 756 |
| 757 // The test harness's Register() function creates a new installer, | 757 // The test harness's Register() function creates a new installer, |
| 758 // so the counts go back to 0. | 758 // so the counts go back to 0. |
| 759 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->error()); | 759 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->error()); |
| 760 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->install_count()); | 760 EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->install_count()); |
| 761 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->error()); | 761 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->error()); |
| 762 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->install_count()); | 762 EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->install_count()); |
| 763 | 763 |
| 764 component_updater()->Stop(); | 764 component_updater()->Stop(); |
| 765 } | 765 } |
| OLD | NEW |