OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 base::ASCIIToUTF16("The best text editor in the universe!"); | 104 base::ASCIIToUTF16("The best text editor in the universe!"); |
105 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); | 105 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); |
106 | 106 |
107 const int sizes[] = {16, 48, 128}; | 107 const int sizes[] = {16, 48, 128}; |
108 for (size_t i = 0; i < arraysize(sizes); ++i) { | 108 for (size_t i = 0; i < arraysize(sizes); ++i) { |
109 GURL icon_url( | 109 GURL icon_url( |
110 web_app.app_url.Resolve(base::StringPrintf("%i.png", sizes[i]))); | 110 web_app.app_url.Resolve(base::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 = |
115 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0), | 115 ConvertWebAppToExtension(web_app, |
116 extensions_dir.path()); | 116 GetTestTime(1978, 12, 11, 0, 0, 0, 0), |
| 117 Extension::FROM_BOOKMARK, |
| 118 extensions_dir.path()); |
117 ASSERT_TRUE(extension.get()); | 119 ASSERT_TRUE(extension.get()); |
118 | 120 |
119 base::ScopedTempDir extension_dir; | 121 base::ScopedTempDir extension_dir; |
120 EXPECT_TRUE(extension_dir.Set(extension->path())); | 122 EXPECT_TRUE(extension_dir.Set(extension->path())); |
121 | 123 |
122 EXPECT_TRUE(extension->is_app()); | 124 EXPECT_TRUE(extension->is_app()); |
123 EXPECT_TRUE(extension->is_hosted_app()); | 125 EXPECT_TRUE(extension->is_hosted_app()); |
124 EXPECT_FALSE(extension->is_legacy_packaged_app()); | 126 EXPECT_FALSE(extension->is_legacy_packaged_app()); |
125 | 127 |
126 EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=", | 128 EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=", |
(...skipping 23 matching lines...) Expand all Loading... |
150 } | 152 } |
151 | 153 |
152 TEST(ExtensionFromWebApp, Minimal) { | 154 TEST(ExtensionFromWebApp, Minimal) { |
153 base::ScopedTempDir extensions_dir; | 155 base::ScopedTempDir extensions_dir; |
154 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); | 156 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); |
155 | 157 |
156 WebApplicationInfo web_app; | 158 WebApplicationInfo web_app; |
157 web_app.title = base::ASCIIToUTF16("Gearpad"); | 159 web_app.title = base::ASCIIToUTF16("Gearpad"); |
158 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); | 160 web_app.app_url = GURL("http://aaronboodman.com/gearpad/"); |
159 | 161 |
160 scoped_refptr<Extension> extension = ConvertWebAppToExtension( | 162 scoped_refptr<Extension> extension = |
161 web_app, GetTestTime(1978, 12, 11, 0, 0, 0, 0), | 163 ConvertWebAppToExtension(web_app, |
162 extensions_dir.path()); | 164 GetTestTime(1978, 12, 11, 0, 0, 0, 0), |
| 165 Extension::FROM_BOOKMARK, |
| 166 extensions_dir.path()); |
163 ASSERT_TRUE(extension.get()); | 167 ASSERT_TRUE(extension.get()); |
164 | 168 |
165 base::ScopedTempDir extension_dir; | 169 base::ScopedTempDir extension_dir; |
166 EXPECT_TRUE(extension_dir.Set(extension->path())); | 170 EXPECT_TRUE(extension_dir.Set(extension->path())); |
167 | 171 |
168 EXPECT_TRUE(extension->is_app()); | 172 EXPECT_TRUE(extension->is_app()); |
169 EXPECT_TRUE(extension->is_hosted_app()); | 173 EXPECT_TRUE(extension->is_hosted_app()); |
170 EXPECT_FALSE(extension->is_legacy_packaged_app()); | 174 EXPECT_FALSE(extension->is_legacy_packaged_app()); |
171 | 175 |
172 EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=", | 176 EXPECT_EQ("zVvdNZy3Mp7CFU8JVSyXNlDuHdVLbP7fDO3TGVzj/0w=", |
173 extension->public_key()); | 177 extension->public_key()); |
174 EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id()); | 178 EXPECT_EQ("oplhagaaipaimkjlbekcdjkffijdockj", extension->id()); |
175 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); | 179 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); |
176 EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); | 180 EXPECT_EQ(base::UTF16ToUTF8(web_app.title), extension->name()); |
177 EXPECT_EQ("", extension->description()); | 181 EXPECT_EQ("", extension->description()); |
178 EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); | 182 EXPECT_EQ(web_app.app_url, AppLaunchInfo::GetFullLaunchURL(extension.get())); |
179 EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size()); | 183 EXPECT_EQ(0u, IconsInfo::GetIcons(extension.get()).map().size()); |
180 EXPECT_EQ(0u, | 184 EXPECT_EQ(0u, |
181 extension->permissions_data()->active_permissions()->apis().size()); | 185 extension->permissions_data()->active_permissions()->apis().size()); |
182 ASSERT_EQ(0u, extension->web_extent().patterns().size()); | 186 ASSERT_EQ(0u, extension->web_extent().patterns().size()); |
183 } | 187 } |
184 | 188 |
185 } // namespace extensions | 189 } // namespace extensions |
OLD | NEW |