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

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: cleanup test a bit 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 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);

Powered by Google App Engine
This is Rietveld 408576698