OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/download/download_service.h" | 9 #include "chrome/browser/download/download_service.h" |
10 #include "chrome/browser/download/download_service_factory.h" | 10 #include "chrome/browser/download/download_service_factory.h" |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 L"changeSize(-30);")); | 875 L"changeSize(-30);")); |
876 shrink.Wait(); | 876 shrink.Wait(); |
877 gfx::Rect bounds_on_shrink = panel->GetBounds(); | 877 gfx::Rect bounds_on_shrink = panel->GetBounds(); |
878 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); | 878 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); |
879 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); | 879 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); |
880 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); | 880 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); |
881 | 881 |
882 panel->Close(); | 882 panel->Close(); |
883 } | 883 } |
884 | 884 |
| 885 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AnimateBounds) { |
| 886 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
| 887 scoped_ptr<NativePanelTesting> panel_testing( |
| 888 NativePanelTesting::Create(panel->native_panel())); |
| 889 |
| 890 // Set bounds with animation. |
| 891 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160); |
| 892 panel->SetPanelBounds(bounds, true); // use animation. |
| 893 EXPECT_TRUE(panel_testing->IsAnimatingBounds()); |
| 894 WaitForBoundsAnimationFinished(panel); |
| 895 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
| 896 EXPECT_EQ(bounds, panel->GetBounds()); |
| 897 |
| 898 // Set bounds without animation. |
| 899 bounds = gfx::Rect(30, 40, 200, 220); |
| 900 panel->SetPanelBounds(bounds, false); // no animation. |
| 901 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
| 902 EXPECT_EQ(bounds, panel->GetBounds()); |
| 903 |
| 904 panel->Close(); |
| 905 } |
| 906 |
885 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { | 907 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { |
886 // Disable mouse watcher. We don't care about mouse movements in this test. | 908 // Disable mouse watcher. We don't care about mouse movements in this test. |
887 PanelManager* panel_manager = PanelManager::GetInstance(); | 909 PanelManager* panel_manager = PanelManager::GetInstance(); |
888 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 910 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
889 panel_manager->set_mouse_watcher(mouse_watcher); | 911 panel_manager->set_mouse_watcher(mouse_watcher); |
890 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 912 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
891 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 913 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
892 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 914 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
893 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | 915 EXPECT_EQ(0, panel_manager->minimized_panel_count()); |
894 | 916 |
(...skipping 29 matching lines...) Expand all Loading... |
924 | 946 |
925 panel->SetExpansionState(Panel::EXPANDED); | 947 panel->SetExpansionState(Panel::EXPANDED); |
926 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 948 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
927 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | 949 EXPECT_EQ(0, panel_manager->minimized_panel_count()); |
928 | 950 |
929 // Verify that changing the panel bounds only affects restored height | 951 // Verify that changing the panel bounds only affects restored height |
930 // when panel is expanded. | 952 // when panel is expanded. |
931 int saved_restored_height = restored.height(); | 953 int saved_restored_height = restored.height(); |
932 panel->SetExpansionState(Panel::MINIMIZED); | 954 panel->SetExpansionState(Panel::MINIMIZED); |
933 bounds = gfx::Rect(10, 20, 300, 400); | 955 bounds = gfx::Rect(10, 20, 300, 400); |
934 panel->SetPanelBounds(bounds); | 956 panel->SetPanelBounds(bounds, true); // use animation. |
935 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 957 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
936 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | 958 EXPECT_EQ(1, panel_manager->minimized_panel_count()); |
937 | 959 |
938 panel->SetExpansionState(Panel::TITLE_ONLY); | 960 panel->SetExpansionState(Panel::TITLE_ONLY); |
939 bounds = gfx::Rect(20, 30, 100, 200); | 961 bounds = gfx::Rect(20, 30, 100, 200); |
940 panel->SetPanelBounds(bounds); | 962 panel->SetPanelBounds(bounds, true); // use animation. |
941 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 963 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
942 EXPECT_EQ(1, panel_manager->minimized_panel_count()); | 964 EXPECT_EQ(1, panel_manager->minimized_panel_count()); |
943 | 965 |
944 panel->SetExpansionState(Panel::EXPANDED); | 966 panel->SetExpansionState(Panel::EXPANDED); |
945 bounds = gfx::Rect(40, 60, 300, 400); | 967 bounds = gfx::Rect(40, 60, 300, 400); |
946 panel->SetPanelBounds(bounds); | 968 panel->SetPanelBounds(bounds, true); // use animation. |
947 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); | 969 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); |
948 EXPECT_EQ(0, panel_manager->minimized_panel_count()); | 970 EXPECT_EQ(0, panel_manager->minimized_panel_count()); |
949 | 971 |
950 panel->Close(); | 972 panel->Close(); |
951 } | 973 } |
952 | 974 |
953 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { | 975 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { |
954 // We'll simulate mouse movements for test. | 976 // We'll simulate mouse movements for test. |
955 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 977 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
956 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); | 978 PanelManager::GetInstance()->set_mouse_watcher(mouse_watcher); |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 // position when tall panel brings up its titlebar. | 1938 // position when tall panel brings up its titlebar. |
1917 CloseWindowAndWait(panel1->browser()); | 1939 CloseWindowAndWait(panel1->browser()); |
1918 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1940 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
1919 GetBalloonBottomPosition(balloon)); | 1941 GetBalloonBottomPosition(balloon)); |
1920 | 1942 |
1921 // Closing the remaining tall panel should move the notification balloon back | 1943 // Closing the remaining tall panel should move the notification balloon back |
1922 // to its original position. | 1944 // to its original position. |
1923 CloseWindowAndWait(panel2->browser()); | 1945 CloseWindowAndWait(panel2->browser()); |
1924 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1946 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
1925 } | 1947 } |
OLD | NEW |