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

Side by Side Diff: chrome/browser/banners/app_banner_data_fetcher_unittest.cc

Issue 1829643002: App Banner: require 'display' to be set to 'standalone' or 'fullscreen'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/banners/app_banner_data_fetcher.h" 5 #include "chrome/browser/banners/app_banner_data_fetcher.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/public/platform/WebDisplayMode.h"
9 10
10 namespace banners { 11 namespace banners {
11 12
12 class AppBannerDataFetcherUnitTest : public testing::Test { 13 class AppBannerDataFetcherUnitTest : public testing::Test {
13 public: 14 public:
14 AppBannerDataFetcherUnitTest() { } 15 AppBannerDataFetcherUnitTest() { }
15 16
16 protected: 17 protected:
17 static base::NullableString16 ToNullableUTF16(const std::string& str) { 18 static base::NullableString16 ToNullableUTF16(const std::string& str) {
18 return base::NullableString16(base::UTF8ToUTF16(str), false); 19 return base::NullableString16(base::UTF8ToUTF16(str), false);
19 } 20 }
20 21
21 static content::Manifest GetValidManifest() { 22 static content::Manifest GetValidManifest() {
22 content::Manifest manifest; 23 content::Manifest manifest;
23 manifest.name = ToNullableUTF16("foo"); 24 manifest.name = ToNullableUTF16("foo");
24 manifest.short_name = ToNullableUTF16("bar"); 25 manifest.short_name = ToNullableUTF16("bar");
25 manifest.start_url = GURL("http://example.com"); 26 manifest.start_url = GURL("http://example.com");
27 manifest.display = blink::WebDisplayModeStandalone;
26 28
27 content::Manifest::Icon icon; 29 content::Manifest::Icon icon;
28 icon.type = ToNullableUTF16("image/png"); 30 icon.type = ToNullableUTF16("image/png");
29 icon.sizes.push_back(gfx::Size(144, 144)); 31 icon.sizes.push_back(gfx::Size(144, 144));
30 manifest.icons.push_back(icon); 32 manifest.icons.push_back(icon);
31 33
32 return manifest; 34 return manifest;
33 } 35 }
34 36
35 static bool IsManifestValid(const content::Manifest& manifest) { 37 static bool IsManifestValid(const content::Manifest& manifest) {
(...skipping 24 matching lines...) Expand all
60 EXPECT_TRUE(IsManifestValid(manifest)); 62 EXPECT_TRUE(IsManifestValid(manifest));
61 63
62 manifest.name = ToNullableUTF16("foo"); 64 manifest.name = ToNullableUTF16("foo");
63 manifest.short_name = base::NullableString16(); 65 manifest.short_name = base::NullableString16();
64 EXPECT_TRUE(IsManifestValid(manifest)); 66 EXPECT_TRUE(IsManifestValid(manifest));
65 67
66 manifest.name = base::NullableString16(); 68 manifest.name = base::NullableString16();
67 EXPECT_FALSE(IsManifestValid(manifest)); 69 EXPECT_FALSE(IsManifestValid(manifest));
68 } 70 }
69 71
72 TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresNonEmptyNameORShortName) {
73 content::Manifest manifest = GetValidManifest();
74
75 manifest.name = ToNullableUTF16("");
76 EXPECT_TRUE(IsManifestValid(manifest));
77
78 manifest.name = ToNullableUTF16("foo");
79 manifest.short_name = ToNullableUTF16("");
80 EXPECT_TRUE(IsManifestValid(manifest));
81
82 manifest.name = ToNullableUTF16("");
83 EXPECT_FALSE(IsManifestValid(manifest));
84 }
85
70 TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresValidStartURL) { 86 TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresValidStartURL) {
71 content::Manifest manifest = GetValidManifest(); 87 content::Manifest manifest = GetValidManifest();
72 88
73 manifest.start_url = GURL(); 89 manifest.start_url = GURL();
74 EXPECT_FALSE(IsManifestValid(manifest)); 90 EXPECT_FALSE(IsManifestValid(manifest));
75 91
76 manifest.start_url = GURL("/"); 92 manifest.start_url = GURL("/");
77 EXPECT_FALSE(IsManifestValid(manifest)); 93 EXPECT_FALSE(IsManifestValid(manifest));
78 } 94 }
79 95
(...skipping 23 matching lines...) Expand all
103 119
104 // Non-square is okay. 120 // Non-square is okay.
105 manifest.icons[0].sizes[1] = gfx::Size(144, 200); 121 manifest.icons[0].sizes[1] = gfx::Size(144, 200);
106 EXPECT_TRUE(IsManifestValid(manifest)); 122 EXPECT_TRUE(IsManifestValid(manifest));
107 123
108 // The representation of the keyword 'any' should be recognized. 124 // The representation of the keyword 'any' should be recognized.
109 manifest.icons[0].sizes[1] = gfx::Size(0, 0); 125 manifest.icons[0].sizes[1] = gfx::Size(0, 0);
110 EXPECT_TRUE(IsManifestValid(manifest)); 126 EXPECT_TRUE(IsManifestValid(manifest));
111 } 127 }
112 128
129 TEST_F(AppBannerDataFetcherUnitTest, ManifestDisplayStandaloneFullscreen) {
130 content::Manifest manifest = GetValidManifest();
131
132 manifest.display = blink::WebDisplayModeUndefined;
133 EXPECT_FALSE(IsManifestValid(manifest));
134
135 manifest.display = blink::WebDisplayModeBrowser;
136 EXPECT_FALSE(IsManifestValid(manifest));
137
138 manifest.display = blink::WebDisplayModeMinimalUi;
139 EXPECT_FALSE(IsManifestValid(manifest));
140
141 manifest.display = blink::WebDisplayModeStandalone;
142 EXPECT_TRUE(IsManifestValid(manifest));
143
144 manifest.display = blink::WebDisplayModeFullscreen;
145 EXPECT_TRUE(IsManifestValid(manifest));
146 }
147
113 } // namespace banners 148 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_data_fetcher.cc ('k') | chrome/browser/banners/app_banner_debug_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698