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 37de9217f8db89d87743254655078cf0345aeb7f..c96b2551e28f1ebfd595d34f49e2219e200ca0f4 100644 |
--- a/chrome/browser/component_updater/test/component_updater_service_unittest.cc |
+++ b/chrome/browser/component_updater/test/component_updater_service_unittest.cc |
@@ -128,6 +128,32 @@ void TestConfigurator::SetComponentUpdateService(ComponentUpdateService* cus) { |
cus_ = cus; |
} |
+TestUpdateNotificationTracker::TestUpdateNotificationTracker() {} |
+ |
+TestUpdateNotificationTracker::~TestUpdateNotificationTracker() {} |
+ |
+std::string TestUpdateNotificationTracker::SourceAt(size_t num) { |
+ return sources_[num]; |
+} |
+ |
+void TestUpdateNotificationTracker::Observe( |
+ int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) { |
+ if (type == chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND |
+ || type == chrome::NOTIFICATION_COMPONENT_UPDATE_READY) { |
+ sources_.push_back(std::string( |
+ *content::Source<std::string>(source).ptr())); |
+ } else |
+ sources_.push_back(std::string()); |
+ TestNotificationTracker::Observe(type, source, details); |
+} |
+ |
+void TestUpdateNotificationTracker::Reset() { |
+ sources_.clear(); |
+ TestNotificationTracker::Reset(); |
+} |
+ |
ComponentUpdaterTest::ComponentUpdaterTest() : test_config_(NULL) { |
// The component updater instance under test. |
test_config_ = new TestConfigurator; |
@@ -169,7 +195,7 @@ const base::FilePath ComponentUpdaterTest::test_file(const char* file) { |
return test_data_dir_.AppendASCII(file); |
} |
-TestNotificationTracker& ComponentUpdaterTest::notification_tracker() { |
+TestUpdateNotificationTracker& ComponentUpdaterTest::notification_tracker() { |
return notification_tracker_; |
} |
@@ -354,10 +380,22 @@ TEST_F(ComponentUpdaterTest, InstallCrx) { |
ASSERT_EQ(5ul, notification_tracker().size()); |
TestNotificationTracker::Event ev1 = notification_tracker().at(1); |
+ std::string source1 = notification_tracker().SourceAt(1); |
EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, ev1.type); |
+ // Check that the UPDATE_FOUND is for com1. |
+ EXPECT_FALSE(ComponentUpdateService::IsUpdateNotificationForComponent( |
+ content::Source<std::string>(&source1), com2)); |
+ EXPECT_TRUE(ComponentUpdateService::IsUpdateNotificationForComponent( |
+ content::Source<std::string>(&source1), com1)); |
TestNotificationTracker::Event ev2 = notification_tracker().at(2); |
+ std::string source2 = notification_tracker().SourceAt(2); |
EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATE_READY, ev2.type); |
+ // Check that the UPDATE_READY is for com1. |
+ EXPECT_FALSE(ComponentUpdateService::IsUpdateNotificationForComponent( |
+ content::Source<std::string>(&source2), com2)); |
+ EXPECT_TRUE(ComponentUpdateService::IsUpdateNotificationForComponent( |
+ content::Source<std::string>(&source2), com1)); |
TestNotificationTracker::Event ev3 = notification_tracker().at(3); |
EXPECT_EQ(chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, ev3.type); |