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

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

Issue 576073004: Add support for 'orientation' in Manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_display
Patch Set: 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
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 2497cd2d38238b2498f99bac8fcb03e7ff14fb9f..12ea5d61f365365b62a49a08dbaf561893852863 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -42,6 +42,7 @@ TEST_F(ManifestParserTest, EmptyStringNull) {
ASSERT_TRUE(manifest.short_name.is_null());
ASSERT_TRUE(manifest.start_url.is_empty());
ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
+ ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
}
TEST_F(ManifestParserTest, ValidNoContentParses) {
@@ -53,6 +54,7 @@ TEST_F(ManifestParserTest, ValidNoContentParses) {
ASSERT_TRUE(manifest.short_name.is_null());
ASSERT_TRUE(manifest.start_url.is_empty());
ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
+ ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
}
TEST_F(ManifestParserTest, NameParseRules) {
@@ -228,4 +230,99 @@ TEST_F(ManifestParserTest, DisplayParserRules) {
}
}
+TEST_F(ManifestParserTest, OrientationParserRules) {
+ // Smoke test.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"natural\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockNatural);
+ EXPECT_FALSE(manifest.IsEmpty());
+ }
+
+ // Trim whitespaces.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"natural\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockNatural);
+ }
+
+ // Don't parse if name isn't a string.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": {} }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
+ }
+
+ // Don't parse if name isn't a string.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": 42 }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
+ }
+
+ // Parse fails if string isn't known.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"naturalish\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
+ }
+
+ // Accept 'any'.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"any\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockAny);
+ }
+
+ // Accept 'natural'.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"natural\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockNatural);
+ }
+
+ // Accept 'landscape'.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"landscape\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockLandscape);
+ }
+
+ // Accept 'landscape-primary'.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"orientation\": \"landscape-primary\" }");
+ EXPECT_EQ(manifest.orientation,
+ blink::WebScreenOrientationLockLandscapePrimary);
+ }
+
+ // Accept 'landscape-secondary'.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"orientation\": \"landscape-secondary\" }");
+ EXPECT_EQ(manifest.orientation,
+ blink::WebScreenOrientationLockLandscapeSecondary);
+ }
+
+ // Accept 'portrait'.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"portrait\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockPortrait);
+ }
+
+ // Accept 'portrait-primary'.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"orientation\": \"portrait-primary\" }");
+ EXPECT_EQ(manifest.orientation,
+ blink::WebScreenOrientationLockPortraitPrimary);
+ }
+
+ // Accept 'portrait-secondary'.
+ {
+ Manifest manifest =
+ ParseManifest("{ \"orientation\": \"portrait-secondary\" }");
+ EXPECT_EQ(manifest.orientation,
+ blink::WebScreenOrientationLockPortraitSecondary);
+ }
+
+ // Case insensitive.
+ {
+ Manifest manifest = ParseManifest("{ \"orientation\": \"LANDSCAPE\" }");
+ EXPECT_EQ(manifest.orientation, blink::WebScreenOrientationLockLandscape);
+ }
+}
+
} // namespace content
« content/common/manifest_manager_messages.h ('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