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

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: Created 4 years, 9 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 manifest.short_name = ToNullableUTF16("");
77 EXPECT_FALSE(IsManifestValid(manifest));
78
79 manifest.name = ToNullableUTF16("foo");
80 EXPECT_TRUE(IsManifestValid(manifest));
81
82 manifest.short_name = ToNullableUTF16("");
83 EXPECT_TRUE(IsManifestValid(manifest));
dominickn 2016/03/23 11:40:53 Nit: Isn't short_name already empty at this point?
mlamouri (slow - plz ping) 2016/03/23 11:46:10 Correct. I did some changes before upload that mad
84
85 manifest.name = ToNullableUTF16("");
86 EXPECT_FALSE(IsManifestValid(manifest));
87 }
88
70 TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresValidStartURL) { 89 TEST_F(AppBannerDataFetcherUnitTest, ManifestRequiresValidStartURL) {
71 content::Manifest manifest = GetValidManifest(); 90 content::Manifest manifest = GetValidManifest();
72 91
73 manifest.start_url = GURL(); 92 manifest.start_url = GURL();
74 EXPECT_FALSE(IsManifestValid(manifest)); 93 EXPECT_FALSE(IsManifestValid(manifest));
75 94
76 manifest.start_url = GURL("/"); 95 manifest.start_url = GURL("/");
77 EXPECT_FALSE(IsManifestValid(manifest)); 96 EXPECT_FALSE(IsManifestValid(manifest));
78 } 97 }
79 98
(...skipping 23 matching lines...) Expand all
103 122
104 // Non-square is okay. 123 // Non-square is okay.
105 manifest.icons[0].sizes[1] = gfx::Size(144, 200); 124 manifest.icons[0].sizes[1] = gfx::Size(144, 200);
106 EXPECT_TRUE(IsManifestValid(manifest)); 125 EXPECT_TRUE(IsManifestValid(manifest));
107 126
108 // The representation of the keyword 'any' should be recognized. 127 // The representation of the keyword 'any' should be recognized.
109 manifest.icons[0].sizes[1] = gfx::Size(0, 0); 128 manifest.icons[0].sizes[1] = gfx::Size(0, 0);
110 EXPECT_TRUE(IsManifestValid(manifest)); 129 EXPECT_TRUE(IsManifestValid(manifest));
111 } 130 }
112 131
132 TEST_F(AppBannerDataFetcherUnitTest, ManifestDisplayStandaloneFullscreen) {
133 content::Manifest manifest = GetValidManifest();
134
135 manifest.display = blink::WebDisplayModeUndefined;
136 EXPECT_FALSE(IsManifestValid(manifest));
137
138 manifest.display = blink::WebDisplayModeBrowser;
139 EXPECT_FALSE(IsManifestValid(manifest));
140
141 manifest.display = blink::WebDisplayModeMinimalUi;
142 EXPECT_FALSE(IsManifestValid(manifest));
143
144 manifest.display = blink::WebDisplayModeStandalone;
145 EXPECT_TRUE(IsManifestValid(manifest));
146
147 manifest.display = blink::WebDisplayModeFullscreen;
148 EXPECT_TRUE(IsManifestValid(manifest));
149 }
150
113 } // namespace banners 151 } // 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