| 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 a1fc17b5f512c8ef753734129322924c39d22c4e..6bac66b75e83b768d532483705fa48f24113727d 100644
|
| --- a/chrome/browser/component_updater/test/component_updater_service_unittest.cc
|
| +++ b/chrome/browser/component_updater/test/component_updater_service_unittest.cc
|
| @@ -135,6 +135,34 @@ void TestConfigurator::SetComponentUpdateService(ComponentUpdateService* cus) {
|
| cus_ = cus;
|
| }
|
|
|
| +TestUpdateNotificationTracker::TestUpdateNotificationTracker() {}
|
| +
|
| +TestUpdateNotificationTracker::~TestUpdateNotificationTracker() {}
|
| +
|
| +ComponentUpdateService::UpdateSource
|
| +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(ComponentUpdateService::UpdateSource(
|
| + *content::Source<ComponentUpdateService::UpdateSource>(
|
| + source).ptr()));
|
| + } else
|
| + sources_.push_back(ComponentUpdateService::UpdateSource());
|
| + 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;
|
| @@ -176,7 +204,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_;
|
| }
|
|
|
| @@ -361,10 +389,24 @@ TEST_F(ComponentUpdaterTest, InstallCrx) {
|
| ASSERT_EQ(5ul, notification_tracker().size());
|
|
|
| TestNotificationTracker::Event ev1 = notification_tracker().at(1);
|
| + ComponentUpdateService::UpdateSource 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);
|
| + ComponentUpdateService::UpdateSource 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);
|
|
|