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

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

Issue 2637003002: Add share_target field to Manifest. (Closed)
Patch Set: Documentation update. 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..83d3abfdeeab2a2e05332918f6c6dc1e8260c28b 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -982,6 +982,70 @@ 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());
mlamouri (slow - plz ping) 2017/01/23 00:22:26 Why ASSERT?
constantina 2017/01/23 02:51:36 It shouldn't be ASSERT; changed to EXPECT.
+ 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());
mlamouri (slow - plz ping) 2017/01/23 00:22:26 ditto
constantina 2017/01/23 02:51:36 Done.
+ EXPECT_EQ(1u, GetErrorCount());
+ EXPECT_EQ("property 'url_template' ignored, type string expected.",
+ errors()[0]);
+ }
+
+ // Smoke test: Contains share_target and url_template, and url_template is
+ // valid template.
+ {
+ 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());
+ }
+
+ // Smoke test: Contains share_target and url_template, and url_template is
+ // invalid template.
+ {
+ 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());
+ }
+}
mlamouri (slow - plz ping) 2017/01/23 00:22:26 Shouldn't you test `url_template` parsing?
constantina 2017/01/23 02:51:36 Done. Separated out the existing test cases that w
+
TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
// If no application, empty list.
{

Powered by Google App Engine
This is Rietveld 408576698