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

Unified Diff: components/update_client/update_response_unittest.cc

Issue 2847023002: Parse update check run actions for the component updater. (Closed)
Patch Set: Added missing data file dependency. Created 3 years, 8 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
« no previous file with comments | « components/update_client/update_response.cc ('k') | components/update_client/utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/update_response_unittest.cc
diff --git a/components/update_client/update_response_unittest.cc b/components/update_client/update_response_unittest.cc
index d29cbe0d5961194c5a8508f43ae6f332d7ffba51..42e844c7ca04b282dac8819cfd1c1ba32f2da468 100644
--- a/components/update_client/update_response_unittest.cc
+++ b/components/update_client/update_response_unittest.cc
@@ -241,6 +241,54 @@ const char* kTwoAppsSetCohort =
" </app>"
"</response>";
+// Includes a run action for an update check with status='ok'.
+const char* kUpdateCheckStatusOkWithRunAction =
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<response protocol='3.0'>"
+ " <app appid='12345'>"
+ " <updatecheck status='ok'>"
+ " <urls>"
+ " <url codebase='http://example.com/'/>"
+ " <url codebasediff='http://diff.example.com/'/>"
+ " </urls>"
+ " <manifest version='1.2.3.4' prodversionmin='2.0.143.0'>"
+ " <packages>"
+ " <package name='extension_1_2_3_4.crx'/>"
+ " </packages>"
+ " </manifest>"
+ " <actions>"
+ " <action run='this'/>"
+ " </actions>"
+ " </updatecheck>"
+ " </app>"
+ "</response>";
+
+// Includes a run action for an update check with status='noupdate'.
+const char* kUpdateCheckStatusNoUpdateWithRunAction =
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<response protocol='3.0'>"
+ " <app appid='12345'>"
+ " <updatecheck status='noupdate'>"
+ " <actions>"
+ " <action run='this'/>"
+ " </actions>"
+ " </updatecheck>"
+ " </app>"
+ "</response>";
+
+// Includes a run action for an update check with status='error'.
+const char* kUpdateCheckStatusErrorWithRunAction =
+ "<?xml version='1.0' encoding='UTF-8'?>"
+ "<response protocol='3.0'>"
+ " <app appid='12345' status='ok'>"
+ " <updatecheck status='error-osnotsupported'>"
+ " <actions>"
+ " <action run='this'/>"
+ " </actions>"
+ " </updatecheck>"
+ " </app>"
+ "</response>";
+
TEST(ComponentUpdaterUpdateResponseTest, TestParser) {
UpdateResponse parser;
@@ -361,6 +409,26 @@ TEST(ComponentUpdaterUpdateResponseTest, TestParser) {
EXPECT_EQ(secondResult->cohort_attrs.find("cohortname")->second, "cname");
EXPECT_EQ(secondResult->cohort_attrs.find("cohorthint"),
secondResult->cohort_attrs.end());
+
+ EXPECT_TRUE(parser.Parse(kUpdateCheckStatusOkWithRunAction));
+ EXPECT_TRUE(parser.errors().empty());
+ EXPECT_FALSE(parser.results().list.empty());
+ firstResult = &parser.results().list[0];
+ EXPECT_STREQ("ok", firstResult->status.c_str());
+ EXPECT_EQ(firstResult->extension_id, "12345");
+ EXPECT_STREQ("this", firstResult->action_run.c_str());
+
+ EXPECT_TRUE(parser.Parse(kUpdateCheckStatusNoUpdateWithRunAction));
+ EXPECT_TRUE(parser.errors().empty());
+ EXPECT_FALSE(parser.results().list.empty());
+ firstResult = &parser.results().list[0];
+ EXPECT_STREQ("noupdate", firstResult->status.c_str());
+ EXPECT_EQ(firstResult->extension_id, "12345");
+ EXPECT_STREQ("this", firstResult->action_run.c_str());
+
+ EXPECT_TRUE(parser.Parse(kUpdateCheckStatusErrorWithRunAction));
+ EXPECT_FALSE(parser.errors().empty());
+ EXPECT_TRUE(parser.results().list.empty());
}
} // namespace update_client
« no previous file with comments | « components/update_client/update_response.cc ('k') | components/update_client/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698