Index: chrome/browser/component_updater/test/component_updater_service_unittest.cc |
diff --git a/chrome/browser/component_updater/test/component_updater_service_unittest.cc b/chrome/browser/component_updater/test/component_updater_service_unittest.cc |
index 6db95a9efa0262bdcd910c60a1e4594f6331febb..218021b1150b1e027bf4a0b8728ffb902d7b195f 100644 |
--- a/chrome/browser/component_updater/test/component_updater_service_unittest.cc |
+++ b/chrome/browser/component_updater/test/component_updater_service_unittest.cc |
@@ -380,7 +380,7 @@ TEST_F(ComponentUpdaterTest, InstallCrx) { |
EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type); |
TestNotificationTracker::Event ev4 = notification_tracker().at(4); |
- EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type); |
+ EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev4.type); |
component_updater()->Stop(); |
} |
@@ -452,7 +452,7 @@ TEST_F(ComponentUpdaterTest, InstallCrxTwoSources) { |
EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type); |
TestNotificationTracker::Event ev4 = notification_tracker().at(5); |
- EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type); |
+ EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev4.type); |
component_updater()->Stop(); |
} |
@@ -493,3 +493,81 @@ TEST_F(ComponentUpdaterTest, ProdVersionCheck) { |
component_updater()->Stop(); |
} |
+ |
+// Test that a ping for an update check can cause installs. |
+// Here is the timeline: |
+// - First loop: we return a reply that indicates no update, so |
+// nothing happens. |
+// - We ping. |
+// - This triggers a second loop, which has a reply that triggers an install. |
+TEST_F(ComponentUpdaterTest, PingUpdateCheck) { |
+ MessageLoop message_loop; |
+ content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
+ content::TestBrowserThread file_thread(BrowserThread::FILE); |
+ content::TestBrowserThread io_thread(BrowserThread::IO); |
+ |
+ io_thread.StartIOThread(); |
+ file_thread.Start(); |
+ |
+ content::URLRequestPrepackagedInterceptor interceptor; |
+ |
+ CrxComponent com1; |
+ RegisterComponent(&com1, kTestComponent_jebg, Version("0.9")); |
+ CrxComponent com2; |
+ RegisterComponent(&com2, kTestComponent_abag, Version("2.2")); |
+ |
+ // The first the URL requests info for every registered component. |
+ const GURL expected_update_url_1( |
+ "http://localhost/upd?extra=foo&x=id%3D" |
+ "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D" |
+ "abagagagagagagagagagagagagagagag%26v%3D2.2%26uc"); |
+ |
+ // The second the URL only requests info for the pinged component. |
+ const GURL expected_update_url_2( |
+ "http://localhost/upd?extra=foo&x=id%3D" |
+ "jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc"); |
+ |
+ interceptor.SetResponse(expected_update_url_1, |
+ test_file("updatecheck_reply_empty")); |
+ interceptor.SetResponse(expected_update_url_2, |
+ test_file("updatecheck_reply_1.xml")); |
+ interceptor.SetResponse(GURL(expected_crx_url), |
+ test_file("jebgalgnebhfojomionfpkfelancnnkf.crx")); |
+ |
+ test_configurator()->SetLoopCount(1); |
+ |
+ component_updater()->Start(); |
+ message_loop.Run(); |
+ |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->error()); |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->install_count()); |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->error()); |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->install_count()); |
+ |
+ EXPECT_EQ(ComponentUpdateService::kOk, |
+ component_updater()->PingUpdateCheck(com1)); |
+ message_loop.Run(); |
+ |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com1.installer)->error()); |
+ EXPECT_EQ(1, static_cast<TestInstaller*>(com1.installer)->install_count()); |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->error()); |
+ EXPECT_EQ(0, static_cast<TestInstaller*>(com2.installer)->install_count()); |
+ |
+ EXPECT_EQ(3, interceptor.GetHitCount()); |
+ |
+ ASSERT_EQ(5ul, notification_tracker().size()); |
+ |
+ TestNotificationTracker::Event ev1 = notification_tracker().at(1); |
+ EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev1.type); |
+ |
+ TestNotificationTracker::Event ev2 = notification_tracker().at(2); |
+ EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, ev2.type); |
+ |
+ TestNotificationTracker::Event ev3 = notification_tracker().at(3); |
+ EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATE_READY, ev3.type); |
+ |
+ TestNotificationTracker::Event ev4 = notification_tracker().at(4); |
+ EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev4.type); |
+ |
+ component_updater()->Stop(); |
+} |