OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 #if defined(OS_LINUX) && !defined(USE_ASH) | 639 #if defined(OS_LINUX) && !defined(USE_ASH) |
640 #define MAYBE_ShellWindowRestoreState DISABLED_ShellWindowRestoreState | 640 #define MAYBE_ShellWindowRestoreState DISABLED_ShellWindowRestoreState |
641 #else | 641 #else |
642 #define MAYBE_ShellWindowRestoreState ShellWindowRestoreState | 642 #define MAYBE_ShellWindowRestoreState ShellWindowRestoreState |
643 #endif | 643 #endif |
644 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, | 644 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
645 MAYBE_ShellWindowRestoreState) { | 645 MAYBE_ShellWindowRestoreState) { |
646 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restore_state")); | 646 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restore_state")); |
647 } | 647 } |
648 | 648 |
| 649 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, |
| 650 ShellWindowAdjustBoundsToBeVisibleOnScreen) { |
| 651 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); |
| 652 ShellWindow* window = CreateShellWindow(extension); |
| 653 |
| 654 // The screen bounds didn't change, the cached bounds didn't need to adjust. |
| 655 gfx::Rect cached_bounds(80, 100, 400, 400); |
| 656 gfx::Rect cached_screen_bounds(0, 0, 1600, 900); |
| 657 gfx::Rect current_screen_bounds(0, 0, 1600, 900); |
| 658 gfx::Size minimum_size(200, 200); |
| 659 gfx::Rect bounds; |
| 660 CallAdjustBoundsToBeVisibleOnScreenForShellWinow(window, |
| 661 cached_bounds, |
| 662 cached_screen_bounds, |
| 663 current_screen_bounds, |
| 664 minimum_size, |
| 665 &bounds); |
| 666 EXPECT_EQ(bounds, cached_bounds); |
| 667 |
| 668 // We have an empty screen bounds, the cached bounds didn't need to adjust. |
| 669 gfx::Rect empty_screen_bounds; |
| 670 CallAdjustBoundsToBeVisibleOnScreenForShellWinow(window, |
| 671 cached_bounds, |
| 672 empty_screen_bounds, |
| 673 current_screen_bounds, |
| 674 minimum_size, |
| 675 &bounds); |
| 676 EXPECT_EQ(bounds, cached_bounds); |
| 677 |
| 678 // Cached bounds is completely off the new screen bounds in horizontal |
| 679 // locations. Expect to reposition the bounds. |
| 680 gfx::Rect horizontal_out_of_screen_bounds(-800, 100, 400, 400); |
| 681 CallAdjustBoundsToBeVisibleOnScreenForShellWinow( |
| 682 window, |
| 683 horizontal_out_of_screen_bounds, |
| 684 gfx::Rect(-1366, 0, 1600, 900), |
| 685 current_screen_bounds, |
| 686 minimum_size, |
| 687 &bounds); |
| 688 EXPECT_EQ(bounds, gfx::Rect(0, 100, 400, 400)); |
| 689 |
| 690 // Cached bounds is completely off the new screen bounds in vertical |
| 691 // locations. Expect to reposition the bounds. |
| 692 gfx::Rect vertical_out_of_screen_bounds(10, 1000, 400, 400); |
| 693 CallAdjustBoundsToBeVisibleOnScreenForShellWinow( |
| 694 window, |
| 695 vertical_out_of_screen_bounds, |
| 696 gfx::Rect(-1366, 0, 1600, 900), |
| 697 current_screen_bounds, |
| 698 minimum_size, |
| 699 &bounds); |
| 700 EXPECT_EQ(bounds, gfx::Rect(10, 500, 400, 400)); |
| 701 |
| 702 // From a large screen resulotion to a small one. Expect it fit on screen. |
| 703 gfx::Rect big_cache_bounds(10, 10, 1000, 1000); |
| 704 CallAdjustBoundsToBeVisibleOnScreenForShellWinow( |
| 705 window, |
| 706 big_cache_bounds, |
| 707 gfx::Rect(0, 0, 1600, 1000), |
| 708 gfx::Rect(0, 0, 800, 600), |
| 709 minimum_size, |
| 710 &bounds); |
| 711 EXPECT_EQ(bounds, gfx::Rect(0, 0, 800, 600)); |
| 712 |
| 713 // Don't resize the bounds smaller than minimum size, when the minimum size is |
| 714 // larger than the screen. |
| 715 CallAdjustBoundsToBeVisibleOnScreenForShellWinow( |
| 716 window, |
| 717 big_cache_bounds, |
| 718 gfx::Rect(0, 0, 1600, 1000), |
| 719 gfx::Rect(0, 0, 800, 600), |
| 720 gfx::Size(900, 900), |
| 721 &bounds); |
| 722 EXPECT_EQ(bounds, gfx::Rect(0, 0, 900, 900)); |
| 723 } |
| 724 |
649 namespace { | 725 namespace { |
650 | 726 |
651 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { | 727 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { |
652 protected: | 728 protected: |
653 enum TestFlags { | 729 enum TestFlags { |
654 RELAUNCH = 0x1, | 730 RELAUNCH = 0x1, |
655 HAS_ID = 0x2, | 731 HAS_ID = 0x2, |
656 }; | 732 }; |
657 // Runs a test inside a harness that opens DevTools on a shell window. | 733 // Runs a test inside a harness that opens DevTools on a shell window. |
658 void RunTestWithDevTools(const char* name, int test_flags); | 734 void RunTestWithDevTools(const char* name, int test_flags); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1076 |
1001 while (!ContainsKey(opener_app_ids_, file_manager->id())) { | 1077 while (!ContainsKey(opener_app_ids_, file_manager->id())) { |
1002 content::RunAllPendingInMessageLoop(); | 1078 content::RunAllPendingInMessageLoop(); |
1003 } | 1079 } |
1004 } | 1080 } |
1005 | 1081 |
1006 #endif // defined(OS_CHROMEOS) | 1082 #endif // defined(OS_CHROMEOS) |
1007 | 1083 |
1008 | 1084 |
1009 } // namespace extensions | 1085 } // namespace extensions |
OLD | NEW |