Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "net/test/embedded_test_server/embedded_test_server.h" | 15 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 InstallableParams GetManifestParams() { | 19 InstallableParams GetManifestParams() { |
| 20 InstallableParams params; | 20 InstallableParams params; |
| 21 params.check_installable = false; | 21 params.check_installable = false; |
| 22 params.fetch_valid_icon = false; | 22 params.fetch_valid_icon = false; |
| 23 return params; | 23 return params; |
| 24 } | 24 } |
| 25 | 25 |
| 26 InstallableParams GetWebAppParams() { | 26 InstallableParams GetWebAppParams() { |
| 27 InstallableParams params = GetManifestParams(); | 27 InstallableParams params = GetManifestParams(); |
| 28 params.ideal_icon_size_in_dp = 48; | 28 params.ideal_icon_size_in_px = 48; |
|
dominickn
2016/12/19 06:23:32
Change the 48 to 144 in all of these locations.
| |
| 29 params.minimum_icon_size_in_dp = 48; | 29 params.minimum_icon_size_in_px = 48; |
| 30 params.check_installable = true; | 30 params.check_installable = true; |
| 31 params.fetch_valid_icon = true; | 31 params.fetch_valid_icon = true; |
| 32 return params; | 32 return params; |
| 33 } | 33 } |
| 34 | 34 |
| 35 InstallableParams GetIconParams() { | 35 InstallableParams GetIconParams() { |
| 36 InstallableParams params = GetManifestParams(); | 36 InstallableParams params = GetManifestParams(); |
| 37 params.ideal_icon_size_in_dp = 48; | 37 params.ideal_icon_size_in_px = 48; |
| 38 params.minimum_icon_size_in_dp = 48; | 38 params.minimum_icon_size_in_px = 48; |
| 39 params.fetch_valid_icon = true; | 39 params.fetch_valid_icon = true; |
| 40 return params; | 40 return params; |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // anonymous namespace | 43 } // anonymous namespace |
| 44 | 44 |
| 45 class CallbackTester { | 45 class CallbackTester { |
| 46 public: | 46 public: |
| 47 explicit CallbackTester(base::Closure quit_closure) | 47 explicit CallbackTester(base::Closure quit_closure) |
| 48 : quit_closure_(quit_closure) { } | 48 : quit_closure_(quit_closure) { } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Ask for a different size icon. This should fail with START_URL_NOT_VALID | 343 // Ask for a different size icon. This should fail with START_URL_NOT_VALID |
| 344 // since we won't have a cached icon error. | 344 // since we won't have a cached icon error. |
| 345 { | 345 { |
| 346 base::RunLoop run_loop; | 346 base::RunLoop run_loop; |
| 347 std::unique_ptr<CallbackTester> tester( | 347 std::unique_ptr<CallbackTester> tester( |
| 348 new CallbackTester(run_loop.QuitClosure())); | 348 new CallbackTester(run_loop.QuitClosure())); |
| 349 | 349 |
| 350 InstallableParams params = GetWebAppParams(); | 350 InstallableParams params = GetWebAppParams(); |
| 351 params.ideal_icon_size_in_dp = 32; | 351 params.ideal_icon_size_in_px = 32; |
|
dominickn
2016/12/19 06:23:32
Change 32 to 96.
| |
| 352 params.minimum_icon_size_in_dp = 32; | 352 params.minimum_icon_size_in_px = 32; |
| 353 RunInstallableManager(tester.get(), params); | 353 RunInstallableManager(tester.get(), params); |
| 354 run_loop.Run(); | 354 run_loop.Run(); |
| 355 | 355 |
| 356 EXPECT_FALSE(tester->manifest().IsEmpty()); | 356 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 357 EXPECT_FALSE(tester->manifest_url().is_empty()); | 357 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 358 EXPECT_TRUE(tester->manifest().prefer_related_applications); | 358 EXPECT_TRUE(tester->manifest().prefer_related_applications); |
| 359 | 359 |
| 360 EXPECT_TRUE(tester->icon_url().is_empty()); | 360 EXPECT_TRUE(tester->icon_url().is_empty()); |
| 361 EXPECT_EQ(nullptr, tester->icon()); | 361 EXPECT_EQ(nullptr, tester->icon()); |
| 362 EXPECT_FALSE(tester->is_installable()); | 362 EXPECT_FALSE(tester->is_installable()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 } | 565 } |
| 566 | 566 |
| 567 { | 567 { |
| 568 base::RunLoop run_loop; | 568 base::RunLoop run_loop; |
| 569 std::unique_ptr<CallbackTester> tester( | 569 std::unique_ptr<CallbackTester> tester( |
| 570 new CallbackTester(run_loop.QuitClosure())); | 570 new CallbackTester(run_loop.QuitClosure())); |
| 571 | 571 |
| 572 // Dial up the icon size requirements to something that isn't available. | 572 // Dial up the icon size requirements to something that isn't available. |
| 573 // This should now fail with NoIconMatchingRequirements. | 573 // This should now fail with NoIconMatchingRequirements. |
| 574 InstallableParams params = GetWebAppParams(); | 574 InstallableParams params = GetWebAppParams(); |
| 575 params.ideal_icon_size_in_dp = 2000; | 575 params.ideal_icon_size_in_px = 2000; |
| 576 params.minimum_icon_size_in_dp = 2000; | 576 params.minimum_icon_size_in_px = 2000; |
| 577 RunInstallableManager(tester.get(), params); | 577 RunInstallableManager(tester.get(), params); |
| 578 run_loop.Run(); | 578 run_loop.Run(); |
| 579 | 579 |
| 580 EXPECT_FALSE(tester->manifest_url().is_empty()); | 580 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 581 EXPECT_FALSE(tester->manifest().IsEmpty()); | 581 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 582 EXPECT_TRUE(tester->is_installable()); | 582 EXPECT_TRUE(tester->is_installable()); |
| 583 EXPECT_TRUE(tester->icon_url().is_empty()); | 583 EXPECT_TRUE(tester->icon_url().is_empty()); |
| 584 EXPECT_EQ(nullptr, tester->icon()); | 584 EXPECT_EQ(nullptr, tester->icon()); |
| 585 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 585 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| 586 } | 586 } |
| 587 | 587 |
| 588 // Navigate and verify the reverse: an overly large icon requested first | 588 // Navigate and verify the reverse: an overly large icon requested first |
| 589 // fails, but a smaller icon requested second passes. | 589 // fails, but a smaller icon requested second passes. |
| 590 { | 590 { |
| 591 base::RunLoop run_loop; | 591 base::RunLoop run_loop; |
| 592 std::unique_ptr<CallbackTester> tester( | 592 std::unique_ptr<CallbackTester> tester( |
| 593 new CallbackTester(run_loop.QuitClosure())); | 593 new CallbackTester(run_loop.QuitClosure())); |
| 594 | 594 |
| 595 // This should fail with NoIconMatchingRequirements. | 595 // This should fail with NoIconMatchingRequirements. |
| 596 InstallableParams params = GetWebAppParams(); | 596 InstallableParams params = GetWebAppParams(); |
| 597 params.ideal_icon_size_in_dp = 2000; | 597 params.ideal_icon_size_in_px = 2000; |
| 598 params.minimum_icon_size_in_dp = 2000; | 598 params.minimum_icon_size_in_px = 2000; |
| 599 NavigateAndRunInstallableManager(tester.get(), params, | 599 NavigateAndRunInstallableManager(tester.get(), params, |
| 600 "/banners/manifest_test_page.html"); | 600 "/banners/manifest_test_page.html"); |
| 601 run_loop.Run(); | 601 run_loop.Run(); |
| 602 | 602 |
| 603 EXPECT_FALSE(tester->manifest_url().is_empty()); | 603 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 604 EXPECT_FALSE(tester->manifest().IsEmpty()); | 604 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 605 EXPECT_TRUE(tester->is_installable()); | 605 EXPECT_TRUE(tester->is_installable()); |
| 606 EXPECT_TRUE(tester->icon_url().is_empty()); | 606 EXPECT_TRUE(tester->icon_url().is_empty()); |
| 607 EXPECT_EQ(nullptr, tester->icon()); | 607 EXPECT_EQ(nullptr, tester->icon()); |
| 608 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 608 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 630 CheckNestedCallsToGetData) { | 630 CheckNestedCallsToGetData) { |
| 631 // Verify that we can call GetData while in a callback from GetData. | 631 // Verify that we can call GetData while in a callback from GetData. |
| 632 base::RunLoop run_loop; | 632 base::RunLoop run_loop; |
| 633 InstallableParams params = GetWebAppParams(); | 633 InstallableParams params = GetWebAppParams(); |
| 634 std::unique_ptr<NestedCallbackTester> tester( | 634 std::unique_ptr<NestedCallbackTester> tester( |
| 635 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); | 635 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); |
| 636 | 636 |
| 637 tester->Run(); | 637 tester->Run(); |
| 638 run_loop.Run(); | 638 run_loop.Run(); |
| 639 } | 639 } |
| OLD | NEW |