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

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

Issue 2612493002: Prevent app banners from displaying after desktop add to shelf. (Closed)
Patch Set: Created 3 years, 11 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/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/banners/app_banner_settings_helper.h"
9 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_service_test_base.h" 11 #include "chrome/browser/extensions/extension_service_test_base.h"
11 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 12 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/web_contents_tester.h" 16 #include "content/public/test/web_contents_tester.h"
16 #include "extensions/browser/extension_registry.h" 17 #include "extensions/browser/extension_registry.h"
17 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
18 #include "extensions/common/extension_icon_set.h" 19 #include "extensions/common/extension_icon_set.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 service_->GetInstalledExtension(helper.extension()->id()); 334 service_->GetInstalledExtension(helper.extension()->id());
334 EXPECT_TRUE(extension); 335 EXPECT_TRUE(extension);
335 EXPECT_EQ(1u, registry()->enabled_extensions().size()); 336 EXPECT_EQ(1u, registry()->enabled_extensions().size());
336 EXPECT_TRUE(extension->from_bookmark()); 337 EXPECT_TRUE(extension->from_bookmark());
337 EXPECT_EQ(kAppTitle, extension->name()); 338 EXPECT_EQ(kAppTitle, extension->name());
338 EXPECT_EQ(kAppDescription, extension->description()); 339 EXPECT_EQ(kAppDescription, extension->description());
339 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension)); 340 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension));
340 EXPECT_FALSE( 341 EXPECT_FALSE(
341 IconsInfo::GetIconResource( 342 IconsInfo::GetIconResource(
342 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY).empty()); 343 extension, kIconSizeSmall, ExtensionIconSet::MATCH_EXACTLY).empty());
344 EXPECT_FALSE(
345 AppBannerSettingsHelper::GetSingleBannerEvent(
346 contents.get(), web_app_info.app_url, web_app_info.app_url.spec(),
347 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN)
348 .is_null());
343 } 349 }
344 350
345 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkAppWithManifest) { 351 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkAppWithManifest) {
346 WebApplicationInfo web_app_info; 352 WebApplicationInfo web_app_info;
347 353
348 std::unique_ptr<content::WebContents> contents( 354 std::unique_ptr<content::WebContents> contents(
349 content::WebContentsTester::CreateTestWebContents(profile(), nullptr)); 355 content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
350 TestBookmarkAppHelper helper(service_, web_app_info, contents.get()); 356 TestBookmarkAppHelper helper(service_, web_app_info, contents.get());
351 helper.Create(base::Bind(&TestBookmarkAppHelper::CreationComplete, 357 helper.Create(base::Bind(&TestBookmarkAppHelper::CreationComplete,
352 base::Unretained(&helper))); 358 base::Unretained(&helper)));
353 359
354 content::Manifest manifest; 360 content::Manifest manifest;
355 manifest.start_url = GURL(kAppUrl); 361 manifest.start_url = GURL(kAppUrl);
356 manifest.name = base::NullableString16(base::UTF8ToUTF16(kAppTitle), false); 362 manifest.name = base::NullableString16(base::UTF8ToUTF16(kAppTitle), false);
357 helper.CompleteGetManifest(manifest); 363 helper.CompleteGetManifest(manifest);
358 364
359 std::map<GURL, std::vector<SkBitmap> > icon_map; 365 std::map<GURL, std::vector<SkBitmap> > icon_map;
360 helper.CompleteIconDownload(true, icon_map); 366 helper.CompleteIconDownload(true, icon_map);
361 367
362 base::RunLoop().RunUntilIdle(); 368 base::RunLoop().RunUntilIdle();
363 EXPECT_TRUE(helper.extension()); 369 EXPECT_TRUE(helper.extension());
364 const Extension* extension = 370 const Extension* extension =
365 service_->GetInstalledExtension(helper.extension()->id()); 371 service_->GetInstalledExtension(helper.extension()->id());
366 EXPECT_TRUE(extension); 372 EXPECT_TRUE(extension);
367 EXPECT_EQ(1u, registry()->enabled_extensions().size()); 373 EXPECT_EQ(1u, registry()->enabled_extensions().size());
368 EXPECT_TRUE(extension->from_bookmark()); 374 EXPECT_TRUE(extension->from_bookmark());
369 EXPECT_EQ(kAppTitle, extension->name()); 375 EXPECT_EQ(kAppTitle, extension->name());
370 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension)); 376 EXPECT_EQ(GURL(kAppUrl), AppLaunchInfo::GetLaunchWebURL(extension));
377 EXPECT_FALSE(
378 AppBannerSettingsHelper::GetSingleBannerEvent(
379 contents.get(), manifest.start_url, manifest.start_url.spec(),
380 AppBannerSettingsHelper::APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN)
381 .is_null());
371 } 382 }
372 383
373 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkAppNoContents) { 384 TEST_F(BookmarkAppHelperExtensionServiceTest, CreateBookmarkAppNoContents) {
374 WebApplicationInfo web_app_info; 385 WebApplicationInfo web_app_info;
375 web_app_info.app_url = GURL(kAppUrl); 386 web_app_info.app_url = GURL(kAppUrl);
376 web_app_info.title = base::UTF8ToUTF16(kAppTitle); 387 web_app_info.title = base::UTF8ToUTF16(kAppTitle);
377 web_app_info.description = base::UTF8ToUTF16(kAppDescription); 388 web_app_info.description = base::UTF8ToUTF16(kAppDescription);
378 web_app_info.icons.push_back( 389 web_app_info.icons.push_back(
379 CreateIconInfoWithBitmap(kIconSizeTiny, SK_ColorRED)); 390 CreateIconInfoWithBitmap(kIconSizeTiny, SK_ColorRED));
380 391
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 TestIconGeneration(kIconSizeTiny, 0, 3); 773 TestIconGeneration(kIconSizeTiny, 0, 3);
763 } 774 }
764 775
765 TEST_F(BookmarkAppHelperTest, IconsResizedWhenOnlyAGigantorOneIsProvided) { 776 TEST_F(BookmarkAppHelperTest, IconsResizedWhenOnlyAGigantorOneIsProvided) {
766 // When an enormous icon is provided, each desired icon size should be resized 777 // When an enormous icon is provided, each desired icon size should be resized
767 // from it, and no icons should be generated. 778 // from it, and no icons should be generated.
768 TestIconGeneration(kIconSizeGigantor, 0, 3); 779 TestIconGeneration(kIconSizeGigantor, 0, 3);
769 } 780 }
770 781
771 } // namespace extensions 782 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper.cc ('k') | chrome/browser/ui/extensions/application_launch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698