| Index: chrome/browser/banners/webapp_manifest_validator_unittest.cc
|
| diff --git a/chrome/browser/banners/app_banner_data_fetcher_unittest.cc b/chrome/browser/banners/webapp_manifest_validator_unittest.cc
|
| similarity index 61%
|
| rename from chrome/browser/banners/app_banner_data_fetcher_unittest.cc
|
| rename to chrome/browser/banners/webapp_manifest_validator_unittest.cc
|
| index 1de8aefb86109a7dea0715afa8d38f0c16b42a3f..e9aa59055bf30c644adfb19bbf845acec39e96d2 100644
|
| --- a/chrome/browser/banners/app_banner_data_fetcher_unittest.cc
|
| +++ b/chrome/browser/banners/webapp_manifest_validator_unittest.cc
|
| @@ -2,17 +2,18 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/banners/app_banner_data_fetcher.h"
|
| +#include "chrome/browser/banners/webapp_manifest_validator.h"
|
|
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "content/public/common/manifest.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "third_party/WebKit/public/platform/WebDisplayMode.h"
|
|
|
| namespace banners {
|
|
|
| -class AppBannerDataFetcherUnitTest : public testing::Test {
|
| +class WebappManifestValidatorUnitTest : public testing::Test {
|
| public:
|
| - AppBannerDataFetcherUnitTest() { }
|
| + WebappManifestValidatorUnitTest() { }
|
|
|
| protected:
|
| static base::NullableString16 ToNullableUTF16(const std::string& str) {
|
| @@ -34,115 +35,116 @@ class AppBannerDataFetcherUnitTest : public testing::Test {
|
| return manifest;
|
| }
|
|
|
| - static bool IsManifestValid(const content::Manifest& manifest) {
|
| + static bool IsManifestGood(const content::Manifest& manifest) {
|
| // The second argument is the web_contents pointer, which is used for
|
| // developer debug logging to the console. The logging is skipped inside the
|
| // method if a null web_contents pointer is provided, so this is safe.
|
| // The third argument is the is_debug_mode boolean value, which is true only
|
| // when it is triggered by the developer's action in DevTools.
|
| - return AppBannerDataFetcher::IsManifestValidForWebApp(manifest, nullptr,
|
| - false);
|
| + OutputDeveloperMessageCode code = OutputDeveloperMessageCode::kNone;
|
| + return webapp_manifest_validator::IsManifestGoodForWebapp(manifest, &code);
|
| }
|
| };
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, EmptyManifestIsInvalid) {
|
| +TEST_F(WebappManifestValidatorUnitTest, EmptyManifestIsInvalid) {
|
| content::Manifest manifest;
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, CheckMinimalValidManifest) {
|
| +TEST_F(WebappManifestValidatorUnitTest, CheckMinimalValidManifest) {
|
| content::Manifest manifest = GetValidManifest();
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresNameORShortName) {
|
| +TEST_F(WebappManifestValidatorUnitTest, ManifestRequiresNameORShortName) {
|
| content::Manifest manifest = GetValidManifest();
|
|
|
| manifest.name = base::NullableString16();
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| manifest.name = ToNullableUTF16("foo");
|
| manifest.short_name = base::NullableString16();
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| manifest.name = base::NullableString16();
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresNonEmptyNameORShortName) {
|
| +TEST_F(WebappManifestValidatorUnitTest,
|
| + ManifestRequiresNonEmptyNameORShortName) {
|
| content::Manifest manifest = GetValidManifest();
|
|
|
| manifest.name = ToNullableUTF16("");
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| manifest.name = ToNullableUTF16("foo");
|
| manifest.short_name = ToNullableUTF16("");
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| manifest.name = ToNullableUTF16("");
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresValidStartURL) {
|
| +TEST_F(WebappManifestValidatorUnitTest, ManifestRequiresValidStartURL) {
|
| content::Manifest manifest = GetValidManifest();
|
|
|
| manifest.start_url = GURL();
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
|
|
| manifest.start_url = GURL("/");
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresImagePNG) {
|
| +TEST_F(WebappManifestValidatorUnitTest, ManifestRequiresImagePNG) {
|
| content::Manifest manifest = GetValidManifest();
|
|
|
| manifest.icons[0].type = ToNullableUTF16("image/gif");
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
| manifest.icons[0].type = base::NullableString16();
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresMinimalSize) {
|
| +TEST_F(WebappManifestValidatorUnitTest, ManifestRequiresMinimalSize) {
|
| content::Manifest manifest = GetValidManifest();
|
|
|
| // The icon MUST be 144x144 size at least.
|
| manifest.icons[0].sizes[0] = gfx::Size(1, 1);
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
|
|
| // If one of the sizes match the requirement, it should be accepted.
|
| manifest.icons[0].sizes.push_back(gfx::Size(144, 144));
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| // Higher than the required size is okay.
|
| manifest.icons[0].sizes[1] = gfx::Size(200, 200);
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| // Non-square is okay.
|
| manifest.icons[0].sizes[1] = gfx::Size(144, 200);
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| // The representation of the keyword 'any' should be recognized.
|
| manifest.icons[0].sizes[1] = gfx::Size(0, 0);
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
| }
|
|
|
| -TEST_F(AppBannerDataFetcherUnitTest, ManifestDisplayStandaloneFullscreen) {
|
| +TEST_F(WebappManifestValidatorUnitTest, ManifestDisplayStandaloneFullscreen) {
|
| content::Manifest manifest = GetValidManifest();
|
|
|
| manifest.display = blink::WebDisplayModeUndefined;
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
|
|
| manifest.display = blink::WebDisplayModeBrowser;
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
|
|
| manifest.display = blink::WebDisplayModeMinimalUi;
|
| - EXPECT_FALSE(IsManifestValid(manifest));
|
| + EXPECT_FALSE(IsManifestGood(manifest));
|
|
|
| manifest.display = blink::WebDisplayModeStandalone;
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
|
|
| manifest.display = blink::WebDisplayModeFullscreen;
|
| - EXPECT_TRUE(IsManifestValid(manifest));
|
| + EXPECT_TRUE(IsManifestGood(manifest));
|
| }
|
|
|
| } // namespace banners
|
|
|