Chromium Code Reviews| 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 |