Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1259)

Unified Diff: chrome/browser/component_updater/test/component_updater_service_unittest.cc

Issue 18006003: Consistently use notifications from component updater w/ on-demand PNaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698