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

Side by Side Diff: chrome/browser/installable/installable_manager_browsertest.cc

Issue 2791923005: Fails InstallableManager if a selected badge icon cannot be fetched. (Closed)
Patch Set: Addressing comments Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/installable/installable_manager.h" 5 #include "chrome/browser/installable/installable_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 EXPECT_FALSE(tester->manifest_url().is_empty()); 475 EXPECT_FALSE(tester->manifest_url().is_empty());
476 476
477 EXPECT_FALSE(tester->primary_icon_url().is_empty()); 477 EXPECT_FALSE(tester->primary_icon_url().is_empty());
478 EXPECT_NE(nullptr, tester->primary_icon()); 478 EXPECT_NE(nullptr, tester->primary_icon());
479 EXPECT_TRUE(tester->badge_icon_url().is_empty()); 479 EXPECT_TRUE(tester->badge_icon_url().is_empty());
480 EXPECT_EQ(nullptr, tester->badge_icon()); 480 EXPECT_EQ(nullptr, tester->badge_icon());
481 EXPECT_FALSE(tester->is_installable()); 481 EXPECT_FALSE(tester->is_installable());
482 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 482 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
483 EXPECT_EQ(GetStatus(), InstallabilityCheckStatus::NOT_STARTED); 483 EXPECT_EQ(GetStatus(), InstallabilityCheckStatus::NOT_STARTED);
484 } 484 }
485
486 // Navigate to a page with a bad badge icon. This should now fail with
487 // NO_ICON_AVAILABLE, but still have the manifest and primary icon.
488 {
489 base::RunLoop run_loop;
490 std::unique_ptr<CallbackTester> tester(
491 new CallbackTester(run_loop.QuitClosure()));
492
493 NavigateAndRunInstallableManager(tester.get(),
494 GetPrimaryIconAndBadgeIconParams(),
495 GetURLOfPageWithServiceWorkerAndManifest(
496 "/banners/manifest_bad_badge.json"));
497 run_loop.Run();
498
499 EXPECT_FALSE(tester->manifest().IsEmpty());
500 EXPECT_FALSE(tester->manifest_url().is_empty());
501
502 EXPECT_FALSE(tester->primary_icon_url().is_empty());
503 EXPECT_NE(nullptr, tester->primary_icon());
504 EXPECT_TRUE(tester->badge_icon_url().is_empty());
505 EXPECT_EQ(nullptr, tester->badge_icon());
506 EXPECT_FALSE(tester->is_installable());
507 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code());
508 EXPECT_EQ(GetStatus(), InstallabilityCheckStatus::NOT_STARTED);
509 }
485 } 510 }
486 511
487 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { 512 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) {
488 // Request everything except badge icon. 513 // Request everything except badge icon.
489 { 514 {
490 base::RunLoop run_loop; 515 base::RunLoop run_loop;
491 std::unique_ptr<CallbackTester> tester( 516 std::unique_ptr<CallbackTester> tester(
492 new CallbackTester(run_loop.QuitClosure())); 517 new CallbackTester(run_loop.QuitClosure()));
493 518
494 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 519 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 EXPECT_EQ(nullptr, tester->badge_icon()); 765 EXPECT_EQ(nullptr, tester->badge_icon());
741 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 766 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
742 } 767 }
743 768
744 { 769 {
745 base::RunLoop run_loop; 770 base::RunLoop run_loop;
746 std::unique_ptr<CallbackTester> tester( 771 std::unique_ptr<CallbackTester> tester(
747 new CallbackTester(run_loop.QuitClosure())); 772 new CallbackTester(run_loop.QuitClosure()));
748 773
749 // Dial up the primary icon size requirements to something that isn't 774 // Dial up the primary icon size requirements to something that isn't
750 // available. This should now fail with NoIconMatchingRequirements. 775 // available. This should now fail with NO_ACCEPTABLE_ICON.
751 InstallableParams params = GetWebAppParams(); 776 InstallableParams params = GetWebAppParams();
752 params.ideal_primary_icon_size_in_px = 2000; 777 params.ideal_primary_icon_size_in_px = 2000;
753 params.minimum_primary_icon_size_in_px = 2000; 778 params.minimum_primary_icon_size_in_px = 2000;
754 RunInstallableManager(tester.get(), params); 779 RunInstallableManager(tester.get(), params);
755 run_loop.Run(); 780 run_loop.Run();
756 781
757 EXPECT_FALSE(tester->manifest_url().is_empty()); 782 EXPECT_FALSE(tester->manifest_url().is_empty());
758 EXPECT_FALSE(tester->manifest().IsEmpty()); 783 EXPECT_FALSE(tester->manifest().IsEmpty());
759 EXPECT_TRUE(tester->is_installable()); 784 EXPECT_TRUE(tester->is_installable());
760 EXPECT_TRUE(tester->primary_icon_url().is_empty()); 785 EXPECT_TRUE(tester->primary_icon_url().is_empty());
761 EXPECT_EQ(nullptr, tester->primary_icon()); 786 EXPECT_EQ(nullptr, tester->primary_icon());
762 EXPECT_TRUE(tester->badge_icon_url().is_empty()); 787 EXPECT_TRUE(tester->badge_icon_url().is_empty());
763 EXPECT_EQ(nullptr, tester->badge_icon()); 788 EXPECT_EQ(nullptr, tester->badge_icon());
764 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 789 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
765 } 790 }
766 791
767 // Navigate and verify the reverse: an overly large primary icon requested 792 // Navigate and verify the reverse: an overly large primary icon requested
768 // first fails, but a smaller primary icon requested second passes. 793 // first fails, but a smaller primary icon requested second passes.
769 { 794 {
770 base::RunLoop run_loop; 795 base::RunLoop run_loop;
771 std::unique_ptr<CallbackTester> tester( 796 std::unique_ptr<CallbackTester> tester(
772 new CallbackTester(run_loop.QuitClosure())); 797 new CallbackTester(run_loop.QuitClosure()));
773 798
774 // This should fail with NoIconMatchingRequirements. 799 // This should fail with NO_ACCEPTABLE_ICON.
775 InstallableParams params = GetWebAppParams(); 800 InstallableParams params = GetWebAppParams();
776 params.ideal_primary_icon_size_in_px = 2000; 801 params.ideal_primary_icon_size_in_px = 2000;
777 params.minimum_primary_icon_size_in_px = 2000; 802 params.minimum_primary_icon_size_in_px = 2000;
778 NavigateAndRunInstallableManager(tester.get(), params, 803 NavigateAndRunInstallableManager(tester.get(), params,
779 "/banners/manifest_test_page.html"); 804 "/banners/manifest_test_page.html");
780 run_loop.Run(); 805 run_loop.Run();
781 806
782 EXPECT_FALSE(tester->manifest_url().is_empty()); 807 EXPECT_FALSE(tester->manifest_url().is_empty());
783 EXPECT_FALSE(tester->manifest().IsEmpty()); 808 EXPECT_FALSE(tester->manifest().IsEmpty());
784 EXPECT_TRUE(tester->is_installable()); 809 EXPECT_TRUE(tester->is_installable());
(...skipping 28 matching lines...) Expand all
813 CheckNestedCallsToGetData) { 838 CheckNestedCallsToGetData) {
814 // Verify that we can call GetData while in a callback from GetData. 839 // Verify that we can call GetData while in a callback from GetData.
815 base::RunLoop run_loop; 840 base::RunLoop run_loop;
816 InstallableParams params = GetWebAppParams(); 841 InstallableParams params = GetWebAppParams();
817 std::unique_ptr<NestedCallbackTester> tester( 842 std::unique_ptr<NestedCallbackTester> tester(
818 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); 843 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure()));
819 844
820 tester->Run(); 845 tester->Run();
821 run_loop.Run(); 846 run_loop.Run();
822 } 847 }
OLDNEW
« no previous file with comments | « chrome/browser/installable/installable_manager.cc ('k') | chrome/test/data/banners/manifest_bad_badge.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698