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

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

Issue 266353006: Add generateAppForLink function in chrome.management (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/bookmark_app_helper.h" 5 #include "chrome/browser/extensions/bookmark_app_helper.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_service_unittest.h" 8 #include "chrome/browser/extensions/extension_service_unittest.h"
9 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 9 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/web_contents_tester.h"
11 #include "extensions/browser/extension_registry.h" 13 #include "extensions/browser/extension_registry.h"
12 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
13 #include "extensions/common/extension_icon_set.h" 15 #include "extensions/common/extension_icon_set.h"
14 #include "extensions/common/manifest_handlers/icons_handler.h" 16 #include "extensions/common/manifest_handlers/icons_handler.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 18 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/skia_util.h" 19 #include "ui/gfx/skia_util.h"
18 20
19 namespace { 21 namespace {
20 22
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 129
128 DISALLOW_COPY_AND_ASSIGN(TestBookmarkAppHelper); 130 DISALLOW_COPY_AND_ASSIGN(TestBookmarkAppHelper);
129 }; 131 };
130 132
131 // Android doesn't support extensions. 133 // Android doesn't support extensions.
132 #if !defined(OS_ANDROID) 134 #if !defined(OS_ANDROID)
133 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkApp) { 135 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkApp) {
134 WebApplicationInfo web_app_info; 136 WebApplicationInfo web_app_info;
135 web_app_info.app_url = GURL(kAppUrl); 137 web_app_info.app_url = GURL(kAppUrl);
136 web_app_info.title = base::UTF8ToUTF16(kAppTitle); 138 web_app_info.title = base::UTF8ToUTF16(kAppTitle);
137 web_app_info.description = base::UTF8ToUTF16(kAppDescription); 139 web_app_info.description = base::UTF8ToUTF16(kAppDescription);
calamity 2014/05/30 04:21:00 WebApplicationInfo::IconsInfo icon_info; icon_info
138 140
139 TestBookmarkAppHelper helper(service_, web_app_info, NULL); 141 scoped_ptr<content::WebContents> contents(
142 content::WebContentsTester::CreateTestWebContents(profile_.get(), NULL));
143 TestBookmarkAppHelper helper(service_, web_app_info, contents.get());
140 helper.Create(base::Bind(&TestBookmarkAppHelper::CreationComplete, 144 helper.Create(base::Bind(&TestBookmarkAppHelper::CreationComplete,
141 base::Unretained(&helper))); 145 base::Unretained(&helper)));
142 146
143 std::map<GURL, std::vector<SkBitmap> > icon_map; 147 std::map<GURL, std::vector<SkBitmap> > icon_map;
144 icon_map[GURL(kAppUrl)].push_back( 148 icon_map[GURL(kAppUrl)].push_back(
145 CreateSquareBitmapWithColor(kIconSizeSmall, SK_ColorRED)); 149 CreateSquareBitmapWithColor(kIconSizeSmall, SK_ColorRED));
146 helper.CompleteIconDownload(true, icon_map); 150 helper.CompleteIconDownload(true, icon_map);
147 151
148 base::RunLoop().RunUntilIdle(); 152 base::RunLoop().RunUntilIdle();
149 EXPECT_TRUE(helper.extension()); 153 EXPECT_TRUE(helper.extension());
150 const Extension* extension = 154 const Extension* extension =
151 service_->GetInstalledExtension(helper.extension()->id()); 155 service_->GetInstalledExtension(helper.extension()->id());
152 EXPECT_TRUE(extension); 156 EXPECT_TRUE(extension);
153 EXPECT_EQ(1u, service_->extensions()->size()); 157 EXPECT_EQ(1u, service_->extensions()->size());
154 EXPECT_TRUE(extension->from_bookmark()); 158 EXPECT_TRUE(extension->from_bookmark());
155 EXPECT_EQ(kAppTitle, extension->name()); 159 EXPECT_EQ(kAppTitle, extension->name());
156 EXPECT_EQ(kAppDescription, extension->description()); 160 EXPECT_EQ(kAppDescription, extension->description());
157 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension)); 161 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension));
158 EXPECT_FALSE( 162 EXPECT_FALSE(
159 IconsInfo::GetIconResource( 163 IconsInfo::GetIconResource(
160 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY).empty()); 164 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY).empty());
calamity 2014/05/30 04:21:00 EXPECT_FALSE( IconsInfo::GetIconResource(
161 } 165 }
162 166
163 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateAndUpdateBookmarkApp) { 167 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateAndUpdateBookmarkApp) {
164 EXPECT_EQ(0u, registry_->enabled_extensions().size()); 168 EXPECT_EQ(0u, registry_->enabled_extensions().size());
165 WebApplicationInfo web_app_info; 169 WebApplicationInfo web_app_info;
166 web_app_info.app_url = GURL(kAppUrl); 170 web_app_info.app_url = GURL(kAppUrl);
167 web_app_info.title = base::UTF8ToUTF16(kAppTitle); 171 web_app_info.title = base::UTF8ToUTF16(kAppTitle);
168 web_app_info.description = base::UTF8ToUTF16(kAppDescription); 172 web_app_info.description = base::UTF8ToUTF16(kAppDescription);
169 web_app_info.icons.push_back( 173 web_app_info.icons.push_back(
170 CreateIconInfoWithBitmap(kIconSizeSmall, SK_ColorRED)); 174 CreateIconInfoWithBitmap(kIconSizeSmall, SK_ColorRED));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 275 }
272 276
273 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) { 277 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) {
274 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org"))); 278 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org")));
275 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path"))); 279 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path")));
276 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org"))); 280 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org")));
277 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags"))); 281 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags")));
278 } 282 }
279 283
280 } // namespace extensions 284 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698