Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_drag_browsertest.cc |
| diff --git a/chrome/browser/ui/panels/panel_drag_browsertest.cc b/chrome/browser/ui/panels/panel_drag_browsertest.cc |
| index 1f255151e6f8bc5df9a2d886d226322f055b1a7f..c30051a590a76dff97dfa4d4d5bd91f9e16750c1 100644 |
| --- a/chrome/browser/ui/panels/panel_drag_browsertest.cc |
| +++ b/chrome/browser/ui/panels/panel_drag_browsertest.cc |
| @@ -10,6 +10,7 @@ |
| #include "chrome/browser/ui/panels/panel.h" |
| #include "chrome/browser/ui/panels/panel_drag_controller.h" |
| #include "chrome/browser/ui/panels/panel_manager.h" |
| +#include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" |
| class PanelDragBrowserTest : public BasePanelBrowserTest { |
| public: |
| @@ -400,6 +401,86 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) { |
| PanelManager::GetInstance()->CloseAll(); |
| } |
| +IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragMinimizedPanel) { |
| + // We'll simulate mouse movements for test. |
| + PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| + PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
| + |
| + Panel* panel = CreatePanel("panel1"); |
| + scoped_ptr<NativePanelTesting> panel_testing( |
| + NativePanelTesting::Create(panel->native_panel())); |
| + |
| + panel->Minimize(); |
| + EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| + |
| + // Hover over minimized panel to bring up titlebar. |
| + gfx::Point hover_point(panel->GetBounds().origin()); |
| + MoveMouseAndWaitForExpansionStateChange(panel, hover_point); |
| + EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| + |
| + // Verify we can drag a minimized panel. |
| + gfx::Rect panel_old_bounds = panel->GetBounds(); |
| + gfx::Point mouse_location = panel_old_bounds.origin(); |
| + panel_testing->PressLeftMouseButtonTitlebar(mouse_location); |
| + EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
| + EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| + |
| + mouse_location.Offset(-70, 0); |
| + panel_testing->DragTitlebar(mouse_location); |
| + gfx::Rect panel_new_bounds = panel_old_bounds; |
| + panel_new_bounds.Offset(-70, 0); |
| + EXPECT_EQ(panel_new_bounds, panel->GetBounds()); |
|
jianli
2012/05/15 22:59:47
Can you also verify that panel is still in title-o
jennb
2012/05/16 00:47:09
Done.
|
| + |
| + // Verify panel returns to fully minimized state after dragging ends. |
| + panel_testing->FinishDragTitlebar(); |
| + MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); |
| + EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
|
jianli
2012/05/15 22:59:47
Can we have a test that we're dragging a title-onl
jennb
2012/05/16 00:47:09
Added check after FinishDragTitlebar() to verify t
|
| + |
| + panel->Close(); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragMinimizedDrawAttentionPanel) { |
|
jianli
2012/05/15 22:59:47
DragMinimizedDrawAttentionPanel => DragMinimizedDr
jennb
2012/05/16 00:47:09
DragMinimizedPanelWhileDrawingAttention
|
| + // We'll simulate mouse movements for test. |
| + PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
| + PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
| + |
| + Panel* panel = CreatePanel("panel1"); |
| + scoped_ptr<NativePanelTesting> panel_testing( |
| + NativePanelTesting::Create(panel->native_panel())); |
| + |
| + panel->Minimize(); |
| + EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| + |
| + panel->FlashFrame(true); |
| + EXPECT_TRUE(panel->IsDrawingAttention()); |
| + EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| + |
| + // Drag the panel. Verify panel stays in title-only state after attention is |
| + // cleared because it is being dragged. |
| + gfx::Rect panel_old_bounds = panel->GetBounds(); |
| + gfx::Point mouse_location = panel_old_bounds.origin(); |
| + panel_testing->PressLeftMouseButtonTitlebar(mouse_location); |
| + EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
| + EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| + |
| + mouse_location.Offset(-70, 0); |
| + panel_testing->DragTitlebar(mouse_location); |
| + gfx::Rect panel_new_bounds = panel_old_bounds; |
| + panel_new_bounds.Offset(-70, 0); |
| + EXPECT_EQ(panel_new_bounds, panel->GetBounds()); |
| + |
| + panel->FlashFrame(false); |
| + EXPECT_FALSE(panel->IsDrawingAttention()); |
| + EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| + |
| + // Verify panel returns to fully minimized state after dragging ends. |
| + panel_testing->FinishDragTitlebar(); |
| + MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); |
| + EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| + |
| + panel->Close(); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDockedPanelOnDrag) { |
| PanelManager* panel_manager = PanelManager::GetInstance(); |
| PanelDragController* drag_controller = panel_manager->drag_controller(); |