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

Side by Side Diff: chrome/browser/extensions/convert_web_app_unittest.cc

Issue 142993002: Remove unused members from WebApplicationInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/convert_web_app.h" 5 #include "chrome/browser/extensions/convert_web_app.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 EXPECT_EQ("2010.10.1.65535", 91 EXPECT_EQ("2010.10.1.65535",
92 ConvertTimeToExtensionVersion( 92 ConvertTimeToExtensionVersion(
93 GetTestTime(2010, 10, 1, 23, 59, 59, 999))); 93 GetTestTime(2010, 10, 1, 23, 59, 59, 999)));
94 } 94 }
95 95
96 TEST(ExtensionFromWebApp, Basic) { 96 TEST(ExtensionFromWebApp, Basic) {
97 base::ScopedTempDir extensions_dir; 97 base::ScopedTempDir extensions_dir;
98 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); 98 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
99 99
100 WebApplicationInfo web_app; 100 WebApplicationInfo web_app;
101 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
102 web_app.title = base::ASCIIToUTF16("Gearpad"); 101 web_app.title = base::ASCIIToUTF16("Gearpad");
103 web_app.description = 102 web_app.description =
104 base::ASCIIToUTF16("The best text editor in the universe!"); 103 base::ASCIIToUTF16("The best text editor in the universe!");
105 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 104 web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
106 web_app.permissions.push_back("geolocation");
107 web_app.permissions.push_back("notifications");
108 web_app.urls.push_back(GURL("http://aaronboodman.com/gearpad/"));
109 105
110 const int sizes[] = {16, 48, 128}; 106 const int sizes[] = {16, 48, 128};
111 for (size_t i = 0; i < arraysize(sizes); ++i) { 107 for (size_t i = 0; i < arraysize(sizes); ++i) {
112 GURL icon_url( 108 GURL icon_url(
113 web_app.app_url.Resolve(base::StringPrintf("%i.png", sizes[i]))); 109 web_app.app_url.Resolve(base::StringPrintf("%i.png", sizes[i])));
114 web_app.icons.push_back(GetIconInfo(icon_url, sizes[i])); 110 web_app.icons.push_back(GetIconInfo(icon_url, sizes[i]));
115 } 111 }
116 112
117 scoped_refptr<Extension> extension = ConvertWebAppToExtension( 113 scoped_refptr<Extension> extension = ConvertWebAppToExtension(
118 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0), 114 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0),
119 extensions_dir.path()); 115 extensions_dir.path());
120 ASSERT_TRUE(extension.get()); 116 ASSERT_TRUE(extension.get());
121 117
122 base::ScopedTempDir extension_dir; 118 base::ScopedTempDir extension_dir;
123 EXPECT_TRUE(extension_dir.Set(extension->path())); 119 EXPECT_TRUE(extension_dir.Set(extension->path()));
124 120
125 EXPECT_TRUE(extension->is_app()); 121 EXPECT_TRUE(extension->is_app());
126 EXPECT_TRUE(extension->is_hosted_app()); 122 EXPECT_TRUE(extension->is_hosted_app());
127 EXPECT_FALSE(extension->is_legacy_packaged_app()); 123 EXPECT_FALSE(extension->is_legacy_packaged_app());
128 124
129 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 125 EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=",
130 extension->public_key()); 126 extension->public_key());
131 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 127 EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id());
132 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 128 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
133 EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); 129 EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name());
134 EXPECT_EQ(base::UTF16ToUTF8(web_app.description), extension->description()); 130 EXPECT_EQ(base::UTF16ToUTF8(web_app.description), extension->description());
135 EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); 131 EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get()));
136 EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size()); 132 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
137 EXPECT_TRUE(extension->HasAPIPermission("geolocation")); 133 ASSERT_EQ(0u, extension->web_extent().patterns().size());
138 EXPECT_TRUE(extension->HasAPIPermission("notifications"));
139 ASSERT_EQ(1u, extension->web_extent().patterns().size());
140 EXPECT_EQ("http://aaronboodman.com/gearpad/*",
141 extension->web_extent().patterns().begin()->GetAsString());
142 134
143 EXPECT_EQ(web_app.icons.size(), 135 EXPECT_EQ(web_app.icons.size(),
144 IconsInfo::GetIcons(extension.get()).map().size()); 136 IconsInfo::GetIcons(extension.get()).map().size());
145 for (size_t i = 0; i < web_app.icons.size(); ++i) { 137 for (size_t i = 0; i < web_app.icons.size(); ++i) {
146 EXPECT_EQ(base::StringPrintf("icons/%i.png", web_app.icons[i].width), 138 EXPECT_EQ(base::StringPrintf("icons/%i.png", web_app.icons[i].width),
147 IconsInfo::GetIcons(extension.get()).Get( 139 IconsInfo::GetIcons(extension.get()).Get(
148 web_app.icons[i].width, ExtensionIconSet::MATCH_EXACTLY)); 140 web_app.icons[i].width, ExtensionIconSet::MATCH_EXACTLY));
149 ExtensionResource resource = 141 ExtensionResource resource =
150 IconsInfo::GetIconResource(extension.get(), 142 IconsInfo::GetIconResource(extension.get(),
151 web_app.icons[i].width, 143 web_app.icons[i].width,
152 ExtensionIconSet::MATCH_EXACTLY); 144 ExtensionIconSet::MATCH_EXACTLY);
153 ASSERT_TRUE(!resource.empty()); 145 ASSERT_TRUE(!resource.empty());
154 EXPECT_TRUE(base::PathExists(resource.GetFilePath())); 146 EXPECT_TRUE(base::PathExists(resource.GetFilePath()));
155 } 147 }
156 } 148 }
157 149
158 TEST(ExtensionFromWebApp, Minimal) { 150 TEST(ExtensionFromWebApp, Minimal) {
159 base::ScopedTempDir extensions_dir; 151 base::ScopedTempDir extensions_dir;
160 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); 152 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
161 153
162 WebApplicationInfo web_app; 154 WebApplicationInfo web_app;
163 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
164 web_app.title = base::ASCIIToUTF16("Gearpad"); 155 web_app.title = base::ASCIIToUTF16("Gearpad");
165 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 156 web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
166 157
167 scoped_refptr<Extension> extension = ConvertWebAppToExtension( 158 scoped_refptr<Extension> extension = ConvertWebAppToExtension(
168 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0), 159 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0),
169 extensions_dir.path()); 160 extensions_dir.path());
170 ASSERT_TRUE(extension.get()); 161 ASSERT_TRUE(extension.get());
171 162
172 base::ScopedTempDir extension_dir; 163 base::ScopedTempDir extension_dir;
173 EXPECT_TRUE(extension_dir.Set(extension->path())); 164 EXPECT_TRUE(extension_dir.Set(extension->path()));
174 165
175 EXPECT_TRUE(extension->is_app()); 166 EXPECT_TRUE(extension->is_app());
176 EXPECT_TRUE(extension->is_hosted_app()); 167 EXPECT_TRUE(extension->is_hosted_app());
177 EXPECT_FALSE(extension->is_legacy_packaged_app()); 168 EXPECT_FALSE(extension->is_legacy_packaged_app());
178 169
179 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 170 EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=",
180 extension->public_key()); 171 extension->public_key());
181 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 172 EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id());
182 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 173 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
183 EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); 174 EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name());
184 EXPECT_EQ("", extension->description()); 175 EXPECT_EQ("", extension->description());
185 EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); 176 EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get()));
186 EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size()); 177 EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size());
187 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); 178 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
188 ASSERT_EQ(1u, extension->web_extent().patterns().size()); 179 ASSERT_EQ(0u, extension->web_extent().patterns().size());
189 EXPECT_EQ("*://aaronboodman.com/*",
190 extension->web_extent().patterns().begin()->GetAsString());
191 } 180 }
192 181
193 } // namespace extensions 182 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698