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

Unified Diff: content/renderer/manifest/manifest_parser_unittest.cc

Issue 919293002: Add related_applications field to manifest parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: content/renderer/manifest/manifest_parser_unittest.cc
diff --git a/content/renderer/manifest/manifest_parser_unittest.cc b/content/renderer/manifest/manifest_parser_unittest.cc
index 362177eb0511119d4c3efd1fc8ea92dcce9f4254..dd241145cc0e9d06724ae7df442d32e0ce0f0719 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -877,4 +877,93 @@ TEST_F(ManifestParserTest, GCMUserVisibleOnlyParseRules) {
}
}
+TEST_F(ManifestParserTest, ChromeRelatedApplicationsParseRules) {
+ // If no application, empty list.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "]}");
mlamouri (slow - plz ping) 2015/02/16 20:20:40 nit: maybe keep it on one line?
benwells 2015/02/16 23:58:43 Done.
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 0u);
+ EXPECT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // If empty application, empty list.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "{}]}");
mlamouri (slow - plz ping) 2015/02/16 20:20:40 nit: ditto
benwells 2015/02/16 23:58:43 Done.
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 0u);
+ EXPECT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // If invalid package, application is ignored.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "{\"platform\": \"foo\"}]}");
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 0u);
+ EXPECT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(1u, GetErrorCount());
+ EXPECT_EQ("Manifest parsing error: unknown 'platform' value ignored.",
+ errors()[0]);
+ }
+
+ // If missing platform, application is ignored.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "{\"id\": \"foo\"}]}");
mlamouri (slow - plz ping) 2015/02/16 20:20:40 Seems like an error in that case would be good.
mlamouri (slow - plz ping) 2015/02/16 20:20:40 Seems like an error in that case would be good.
benwells 2015/02/16 23:58:43 Done.
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 0u);
+ EXPECT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
mlamouri (slow - plz ping) 2015/02/16 20:20:40 Could you add a test where you have two invalid pa
benwells 2015/02/16 23:58:43 Done.
+ // Web application, without id.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "{\"platform\": \"web\"}]}");
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 1u);
+ EXPECT_EQ(manifest.chrome_related_applications[0].platform,
+ Manifest::RELATED_APPLICATION_PLATFORM_WEB);
+ EXPECT_TRUE(manifest.chrome_related_applications[0].id.is_null());
+ EXPECT_FALSE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // Android application, with id.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "{\"platform\": \"android\", \"id\": \"foo\"}]}");
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 1u);
+ EXPECT_EQ(manifest.chrome_related_applications[0].platform,
+ Manifest::RELATED_APPLICATION_PLATFORM_ANDROID);
+ EXPECT_TRUE(EqualsASCII(manifest.chrome_related_applications[0].id.string(),
+ "foo"));
+ EXPECT_FALSE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // All valid applications are in list.
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"chrome_related_applications\": ["
+ "{\"platform\": \"android\", \"id\": \"foo\"},"
+ "{\"platform\": \"web\"}]}");
+ EXPECT_EQ(manifest.chrome_related_applications.size(), 2u);
+ EXPECT_EQ(manifest.chrome_related_applications[0].platform,
+ Manifest::RELATED_APPLICATION_PLATFORM_ANDROID);
+ EXPECT_TRUE(EqualsASCII(manifest.chrome_related_applications[0].id.string(),
+ "foo"));
+ EXPECT_EQ(manifest.chrome_related_applications[1].platform,
+ Manifest::RELATED_APPLICATION_PLATFORM_WEB);
+ EXPECT_TRUE(manifest.chrome_related_applications[1].id.is_null());
+ EXPECT_FALSE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+}
+
} // namespace content
« content/renderer/manifest/manifest_parser.cc ('K') | « content/renderer/manifest/manifest_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698