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

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

Issue 12316077: Move the parsing of app.launch related keys out of Extension class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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
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_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/api/icons/icons_handler.h" 19 #include "chrome/common/extensions/api/icons/icons_handler.h"
20 #include "chrome/common/extensions/app_launcher_info.h"
20 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/extension_icon_set.h" 22 #include "chrome/common/extensions/extension_icon_set.h"
22 #include "chrome/common/extensions/extension_resource.h" 23 #include "chrome/common/extensions/extension_resource.h"
24 #include "chrome/common/extensions/manifest_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/url_pattern.h" 27 #include "extensions/common/url_pattern.h"
26 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
27 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/gfx/codec/png_codec.h" 30 #include "ui/gfx/codec/png_codec.h"
29 #include "webkit/glue/image_decoder.h" 31 #include "webkit/glue/image_decoder.h"
30 32
31 namespace extensions { 33 namespace extensions {
32 34
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 exploded.millisecond = millisecond; 79 exploded.millisecond = millisecond;
78 return base::Time::FromUTCExploded(exploded); 80 return base::Time::FromUTCExploded(exploded);
79 } 81 }
80 82
81 } // namespace 83 } // namespace
82 84
83 class ExtensionFromWebApp : public ::testing::Test { 85 class ExtensionFromWebApp : public ::testing::Test {
84 public: 86 public:
85 virtual void SetUp() OVERRIDE { 87 virtual void SetUp() OVERRIDE {
86 testing::Test::SetUp(); 88 testing::Test::SetUp();
89 (new AppLaunchManifestHandler)->Register();
87 (new IconsHandler)->Register(); 90 (new IconsHandler)->Register();
88 } 91 }
89 92
90 virtual void TearDown() OVERRIDE { 93 virtual void TearDown() OVERRIDE {
91 ManifestHandler::ClearRegistryForTesting(); 94 ManifestHandler::ClearRegistryForTesting();
92 testing::Test::TearDown(); 95 testing::Test::TearDown();
93 } 96 }
94 }; 97 };
95 98
96 TEST_F(ExtensionFromWebApp, GenerateVersion) { 99 TEST_F(ExtensionFromWebApp, GenerateVersion) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 EXPECT_TRUE(extension->is_app()); 139 EXPECT_TRUE(extension->is_app());
137 EXPECT_TRUE(extension->is_hosted_app()); 140 EXPECT_TRUE(extension->is_hosted_app());
138 EXPECT_FALSE(extension->is_legacy_packaged_app()); 141 EXPECT_FALSE(extension->is_legacy_packaged_app());
139 142
140 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 143 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=",
141 extension->public_key()); 144 extension->public_key());
142 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 145 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id());
143 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 146 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
144 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); 147 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name());
145 EXPECT_EQ(UTF16ToUTF8(web_app.description), extension->description()); 148 EXPECT_EQ(UTF16ToUTF8(web_app.description), extension->description());
146 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL()); 149 EXPECT_EQ(web_app.app_url, AppLauncherInfo::GetFullLaunchURL(extension));
147 EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size()); 150 EXPECT_EQ(2u, extension->GetActivePermissions()->apis().size());
148 EXPECT_TRUE(extension->HasAPIPermission("geolocation")); 151 EXPECT_TRUE(extension->HasAPIPermission("geolocation"));
149 EXPECT_TRUE(extension->HasAPIPermission("notifications")); 152 EXPECT_TRUE(extension->HasAPIPermission("notifications"));
150 ASSERT_EQ(1u, extension->web_extent().patterns().size()); 153 ASSERT_EQ(1u, extension->web_extent().patterns().size());
151 EXPECT_EQ("http://aaronboodman.com/gearpad/*", 154 EXPECT_EQ("http://aaronboodman.com/gearpad/*",
152 extension->web_extent().patterns().begin()->GetAsString()); 155 extension->web_extent().patterns().begin()->GetAsString());
153 156
154 EXPECT_EQ(web_app.icons.size(), IconsInfo::GetIcons(extension).map().size()); 157 EXPECT_EQ(web_app.icons.size(), IconsInfo::GetIcons(extension).map().size());
155 for (size_t i = 0; i < web_app.icons.size(); ++i) { 158 for (size_t i = 0; i < web_app.icons.size(); ++i) {
156 EXPECT_EQ(base::StringPrintf("icons/%i.png", web_app.icons[i].width), 159 EXPECT_EQ(base::StringPrintf("icons/%i.png", web_app.icons[i].width),
(...skipping 26 matching lines...) Expand all
183 EXPECT_TRUE(extension->is_app()); 186 EXPECT_TRUE(extension->is_app());
184 EXPECT_TRUE(extension->is_hosted_app()); 187 EXPECT_TRUE(extension->is_hosted_app());
185 EXPECT_FALSE(extension->is_legacy_packaged_app()); 188 EXPECT_FALSE(extension->is_legacy_packaged_app());
186 189
187 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=", 190 EXPECT_EQ("lJqm1+jncOHClAuwif1QxNJKfeV9Fbl9IBZx7FkNwkA=",
188 extension->public_key()); 191 extension->public_key());
189 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id()); 192 EXPECT_EQ("ncnbaadanljoanockmphfdkimpdedemj", extension->id());
190 EXPECT_EQ("1978.12.11.0", extension->version()->GetString()); 193 EXPECT_EQ("1978.12.11.0", extension->version()->GetString());
191 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name()); 194 EXPECT_EQ(UTF16ToUTF8(web_app.title), extension->name());
192 EXPECT_EQ("", extension->description()); 195 EXPECT_EQ("", extension->description());
193 EXPECT_EQ(web_app.app_url, extension->GetFullLaunchURL()); 196 EXPECT_EQ(web_app.app_url, AppLauncherInfo::GetFullLaunchURL(extension));
194 EXPECT_EQ(0u, IconsInfo::GetIcons(extension).map().size()); 197 EXPECT_EQ(0u, IconsInfo::GetIcons(extension).map().size());
195 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size()); 198 EXPECT_EQ(0u, extension->GetActivePermissions()->apis().size());
196 ASSERT_EQ(1u, extension->web_extent().patterns().size()); 199 ASSERT_EQ(1u, extension->web_extent().patterns().size());
197 EXPECT_EQ("*://aaronboodman.com/*", 200 EXPECT_EQ("*://aaronboodman.com/*",
198 extension->web_extent().patterns().begin()->GetAsString()); 201 extension->web_extent().patterns().begin()->GetAsString());
199 } 202 }
200 203
201 } // namespace extensions 204 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_web_app_browsertest.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698