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

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

Issue 2637003002: Add share_target field to Manifest. (Closed)
Patch Set: Doc update and clean up Created 3 years, 11 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 8b21c69d5d3e225f69d251ff3cd8e447bfada1a8..14a4310d6c6c51474fc55ddc7af0c1d9a3f6b396 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -982,6 +982,58 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
}
}
+TEST_F(ManifestParserTest, ShareTargetParseRules) {
+ // Contains share_target field but no keys.
+ {
+ Manifest manifest = ParseManifest("{ \"share_target\": {} }");
+ EXPECT_TRUE(manifest.share_target.is_null());
+ EXPECT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // Contains share_target and url_template, but url_template is empty.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"share_target\": { \"url_template\": \"\" } }");
+ EXPECT_TRUE(
+ base::EqualsASCII(manifest.share_target.url_template.string(), ""));
+ EXPECT_FALSE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // Don't parse if property isn't a string.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"share_target\": { \"url_template\": {} } }");
+ EXPECT_TRUE(manifest.share_target.is_null());
+ ASSERT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(1u, GetErrorCount());
+ EXPECT_EQ("property 'url_template' ignored, type string expected.",
+ errors()[0]);
+ }
+
+ // Don't parse if property isn't a string.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"share_target\": { \"url_template\": 42 } }");
+ EXPECT_TRUE(manifest.share_target.is_null());
+ ASSERT_TRUE(manifest.IsEmpty());
+ EXPECT_EQ(1u, GetErrorCount());
+ EXPECT_EQ("property 'url_template' ignored, type string expected.",
+ errors()[0]);
+ }
+
+ // Contains share_target and url_template, and url_template is valid template.
Matt Giuca 2017/01/18 07:51:32 What if it's an invalid template? Is it expected t
constantina 2017/01/18 23:28:10 Test added. We will let it parse correctly, at lea
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"share_target\": {\"url_template\": \"share/?title={title}\" } }");
+ EXPECT_TRUE(base::EqualsASCII(manifest.share_target.url_template.string(),
+ "share/?title={title}"));
+ EXPECT_FALSE(manifest.IsEmpty());
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+}
+
TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
// If no application, empty list.
{

Powered by Google App Engine
This is Rietveld 408576698