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

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

Issue 563083004: Add support for 'display' in Manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_to_homescreen_manifest
Patch Set: review comments Created 6 years, 3 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 | « content/renderer/manifest/manifest_parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0e500aec9e2c2bce3f123bbd36cd2b8d1ecc2f07..2497cd2d38238b2498f99bac8fcb03e7ff14fb9f 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -41,6 +41,7 @@ TEST_F(ManifestParserTest, EmptyStringNull) {
ASSERT_TRUE(manifest.name.is_null());
ASSERT_TRUE(manifest.short_name.is_null());
ASSERT_TRUE(manifest.start_url.is_empty());
+ ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
}
TEST_F(ManifestParserTest, ValidNoContentParses) {
@@ -51,6 +52,7 @@ TEST_F(ManifestParserTest, ValidNoContentParses) {
ASSERT_TRUE(manifest.name.is_null());
ASSERT_TRUE(manifest.short_name.is_null());
ASSERT_TRUE(manifest.start_url.is_empty());
+ ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
}
TEST_F(ManifestParserTest, NameParseRules) {
@@ -58,6 +60,7 @@ TEST_F(ManifestParserTest, NameParseRules) {
{
Manifest manifest = ParseManifest("{ \"name\": \"foo\" }");
ASSERT_TRUE(EqualsASCII(manifest.name.string(), "foo"));
+ ASSERT_FALSE(manifest.IsEmpty());
}
// Trim whitespaces.
@@ -84,6 +87,7 @@ TEST_F(ManifestParserTest, ShortNameParseRules) {
{
Manifest manifest = ParseManifest("{ \"short_name\": \"foo\" }");
ASSERT_TRUE(EqualsASCII(manifest.short_name.string(), "foo"));
+ ASSERT_FALSE(manifest.IsEmpty());
}
// Trim whitespaces.
@@ -111,6 +115,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
Manifest manifest = ParseManifest("{ \"start_url\": \"land.html\" }");
ASSERT_EQ(manifest.start_url.spec(),
default_document_url.Resolve("land.html").spec());
+ ASSERT_FALSE(manifest.IsEmpty());
}
// Whitespaces.
@@ -160,4 +165,67 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
}
}
+TEST_F(ManifestParserTest, DisplayParserRules) {
+ // Smoke test.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"browser\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_BROWSER);
+ EXPECT_FALSE(manifest.IsEmpty());
+ }
+
+ // Trim whitespaces.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \" browser \" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_BROWSER);
+ }
+
+ // Don't parse if name isn't a string.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": {} }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
+ }
+
+ // Don't parse if name isn't a string.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": 42 }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
+ }
+
+ // Parse fails if string isn't known.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"browser_something\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
+ }
+
+ // Accept 'fullscreen'.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"fullscreen\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_FULLSCREEN);
+ }
+
+ // Accept 'fullscreen'.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"standalone\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_STANDALONE);
+ }
+
+ // Accept 'minimal-ui'.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"minimal-ui\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_MINIMAL_UI);
+ }
+
+ // Accept 'browser'.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"browser\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_BROWSER);
+ }
+
+ // Case insensitive.
+ {
+ Manifest manifest = ParseManifest("{ \"display\": \"BROWSER\" }");
+ EXPECT_EQ(manifest.display, Manifest::DISPLAY_MODE_BROWSER);
+ }
+}
+
} // namespace content
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698