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

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

Issue 318863008: Move ExtensionServiceTestBase into it's own header/cc file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge conflict 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
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.h"
9 #include "chrome/browser/extensions/extension_service_test_base.h"
9 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 10 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
10 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/browser/render_process_host.h" 12 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 #include "content/public/test/web_contents_tester.h" 14 #include "content/public/test/web_contents_tester.h"
14 #include "extensions/browser/extension_registry.h" 15 #include "extensions/browser/extension_registry.h"
15 #include "extensions/common/constants.h" 16 #include "extensions/common/constants.h"
16 #include "extensions/common/extension_icon_set.h" 17 #include "extensions/common/extension_icon_set.h"
17 #include "extensions/common/manifest_handlers/icons_handler.h" 18 #include "extensions/common/manifest_handlers/icons_handler.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 16 matching lines...) Expand all
35 36
36 class BookmarkAppHelperTest : public testing::Test { 37 class BookmarkAppHelperTest : public testing::Test {
37 public: 38 public:
38 BookmarkAppHelperTest() {} 39 BookmarkAppHelperTest() {}
39 virtual ~BookmarkAppHelperTest() {} 40 virtual ~BookmarkAppHelperTest() {}
40 41
41 private: 42 private:
42 DISALLOW_COPY_AND_ASSIGN(BookmarkAppHelperTest); 43 DISALLOW_COPY_AND_ASSIGN(BookmarkAppHelperTest);
43 }; 44 };
44 45
45 class BookmarkAppHelperExtensionServiceTest : public ExtensionServiceTestBase { 46 class BookmarkAppHelperExtensionServiceTest
47 : public extensions::ExtensionServiceTestBase {
46 public: 48 public:
47 BookmarkAppHelperExtensionServiceTest() {} 49 BookmarkAppHelperExtensionServiceTest() {}
48 virtual ~BookmarkAppHelperExtensionServiceTest() {} 50 virtual ~BookmarkAppHelperExtensionServiceTest() {}
49 51
50 virtual void SetUp() OVERRIDE { 52 virtual void SetUp() OVERRIDE {
51 ExtensionServiceTestBase::SetUp(); 53 extensions::ExtensionServiceTestBase::SetUp();
52 InitializeEmptyExtensionService(); 54 InitializeEmptyExtensionService();
53 service_->Init(); 55 service_->Init();
54 EXPECT_EQ(0u, service_->extensions()->size()); 56 EXPECT_EQ(0u, service_->extensions()->size());
55 } 57 }
56 58
57 virtual void TearDown() OVERRIDE { 59 virtual void TearDown() OVERRIDE {
58 ExtensionServiceTestBase::TearDown(); 60 ExtensionServiceTestBase::TearDown();
59 for (content::RenderProcessHost::iterator i( 61 for (content::RenderProcessHost::iterator i(
60 content::RenderProcessHost::AllHostsIterator()); 62 content::RenderProcessHost::AllHostsIterator());
61 !i.IsAtEnd(); 63 !i.IsAtEnd();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 EXPECT_FALSE( 217 EXPECT_FALSE(
216 IconsInfo::GetIconResource( 218 IconsInfo::GetIconResource(
217 extension, kIconSizeMedium, ExtensionIconSet::MATCH_EXACTLY).empty()); 219 extension, kIconSizeMedium, ExtensionIconSet::MATCH_EXACTLY).empty());
218 EXPECT_FALSE( 220 EXPECT_FALSE(
219 IconsInfo::GetIconResource(extension, 221 IconsInfo::GetIconResource(extension,
220 kIconSizeMedium * 2, 222 kIconSizeMedium * 2,
221 ExtensionIconSet::MATCH_EXACTLY).empty()); 223 ExtensionIconSet::MATCH_EXACTLY).empty());
222 } 224 }
223 225
224 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateAndUpdateBookmarkApp) { 226 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateAndUpdateBookmarkApp) {
225 EXPECT_EQ(0u, registry_->enabled_extensions().size()); 227 EXPECT_EQ(0u, registry()->enabled_extensions().size());
226 WebApplicationInfo web_app_info; 228 WebApplicationInfo web_app_info;
227 web_app_info.app_url = GURL(kAppUrl); 229 web_app_info.app_url = GURL(kAppUrl);
228 web_app_info.title = base::UTF8ToUTF16(kAppTitle); 230 web_app_info.title = base::UTF8ToUTF16(kAppTitle);
229 web_app_info.description = base::UTF8ToUTF16(kAppDescription); 231 web_app_info.description = base::UTF8ToUTF16(kAppDescription);
230 web_app_info.icons.push_back( 232 web_app_info.icons.push_back(
231 CreateIconInfoWithBitmap(kIconSizeSmall, SK_ColorRED)); 233 CreateIconInfoWithBitmap(kIconSizeSmall, SK_ColorRED));
232 234
233 extensions::CreateOrUpdateBookmarkApp(service_, web_app_info); 235 extensions::CreateOrUpdateBookmarkApp(service_, web_app_info);
234 base::RunLoop().RunUntilIdle(); 236 base::RunLoop().RunUntilIdle();
235 237
236 { 238 {
237 EXPECT_EQ(1u, registry_->enabled_extensions().size()); 239 EXPECT_EQ(1u, registry()->enabled_extensions().size());
238 const Extension* extension = service_->extensions()->begin()->get(); 240 const Extension* extension = service_->extensions()->begin()->get();
239 EXPECT_TRUE(extension->from_bookmark()); 241 EXPECT_TRUE(extension->from_bookmark());
240 EXPECT_EQ(kAppTitle, extension->name()); 242 EXPECT_EQ(kAppTitle, extension->name());
241 EXPECT_EQ(kAppDescription, extension->description()); 243 EXPECT_EQ(kAppDescription, extension->description());
242 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension)); 244 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension));
243 EXPECT_FALSE(extensions::IconsInfo::GetIconResource( 245 EXPECT_FALSE(extensions::IconsInfo::GetIconResource(
244 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY) 246 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY)
245 .empty()); 247 .empty());
246 } 248 }
247 249
248 web_app_info.title = base::UTF8ToUTF16(kAlternativeAppTitle); 250 web_app_info.title = base::UTF8ToUTF16(kAlternativeAppTitle);
249 web_app_info.icons[0] = CreateIconInfoWithBitmap(kIconSizeLarge, SK_ColorRED); 251 web_app_info.icons[0] = CreateIconInfoWithBitmap(kIconSizeLarge, SK_ColorRED);
250 252
251 extensions::CreateOrUpdateBookmarkApp(service_, web_app_info); 253 extensions::CreateOrUpdateBookmarkApp(service_, web_app_info);
252 base::RunLoop().RunUntilIdle(); 254 base::RunLoop().RunUntilIdle();
253 255
254 { 256 {
255 EXPECT_EQ(1u, registry_->enabled_extensions().size()); 257 EXPECT_EQ(1u, registry()->enabled_extensions().size());
256 const Extension* extension = service_->extensions()->begin()->get(); 258 const Extension* extension = service_->extensions()->begin()->get();
257 EXPECT_TRUE(extension->from_bookmark()); 259 EXPECT_TRUE(extension->from_bookmark());
258 EXPECT_EQ(kAlternativeAppTitle, extension->name()); 260 EXPECT_EQ(kAlternativeAppTitle, extension->name());
259 EXPECT_EQ(kAppDescription, extension->description()); 261 EXPECT_EQ(kAppDescription, extension->description());
260 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension)); 262 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension));
261 EXPECT_TRUE(extensions::IconsInfo::GetIconResource( 263 EXPECT_TRUE(extensions::IconsInfo::GetIconResource(
262 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY) 264 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY)
263 .empty()); 265 .empty());
264 EXPECT_FALSE(extensions::IconsInfo::GetIconResource( 266 EXPECT_FALSE(extensions::IconsInfo::GetIconResource(
265 extension, kIconSizeLarge, ExtensionIconSet::MATCH_EXACTLY) 267 extension, kIconSizeLarge, ExtensionIconSet::MATCH_EXACTLY)
266 .empty()); 268 .empty());
267 } 269 }
268 } 270 }
269 271
270 TEST_F(BookmarkAppHelperExtensionServiceTest, GetWebApplicationInfo) { 272 TEST_F(BookmarkAppHelperExtensionServiceTest, GetWebApplicationInfo) {
271 WebApplicationInfo web_app_info; 273 WebApplicationInfo web_app_info;
272 web_app_info.app_url = GURL(kAppUrl); 274 web_app_info.app_url = GURL(kAppUrl);
273 web_app_info.title = base::UTF8ToUTF16(kAppTitle); 275 web_app_info.title = base::UTF8ToUTF16(kAppTitle);
274 web_app_info.description = base::UTF8ToUTF16(kAppDescription); 276 web_app_info.description = base::UTF8ToUTF16(kAppDescription);
275 277
276 web_app_info.icons.push_back( 278 web_app_info.icons.push_back(
277 CreateIconInfoWithBitmap(kIconSizeSmall, SK_ColorRED)); 279 CreateIconInfoWithBitmap(kIconSizeSmall, SK_ColorRED));
278 web_app_info.icons.push_back( 280 web_app_info.icons.push_back(
279 CreateIconInfoWithBitmap(kIconSizeLarge, SK_ColorRED)); 281 CreateIconInfoWithBitmap(kIconSizeLarge, SK_ColorRED));
280 282
281 extensions::CreateOrUpdateBookmarkApp(service_, web_app_info); 283 extensions::CreateOrUpdateBookmarkApp(service_, web_app_info);
282 base::RunLoop().RunUntilIdle(); 284 base::RunLoop().RunUntilIdle();
283 285
284 EXPECT_EQ(1u, registry_->enabled_extensions().size()); 286 EXPECT_EQ(1u, registry()->enabled_extensions().size());
285 base::RunLoop run_loop; 287 base::RunLoop run_loop;
286 extensions::GetWebApplicationInfoFromApp( 288 extensions::GetWebApplicationInfoFromApp(
287 profile_.get(), 289 profile_.get(),
288 service_->extensions()->begin()->get(), 290 service_->extensions()->begin()->get(),
289 base::Bind( 291 base::Bind(
290 &ValidateWebApplicationInfo, run_loop.QuitClosure(), web_app_info)); 292 &ValidateWebApplicationInfo, run_loop.QuitClosure(), web_app_info));
291 run_loop.Run(); 293 run_loop.Run();
292 } 294 }
293 #endif 295 #endif
294 296
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 334 }
333 335
334 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) { 336 TEST_F(BookmarkAppHelperTest, IsValidBookmarkAppUrl) {
335 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org"))); 337 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("https://www.chromium.org")));
336 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path"))); 338 EXPECT_TRUE(IsValidBookmarkAppUrl(GURL("http://www.chromium.org/path")));
337 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org"))); 339 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("ftp://www.chromium.org")));
338 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags"))); 340 EXPECT_FALSE(IsValidBookmarkAppUrl(GURL("chrome://flags")));
339 } 341 }
340 342
341 } // namespace extensions 343 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698