| OLD | NEW |
| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 EXPECT_FALSE(tester->manifest().IsEmpty()); | 461 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 462 EXPECT_FALSE(tester->manifest_url().is_empty()); | 462 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 463 | 463 |
| 464 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 464 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 465 EXPECT_NE(nullptr, tester->primary_icon()); | 465 EXPECT_NE(nullptr, tester->primary_icon()); |
| 466 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 466 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 467 EXPECT_EQ(nullptr, tester->badge_icon()); | 467 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 468 EXPECT_FALSE(tester->is_installable()); | 468 EXPECT_FALSE(tester->is_installable()); |
| 469 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 469 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 470 } | 470 } |
| 471 |
| 472 // Navigate to a page with a bad badge icon. This should now fail with |
| 473 // NO_ICON_AVAILABLE, but still have the manifest and primary icon. |
| 474 { |
| 475 base::RunLoop run_loop; |
| 476 std::unique_ptr<CallbackTester> tester( |
| 477 new CallbackTester(run_loop.QuitClosure())); |
| 478 |
| 479 NavigateAndRunInstallableManager(tester.get(), |
| 480 GetPrimaryIconAndBadgeIconParams(), |
| 481 GetURLOfPageWithServiceWorkerAndManifest( |
| 482 "/banners/manifest_bad_badge.json")); |
| 483 run_loop.Run(); |
| 484 |
| 485 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 486 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 487 |
| 488 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 489 EXPECT_NE(nullptr, tester->primary_icon()); |
| 490 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 491 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 492 EXPECT_FALSE(tester->is_installable()); |
| 493 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code()); |
| 494 } |
| 471 } | 495 } |
| 472 | 496 |
| 473 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { | 497 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { |
| 474 // Request everything except badge icon. | 498 // Request everything except badge icon. |
| 475 { | 499 { |
| 476 base::RunLoop run_loop; | 500 base::RunLoop run_loop; |
| 477 std::unique_ptr<CallbackTester> tester( | 501 std::unique_ptr<CallbackTester> tester( |
| 478 new CallbackTester(run_loop.QuitClosure())); | 502 new CallbackTester(run_loop.QuitClosure())); |
| 479 | 503 |
| 480 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), | 504 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 EXPECT_EQ(nullptr, tester->badge_icon()); | 736 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 713 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 737 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 714 } | 738 } |
| 715 | 739 |
| 716 { | 740 { |
| 717 base::RunLoop run_loop; | 741 base::RunLoop run_loop; |
| 718 std::unique_ptr<CallbackTester> tester( | 742 std::unique_ptr<CallbackTester> tester( |
| 719 new CallbackTester(run_loop.QuitClosure())); | 743 new CallbackTester(run_loop.QuitClosure())); |
| 720 | 744 |
| 721 // Dial up the primary icon size requirements to something that isn't | 745 // Dial up the primary icon size requirements to something that isn't |
| 722 // available. This should now fail with NoIconMatchingRequirements. | 746 // available. This should now fail with NO_ACCEPTABLE_ICON. |
| 723 InstallableParams params = GetWebAppParams(); | 747 InstallableParams params = GetWebAppParams(); |
| 724 params.ideal_primary_icon_size_in_px = 2000; | 748 params.ideal_primary_icon_size_in_px = 2000; |
| 725 params.minimum_primary_icon_size_in_px = 2000; | 749 params.minimum_primary_icon_size_in_px = 2000; |
| 726 RunInstallableManager(tester.get(), params); | 750 RunInstallableManager(tester.get(), params); |
| 727 run_loop.Run(); | 751 run_loop.Run(); |
| 728 | 752 |
| 729 EXPECT_FALSE(tester->manifest_url().is_empty()); | 753 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 730 EXPECT_FALSE(tester->manifest().IsEmpty()); | 754 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 731 EXPECT_TRUE(tester->is_installable()); | 755 EXPECT_TRUE(tester->is_installable()); |
| 732 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 756 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 733 EXPECT_EQ(nullptr, tester->primary_icon()); | 757 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 734 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 758 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 735 EXPECT_EQ(nullptr, tester->badge_icon()); | 759 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 736 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 760 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| 737 } | 761 } |
| 738 | 762 |
| 739 // Navigate and verify the reverse: an overly large primary icon requested | 763 // Navigate and verify the reverse: an overly large primary icon requested |
| 740 // first fails, but a smaller primary icon requested second passes. | 764 // first fails, but a smaller primary icon requested second passes. |
| 741 { | 765 { |
| 742 base::RunLoop run_loop; | 766 base::RunLoop run_loop; |
| 743 std::unique_ptr<CallbackTester> tester( | 767 std::unique_ptr<CallbackTester> tester( |
| 744 new CallbackTester(run_loop.QuitClosure())); | 768 new CallbackTester(run_loop.QuitClosure())); |
| 745 | 769 |
| 746 // This should fail with NoIconMatchingRequirements. | 770 // This should fail with NO_ACCEPTABLE_ICON. |
| 747 InstallableParams params = GetWebAppParams(); | 771 InstallableParams params = GetWebAppParams(); |
| 748 params.ideal_primary_icon_size_in_px = 2000; | 772 params.ideal_primary_icon_size_in_px = 2000; |
| 749 params.minimum_primary_icon_size_in_px = 2000; | 773 params.minimum_primary_icon_size_in_px = 2000; |
| 750 NavigateAndRunInstallableManager(tester.get(), params, | 774 NavigateAndRunInstallableManager(tester.get(), params, |
| 751 "/banners/manifest_test_page.html"); | 775 "/banners/manifest_test_page.html"); |
| 752 run_loop.Run(); | 776 run_loop.Run(); |
| 753 | 777 |
| 754 EXPECT_FALSE(tester->manifest_url().is_empty()); | 778 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 755 EXPECT_FALSE(tester->manifest().IsEmpty()); | 779 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 756 EXPECT_TRUE(tester->is_installable()); | 780 EXPECT_TRUE(tester->is_installable()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 785 CheckNestedCallsToGetData) { | 809 CheckNestedCallsToGetData) { |
| 786 // Verify that we can call GetData while in a callback from GetData. | 810 // Verify that we can call GetData while in a callback from GetData. |
| 787 base::RunLoop run_loop; | 811 base::RunLoop run_loop; |
| 788 InstallableParams params = GetWebAppParams(); | 812 InstallableParams params = GetWebAppParams(); |
| 789 std::unique_ptr<NestedCallbackTester> tester( | 813 std::unique_ptr<NestedCallbackTester> tester( |
| 790 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); | 814 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); |
| 791 | 815 |
| 792 tester->Run(); | 816 tester->Run(); |
| 793 run_loop.Run(); | 817 run_loop.Run(); |
| 794 } | 818 } |
| OLD | NEW |