| 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 "chrome/browser/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
| 6 #include "chrome/browser/profiles/profile.h" | 6 #include "chrome/browser/profiles/profile.h" |
| 7 #include "chrome/browser/ui/browser_list.h" | 7 #include "chrome/browser/ui/browser_list.h" |
| 8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 9 #include "chrome/browser/ui/find_bar/find_bar.h" | 9 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 expected_panel_menu_items[4].enabled = true; | 297 expected_panel_menu_items[4].enabled = true; |
| 298 } | 298 } |
| 299 ValidateSettingsMenuItems(settings_menu_model.get(), | 299 ValidateSettingsMenuItems(settings_menu_model.get(), |
| 300 arraysize(expected_panel_menu_items), | 300 arraysize(expected_panel_menu_items), |
| 301 expected_panel_menu_items); | 301 expected_panel_menu_items); |
| 302 | 302 |
| 303 panel->Close(); | 303 panel->Close(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void TestMinimizeRestore() { | 306 void TestMinimizeRestore() { |
| 307 // This constant is used to generate a point 'sufficiently higher then |
| 308 // top edge of the panel'. On some platforms (Mac) we extend hover area |
| 309 // a bit above the minimized panel as well, so it takes significant |
| 310 // distance to 'move mouse out' of the hover-sensitive area. |
| 311 const int kFarEnoughFromHoverArea = 153; |
| 312 |
| 307 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); | 313 std::vector<Panel*> panels = PanelManager::GetInstance()->panels(); |
| 308 std::vector<gfx::Rect> test_begin_bounds = GetAllPanelsBounds(); | 314 std::vector<gfx::Rect> test_begin_bounds = GetAllPanelsBounds(); |
| 309 std::vector<gfx::Rect> expected_bounds = test_begin_bounds; | 315 std::vector<gfx::Rect> expected_bounds = test_begin_bounds; |
| 310 std::vector<Panel::ExpansionState> expected_expansion_states( | 316 std::vector<Panel::ExpansionState> expected_expansion_states( |
| 311 panels.size(), Panel::EXPANDED); | 317 panels.size(), Panel::EXPANDED); |
| 312 std::vector<NativePanelTesting*> native_panels_testing(panels.size()); | 318 std::vector<NativePanelTesting*> native_panels_testing(panels.size()); |
| 313 for (size_t i = 0; i < panels.size(); ++i) { | 319 for (size_t i = 0; i < panels.size(); ++i) { |
| 314 native_panels_testing[i] = | 320 native_panels_testing[i] = |
| 315 NativePanelTesting::Create(panels[i]->native_panel()); | 321 NativePanelTesting::Create(panels[i]->native_panel()); |
| 316 } | 322 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 for (size_t index = 0; index < panels.size(); ++index) { | 364 for (size_t index = 0; index < panels.size(); ++index) { |
| 359 // Hover mouse on minimized panel. | 365 // Hover mouse on minimized panel. |
| 360 // Verify titlebar is exposed on all panels. | 366 // Verify titlebar is exposed on all panels. |
| 361 gfx::Point hover_point(panels[index]->GetRestoredBounds().origin()); | 367 gfx::Point hover_point(panels[index]->GetRestoredBounds().origin()); |
| 362 native_panels_testing[index]->SetMousePositionForMinimizeRestore( | 368 native_panels_testing[index]->SetMousePositionForMinimizeRestore( |
| 363 hover_point); | 369 hover_point); |
| 364 CheckPanelBounds(panels, titlebar_exposed_bounds); | 370 CheckPanelBounds(panels, titlebar_exposed_bounds); |
| 365 CheckExpansionStates(titlebar_exposed_states); | 371 CheckExpansionStates(titlebar_exposed_states); |
| 366 | 372 |
| 367 // Hover mouse above the panel. Verify all panels are minimized. | 373 // Hover mouse above the panel. Verify all panels are minimized. |
| 368 hover_point.set_y(panels[index]->GetRestoredBounds().y() - 10); | 374 hover_point.set_y( |
| 375 panels[index]->GetRestoredBounds().y() - kFarEnoughFromHoverArea); |
| 369 native_panels_testing[index]->SetMousePositionForMinimizeRestore( | 376 native_panels_testing[index]->SetMousePositionForMinimizeRestore( |
| 370 hover_point); | 377 hover_point); |
| 371 CheckPanelBounds(panels, minimized_bounds); | 378 CheckPanelBounds(panels, minimized_bounds); |
| 372 CheckExpansionStates(minimized_states); | 379 CheckExpansionStates(minimized_states); |
| 373 | 380 |
| 374 // Hover mouse below minimized panel. | 381 // Hover mouse below minimized panel. |
| 375 // Verify titlebar is exposed on all panels. | 382 // Verify titlebar is exposed on all panels. |
| 376 hover_point.set_y(panels[index]->GetRestoredBounds().y() + | 383 hover_point.set_y(panels[index]->GetRestoredBounds().y() + |
| 377 panels[index]->GetRestoredBounds().height() + 5); | 384 panels[index]->GetRestoredBounds().height() + 5); |
| 378 native_panels_testing[index]->SetMousePositionForMinimizeRestore( | 385 native_panels_testing[index]->SetMousePositionForMinimizeRestore( |
| 379 hover_point); | 386 hover_point); |
| 380 CheckPanelBounds(panels, titlebar_exposed_bounds); | 387 CheckPanelBounds(panels, titlebar_exposed_bounds); |
| 381 CheckExpansionStates(titlebar_exposed_states); | 388 CheckExpansionStates(titlebar_exposed_states); |
| 382 | 389 |
| 383 // Hover below titlebar exposed panel. Verify nothing changed. | 390 // Hover below titlebar exposed panel. Verify nothing changed. |
| 384 hover_point.set_y(panels[index]->GetRestoredBounds().y() + | 391 hover_point.set_y(panels[index]->GetRestoredBounds().y() + |
| 385 panels[index]->GetRestoredBounds().height() + 6); | 392 panels[index]->GetRestoredBounds().height() + 6); |
| 386 native_panels_testing[index]->SetMousePositionForMinimizeRestore( | 393 native_panels_testing[index]->SetMousePositionForMinimizeRestore( |
| 387 hover_point); | 394 hover_point); |
| 388 CheckPanelBounds(panels, titlebar_exposed_bounds); | 395 CheckPanelBounds(panels, titlebar_exposed_bounds); |
| 389 CheckExpansionStates(titlebar_exposed_states); | 396 CheckExpansionStates(titlebar_exposed_states); |
| 390 | 397 |
| 391 // Hover mouse above panel. Verify all panels are minimized. | 398 // Hover mouse above panel. Verify all panels are minimized. |
| 392 hover_point.set_y(panels[index]->GetRestoredBounds().y() - 10); | 399 hover_point.set_y( |
| 400 panels[index]->GetRestoredBounds().y() - kFarEnoughFromHoverArea); |
| 393 native_panels_testing[index]->SetMousePositionForMinimizeRestore( | 401 native_panels_testing[index]->SetMousePositionForMinimizeRestore( |
| 394 hover_point); | 402 hover_point); |
| 395 CheckPanelBounds(panels, minimized_bounds); | 403 CheckPanelBounds(panels, minimized_bounds); |
| 396 CheckExpansionStates(minimized_states); | 404 CheckExpansionStates(minimized_states); |
| 397 } | 405 } |
| 398 | 406 |
| 399 // Test restore. All panels are currently in minimized state. | 407 // Test restore. All panels are currently in minimized state. |
| 400 for (size_t index = 0; index < panels.size(); ++index) { | 408 for (size_t index = 0; index < panels.size(); ++index) { |
| 401 // Hover on the last panel. This is to test the case of clicking on the | 409 // Hover on the last panel. This is to test the case of clicking on the |
| 402 // panel when it's in titlebar exposed state. | 410 // panel when it's in titlebar exposed state. |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 815 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 808 MessageLoop::current()->RunAllPending(); | 816 MessageLoop::current()->RunAllPending(); |
| 809 } | 817 } |
| 810 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); | 818 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); |
| 811 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); | 819 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); |
| 812 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); | 820 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); |
| 813 | 821 |
| 814 panel->Close(); | 822 panel->Close(); |
| 815 } | 823 } |
| 816 | 824 |
| 817 #if defined(TOOLKIT_GTK) | 825 #if defined(TOOLKIT_GTK) || defined(OS_MACOSX) |
| 818 #define MAYBE_MinimizeRestore MinimizeRestore | 826 #define MAYBE_MinimizeRestore MinimizeRestore |
| 819 #else | 827 #else |
| 820 #define MAYBE_MinimizeRestore DISABLED_MinimizeRestore | 828 #define MAYBE_MinimizeRestore DISABLED_MinimizeRestore |
| 821 #endif | 829 #endif |
| 822 | 830 |
| 823 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_MinimizeRestore) { | 831 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_MinimizeRestore) { |
| 824 // Disable mouse watcher. We'll simulate mouse movements for test. | 832 // Disable mouse watcher. We'll simulate mouse movements for test. |
| 825 NativePanelTesting::GetPanelMouseWatcherInstance()->EnableTestingMode(); | 833 NativePanelTesting::GetPanelMouseWatcherInstance()->EnableTestingMode(); |
| 826 | 834 |
| 827 // Test with one panel. | 835 // Test with one panel. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 EXPECT_EQ(1, tabbed_browser->tab_count()); | 1004 EXPECT_EQ(1, tabbed_browser->tab_count()); |
| 997 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); | 1005 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); |
| 998 tabbed_browser->CloseWindow(); | 1006 tabbed_browser->CloseWindow(); |
| 999 #endif | 1007 #endif |
| 1000 | 1008 |
| 1001 EXPECT_EQ(1, panel_browser->tab_count()); | 1009 EXPECT_EQ(1, panel_browser->tab_count()); |
| 1002 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 1010 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
| 1003 | 1011 |
| 1004 panel_browser->CloseWindow(); | 1012 panel_browser->CloseWindow(); |
| 1005 } | 1013 } |
| OLD | NEW |