Chromium Code Reviews| 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" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.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/app_launcher_info.h" | |
| 19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_icon_set.h" | 21 #include "chrome/common/extensions/extension_icon_set.h" |
| 21 #include "chrome/common/extensions/extension_unittest.h" | 22 #include "chrome/common/extensions/extension_unittest.h" |
| 23 #include "chrome/common/extensions/manifest_handler.h" | |
|
Devlin
2013/04/16 21:40:58
I don't think you need the generic manifest_handle
| |
| 22 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 24 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 23 #include "chrome/common/extensions/permissions/permission_set.h" | 25 #include "chrome/common/extensions/permissions/permission_set.h" |
| 24 #include "chrome/common/web_apps.h" | 26 #include "chrome/common/web_apps.h" |
| 25 #include "extensions/common/extension_resource.h" | 27 #include "extensions/common/extension_resource.h" |
| 26 #include "extensions/common/url_pattern.h" | 28 #include "extensions/common/url_pattern.h" |
| 27 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/gfx/codec/png_codec.h" | 31 #include "ui/gfx/codec/png_codec.h" |
| 30 #include "webkit/glue/image_decoder.h" | 32 #include "webkit/glue/image_decoder.h" |
| 31 | 33 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 exploded.millisecond = millisecond; | 80 exploded.millisecond = millisecond; |
| 79 return base::Time::FromUTCExploded(exploded); | 81 return base::Time::FromUTCExploded(exploded); |
| 80 } | 82 } |
| 81 | 83 |
| 82 } // namespace | 84 } // namespace |
| 83 | 85 |
| 84 class ExtensionFromWebApp : public ExtensionTest { | 86 class ExtensionFromWebApp : public ExtensionTest { |
| 85 protected: | 87 protected: |
| 86 virtual void SetUp() OVERRIDE { | 88 virtual void SetUp() OVERRIDE { |
| 87 ExtensionTest::SetUp(); | 89 ExtensionTest::SetUp(); |
| 90 (new AppLaunchManifestHandler)->Register(); | |
| 88 (new IconsHandler)->Register(); | 91 (new IconsHandler)->Register(); |
| 89 } | 92 } |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 TEST_F(ExtensionFromWebApp, GenerateVersion) { | 95 TEST_F(ExtensionFromWebApp, GenerateVersion) { |
| 93 EXPECT_EQ("2010.1.1.0", | 96 EXPECT_EQ("2010.1.1.0", |
| 94 ConvertTimeToExtensionVersion( | 97 ConvertTimeToExtensionVersion( |
| 95 GetTestTime(2010, 1, 1, 0, 0, 0, 0))); | 98 GetTestTime(2010, 1, 1, 0, 0, 0, 0))); |
| 96 EXPECT_EQ("2010.12.31.22111", | 99 EXPECT_EQ("2010.12.31.22111", |
| 97 ConvertTimeToExtensionVersion( | 100 ConvertTimeToExtensionVersion( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 EXPECT_TRUE(extension->is_app()); | 135 EXPECT_TRUE(extension->is_app()); |
| 133 EXPECT_TRUE(extension->is_hosted_app()); | 136 EXPECT_TRUE(extension->is_hosted_app()); |
| 134 EXPECT_FALSE(extension->is_legacy_packaged_app()); | 137 EXPECT_FALSE(extension->is_legacy_packaged_app()); |
| 135 | 138 |
| 136 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", | 139 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", |
| 137 extension->public_key()); | 140 extension->public_key()); |
| 138 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); | 141 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); |
| 139 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); | 142 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); |
| 140 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); | 143 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); |
| 141 EXPECT_EQ(UTF16ToUTF8(web_app.description), extension->description()); | 144 EXPECT_EQ(UTF16ToUTF8(web_app.description), extension->description()); |
| 142 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL()); | 145 EXPECT_EQ(web_app.app_url, AppLauncherInfo::GetFullLaunchURL(extension)); |
| 143 EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size()); | 146 EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size()); |
| 144 EXPECT_TRUE(extension->HasAPIPermission("geolocation")); | 147 EXPECT_TRUE(extension->HasAPIPermission("geolocation")); |
| 145 EXPECT_TRUE(extension->HasAPIPermission("notifications")); | 148 EXPECT_TRUE(extension->HasAPIPermission("notifications")); |
| 146 ASSERT_EQ(1u, extension->web_extent().patterns().size()); | 149 ASSERT_EQ(1u, extension->web_extent().patterns().size()); |
| 147 EXPECT_EQ("http://aaronboodman.com/gearpad/*", | 150 EXPECT_EQ("http://aaronboodman.com/gearpad/*", |
| 148 extension->web_extent().patterns().begin()->GetAsString()); | 151 extension->web_extent().patterns().begin()->GetAsString()); |
| 149 | 152 |
| 150 EXPECT_EQ(web_app.icons.size(), IconsInfo::GetIcons(extension).map().size()); | 153 EXPECT_EQ(web_app.icons.size(), IconsInfo::GetIcons(extension).map().size()); |
| 151 for (size_t i = 0; i < web_app.icons.size(); ++i) { | 154 for (size_t i = 0; i < web_app.icons.size(); ++i) { |
| 152 EXPECT_EQ(base::StringPrintf("icons/%i.png", web_app.icons[i].width), | 155 EXPECT_EQ(base::StringPrintf("icons/%i.png", web_app.icons[i].width), |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 179 EXPECT_TRUE(extension->is_app()); | 182 EXPECT_TRUE(extension->is_app()); |
| 180 EXPECT_TRUE(extension->is_hosted_app()); | 183 EXPECT_TRUE(extension->is_hosted_app()); |
| 181 EXPECT_FALSE(extension->is_legacy_packaged_app()); | 184 EXPECT_FALSE(extension->is_legacy_packaged_app()); |
| 182 | 185 |
| 183 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", | 186 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", |
| 184 extension->public_key()); | 187 extension->public_key()); |
| 185 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); | 188 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); |
| 186 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); | 189 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); |
| 187 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); | 190 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); |
| 188 EXPECT_EQ("", extension->description()); | 191 EXPECT_EQ("", extension->description()); |
| 189 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL()); | 192 EXPECT_EQ(web_app.app_url, AppLauncherInfo::GetFullLaunchURL(extension)); |
| 190 EXPECT_EQ(0u, IconsInfo::GetIcons(extension).map().size()); | 193 EXPECT_EQ(0u, IconsInfo::GetIcons(extension).map().size()); |
| 191 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); | 194 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); |
| 192 ASSERT_EQ(1u, extension->web_extent().patterns().size()); | 195 ASSERT_EQ(1u, extension->web_extent().patterns().size()); |
| 193 EXPECT_EQ("*://aaronboodman.com/*", | 196 EXPECT_EQ("*://aaronboodman.com/*", |
| 194 extension->web_extent().patterns().begin()->GetAsString()); | 197 extension->web_extent().patterns().begin()->GetAsString()); |
| 195 } | 198 } |
| 196 | 199 |
| 197 } // namespace extensions | 200 } // namespace extensions |
| OLD | NEW |