| Index: chrome/browser/android/webapk/webapk_builder_unittest.cc
|
| diff --git a/chrome/browser/android/webapk/webapk_builder_unittest.cc b/chrome/browser/android/webapk/webapk_builder_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e69a4711e708e77f41a739e6147e645c5831137c
|
| --- /dev/null
|
| +++ b/chrome/browser/android/webapk/webapk_builder_unittest.cc
|
| @@ -0,0 +1,47 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/android/webapk/webapk_builder.h"
|
| +#include "content/public/common/manifest.h"
|
| +#include "content/renderer/manifest/manifest_parser.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "url/gurl.h"
|
| +
|
| +TEST(WebApkBuilderTest, DisplayToString) {
|
| + for (int display = 0; display < blink::WebDisplayModeLast; ++display) {
|
| + std::string display_string = WebApkBuilder::DisplayToString(
|
| + static_cast<blink::WebDisplayMode>(display));
|
| + content::ManifestParser parser("{\"display\":\"" + display_string + "\"}",
|
| + GURL(), GURL());
|
| + parser.Parse();
|
| + EXPECT_FALSE(parser.failed());
|
| + EXPECT_EQ(parser.manifest().display, display)
|
| + << "Incorrect conversion from display enum value to string: " << display
|
| + << " " << display_string;
|
| + }
|
| +}
|
| +
|
| +TEST(WebApkBuilderTest, OrientationToString) {
|
| + for (int orientation = 0;
|
| + orientation < blink::WebScreenOrientationLockNatural; ++orientation) {
|
| + std::string orientation_string = WebApkBuilder::OrientationToString(
|
| + static_cast<blink::WebScreenOrientationLockType>(orientation));
|
| + content::ManifestParser parser(
|
| + "{\"orientation\":\"" + orientation_string + "\"}", GURL(), GURL());
|
| + parser.Parse();
|
| + EXPECT_FALSE(parser.failed());
|
| + EXPECT_EQ(parser.manifest().orientation, orientation)
|
| + << "Incorrect conversion from display enum value to string: "
|
| + << orientation << " " << orientation_string;
|
| + }
|
| +}
|
| +
|
| +// Test that the "invalid color value" is what the server expects.
|
| +TEST(WebApkBuilderTest, InvalidColorFormat) {
|
| + content::ManifestParser parser("{\"theme_color\":\"falu\"}", GURL(),
|
| + GURL());
|
| + parser.Parse();
|
| + ASSERT_FALSE(parser.failed());
|
| + EXPECT_EQ(0x80000000, parser.manifest().theme_color);
|
| +}
|
|
|