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

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

Issue 11198067: Move extension unpack intermediate dir to Extensions/Temp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: standardize names Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/convert_web_app.cc ('k') | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_path.h" 10 #include "base/file_path.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 GetTestTime(2010, 1, 1, 0, 0, 0, 0))); 86 GetTestTime(2010, 1, 1, 0, 0, 0, 0)));
87 EXPECT_EQ("2010.12.31.22111", 87 EXPECT_EQ("2010.12.31.22111",
88 ConvertTimeToExtensionVersion( 88 ConvertTimeToExtensionVersion(
89 GetTestTime(2010, 12, 31, 8, 5, 50, 500))); 89 GetTestTime(2010, 12, 31, 8, 5, 50, 500)));
90 EXPECT_EQ("2010.10.1.65535", 90 EXPECT_EQ("2010.10.1.65535",
91 ConvertTimeToExtensionVersion( 91 ConvertTimeToExtensionVersion(
92 GetTestTime(2010, 10, 1, 23, 59, 59, 999))); 92 GetTestTime(2010, 10, 1, 23, 59, 59, 999)));
93 } 93 }
94 94
95 TEST(ExtensionFromWebApp, Basic) { 95 TEST(ExtensionFromWebApp, Basic) {
96 ScopedTempDir extensions_dir;
97 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
98
96 WebApplicationInfo web_app; 99 WebApplicationInfo web_app;
97 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json"); 100 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
98 web_app.title = ASCIIToUTF16("Gearpad"); 101 web_app.title = ASCIIToUTF16("Gearpad");
99 web_app.description = ASCIIToUTF16("The best text editor in the universe!"); 102 web_app.description = ASCIIToUTF16("The best text editor in the universe!");
100 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 103 web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
101 web_app.permissions.push_back("geolocation"); 104 web_app.permissions.push_back("geolocation");
102 web_app.permissions.push_back("notifications"); 105 web_app.permissions.push_back("notifications");
103 web_app.urls.push_back(GURL("http://aaronboodman.com/gearpad/")); 106 web_app.urls.push_back(GURL("http://aaronboodman.com/gearpad/"));
104 107
105 const int sizes[] = {16, 48, 128}; 108 const int sizes[] = {16, 48, 128};
106 for (size_t i = 0; i < arraysize(sizes); ++i) { 109 for (size_t i = 0; i < arraysize(sizes); ++i) {
107 GURL icon_url(web_app.app_url.Resolve(StringPrintf("%i.png", sizes[i]))); 110 GURL icon_url(web_app.app_url.Resolve(StringPrintf("%i.png", sizes[i])));
108 web_app.icons.push_back(GetIconInfo(icon_url, sizes[i])); 111 web_app.icons.push_back(GetIconInfo(icon_url, sizes[i]));
109 } 112 }
110 113
111 scoped_refptr<Extension> extension = ConvertWebAppToExtension( 114 scoped_refptr<Extension> extension = ConvertWebAppToExtension(
112 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0)); 115 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0),
116 extensions_dir.path());
113 ASSERT_TRUE(extension.get()); 117 ASSERT_TRUE(extension.get());
114 118
115 ScopedTempDir extension_dir; 119 ScopedTempDir extension_dir;
116 EXPECT_TRUE(extension_dir.Set(extension->path())); 120 EXPECT_TRUE(extension_dir.Set(extension->path()));
117 121
118 EXPECT_TRUE(extension->is_app()); 122 EXPECT_TRUE(extension->is_app());
119 EXPECT_TRUE(extension->is_hosted_app()); 123 EXPECT_TRUE(extension->is_hosted_app());
120 EXPECT_FALSE(extension->is_legacy_packaged_app()); 124 EXPECT_FALSE(extension->is_legacy_packaged_app());
121 125
122 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 126 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=",
(...skipping 16 matching lines...) Expand all
139 extension->icons().Get(web_app.icons[i].width, 143 extension->icons().Get(web_app.icons[i].width,
140 ExtensionIconSet::MATCH_EXACTLY)); 144 ExtensionIconSet::MATCH_EXACTLY));
141 ExtensionResource resource = extension->GetIconResource( 145 ExtensionResource resource = extension->GetIconResource(
142 web_app.icons[i].width, ExtensionIconSet::MATCH_EXACTLY); 146 web_app.icons[i].width, ExtensionIconSet::MATCH_EXACTLY);
143 ASSERT_TRUE(!resource.empty()); 147 ASSERT_TRUE(!resource.empty());
144 EXPECT_TRUE(file_util::PathExists(resource.GetFilePath())); 148 EXPECT_TRUE(file_util::PathExists(resource.GetFilePath()));
145 } 149 }
146 } 150 }
147 151
148 TEST(ExtensionFromWebApp, Minimal) { 152 TEST(ExtensionFromWebApp, Minimal) {
153 ScopedTempDir extensions_dir;
154 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
155
149 WebApplicationInfo web_app; 156 WebApplicationInfo web_app;
150 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json"); 157 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
151 web_app.title = ASCIIToUTF16("Gearpad"); 158 web_app.title = ASCIIToUTF16("Gearpad");
152 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 159 web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
153 160
154 scoped_refptr<Extension> extension = ConvertWebAppToExtension( 161 scoped_refptr<Extension> extension = ConvertWebAppToExtension(
155 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0)); 162 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0),
163 extensions_dir.path());
156 ASSERT_TRUE(extension.get()); 164 ASSERT_TRUE(extension.get());
157 165
158 ScopedTempDir extension_dir; 166 ScopedTempDir extension_dir;
159 EXPECT_TRUE(extension_dir.Set(extension->path())); 167 EXPECT_TRUE(extension_dir.Set(extension->path()));
160 168
161 EXPECT_TRUE(extension->is_app()); 169 EXPECT_TRUE(extension->is_app());
162 EXPECT_TRUE(extension->is_hosted_app()); 170 EXPECT_TRUE(extension->is_hosted_app());
163 EXPECT_FALSE(extension->is_legacy_packaged_app()); 171 EXPECT_FALSE(extension->is_legacy_packaged_app());
164 172
165 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 173 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=",
166 extension->public_key()); 174 extension->public_key());
167 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 175 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id());
168 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 176 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
169 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); 177 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name());
170 EXPECT_EQ("", extension->description()); 178 EXPECT_EQ("", extension->description());
171 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL()); 179 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL());
172 EXPECT_EQ(0u, extension->icons().map().size()); 180 EXPECT_EQ(0u, extension->icons().map().size());
173 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); 181 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
174 ASSERT_EQ(1u, extension->web_extent().patterns().size()); 182 ASSERT_EQ(1u, extension->web_extent().patterns().size());
175 EXPECT_EQ("*://aaronboodman.com/*", 183 EXPECT_EQ("*://aaronboodman.com/*",
176 extension->web_extent().patterns().begin()->GetAsString()); 184 extension->web_extent().patterns().begin()->GetAsString());
177 } 185 }
178 186
179 } // namespace extensions 187 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app.cc ('k') | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698