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