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

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

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "base/scoped_temp_dir.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_icon_set.h" 20 #include "chrome/common/extensions/extension_icon_set.h"
21 #include "chrome/common/extensions/extension_resource.h" 21 #include "chrome/common/extensions/extension_resource.h"
22 #include "chrome/common/extensions/permissions/permission_set.h" 22 #include "chrome/common/extensions/permissions/permission_set.h"
23 #include "chrome/common/web_apps.h" 23 #include "chrome/common/web_apps.h"
(...skipping 62 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; 96 base::ScopedTempDir extensions_dir;
97 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); 97 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
98 98
99 WebApplicationInfo web_app; 99 WebApplicationInfo web_app;
100 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json"); 100 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
101 web_app.title = ASCIIToUTF16("Gearpad"); 101 web_app.title = ASCIIToUTF16("Gearpad");
102 web_app.description = ASCIIToUTF16("The best text editor in the universe!"); 102 web_app.description = ASCIIToUTF16("The best text editor in the universe!");
103 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 103 web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
104 web_app.permissions.push_back("geolocation"); 104 web_app.permissions.push_back("geolocation");
105 web_app.permissions.push_back("notifications"); 105 web_app.permissions.push_back("notifications");
106 web_app.urls.push_back(GURL("http://aaronboodman.com/gearpad/")); 106 web_app.urls.push_back(GURL("http://aaronboodman.com/gearpad/"));
107 107
108 const int sizes[] = {16, 48, 128}; 108 const int sizes[] = {16, 48, 128};
109 for (size_t i = 0; i < arraysize(sizes); ++i) { 109 for (size_t i = 0; i < arraysize(sizes); ++i) {
110 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])));
111 web_app.icons.push_back(GetIconInfo(icon_url, sizes[i])); 111 web_app.icons.push_back(GetIconInfo(icon_url, sizes[i]));
112 } 112 }
113 113
114 scoped_refptr<Extension> extension = ConvertWebAppToExtension( 114 scoped_refptr<Extension> extension = ConvertWebAppToExtension(
115 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()); 116 extensions_dir.path());
117 ASSERT_TRUE(extension.get()); 117 ASSERT_TRUE(extension.get());
118 118
119 ScopedTempDir extension_dir; 119 base::ScopedTempDir extension_dir;
120 EXPECT_TRUE(extension_dir.Set(extension->path())); 120 EXPECT_TRUE(extension_dir.Set(extension->path()));
121 121
122 EXPECT_TRUE(extension->is_app()); 122 EXPECT_TRUE(extension->is_app());
123 EXPECT_TRUE(extension->is_hosted_app()); 123 EXPECT_TRUE(extension->is_hosted_app());
124 EXPECT_FALSE(extension->is_legacy_packaged_app()); 124 EXPECT_FALSE(extension->is_legacy_packaged_app());
125 125
126 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 126 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=",
127 extension->public_key()); 127 extension->public_key());
128 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 128 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id());
129 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 129 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
(...skipping 13 matching lines...) Expand all
143 extension->icons().Get(web_app.icons[i].width, 143 extension->icons().Get(web_app.icons[i].width,
144 ExtensionIconSet::MATCH_EXACTLY)); 144 ExtensionIconSet::MATCH_EXACTLY));
145 ExtensionResource resource = extension->GetIconResource( 145 ExtensionResource resource = extension->GetIconResource(
146 web_app.icons[i].width, ExtensionIconSet::MATCH_EXACTLY); 146 web_app.icons[i].width, ExtensionIconSet::MATCH_EXACTLY);
147 ASSERT_TRUE(!resource.empty()); 147 ASSERT_TRUE(!resource.empty());
148 EXPECT_TRUE(file_util::PathExists(resource.GetFilePath())); 148 EXPECT_TRUE(file_util::PathExists(resource.GetFilePath()));
149 } 149 }
150 } 150 }
151 151
152 TEST(ExtensionFromWebApp, Minimal) { 152 TEST(ExtensionFromWebApp, Minimal) {
153 ScopedTempDir extensions_dir; 153 base::ScopedTempDir extensions_dir;
154 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); 154 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir());
155 155
156 WebApplicationInfo web_app; 156 WebApplicationInfo web_app;
157 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json"); 157 web_app.manifest_url = GURL("http://aaronboodman.com/gearpad/manifest.json");
158 web_app.title = ASCIIToUTF16("Gearpad"); 158 web_app.title = ASCIIToUTF16("Gearpad");
159 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); 159 web_app.app_url = GURL("http://aaronboodman.com/gearpad/");
160 160
161 scoped_refptr<Extension> extension = ConvertWebAppToExtension( 161 scoped_refptr<Extension> extension = ConvertWebAppToExtension(
162 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()); 163 extensions_dir.path());
164 ASSERT_TRUE(extension.get()); 164 ASSERT_TRUE(extension.get());
165 165
166 ScopedTempDir extension_dir; 166 base::ScopedTempDir extension_dir;
167 EXPECT_TRUE(extension_dir.Set(extension->path())); 167 EXPECT_TRUE(extension_dir.Set(extension->path()));
168 168
169 EXPECT_TRUE(extension->is_app()); 169 EXPECT_TRUE(extension->is_app());
170 EXPECT_TRUE(extension->is_hosted_app()); 170 EXPECT_TRUE(extension->is_hosted_app());
171 EXPECT_FALSE(extension->is_legacy_packaged_app()); 171 EXPECT_FALSE(extension->is_legacy_packaged_app());
172 172
173 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 173 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=",
174 extension->public_key()); 174 extension->public_key());
175 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 175 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id());
176 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 176 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
177 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); 177 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name());
178 EXPECT_EQ("", extension->description()); 178 EXPECT_EQ("", extension->description());
179 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL()); 179 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL());
180 EXPECT_EQ(0u, extension->icons().map().size()); 180 EXPECT_EQ(0u, extension->icons().map().size());
181 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); 181 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
182 ASSERT_EQ(1u, extension->web_extent().patterns().size()); 182 ASSERT_EQ(1u, extension->web_extent().patterns().size());
183 EXPECT_EQ("*://aaronboodman.com/*", 183 EXPECT_EQ("*://aaronboodman.com/*",
184 extension->web_extent().patterns().begin()->GetAsString()); 184 extension->web_extent().patterns().begin()->GetAsString());
185 } 185 }
186 186
187 } // namespace extensions 187 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app.cc ('k') | chrome/browser/extensions/crx_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698