Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: chrome/browser/ui/panels/detached_panel_browsertest.cc

Issue 9616037: Change panel drag related methods to use mouse location in screen coordinates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to reland Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/panels/native_panel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/panels/base_panel_browser_test.h" 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
6 #include "chrome/browser/ui/panels/detached_panel_strip.h" 6 #include "chrome/browser/ui/panels/detached_panel_strip.h"
7 #include "chrome/browser/ui/panels/native_panel.h" 7 #include "chrome/browser/ui/panels/native_panel.h"
8 #include "chrome/browser/ui/panels/panel.h" 8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_drag_controller.h" 9 #include "chrome/browser/ui/panels/panel_drag_controller.h"
10 #include "chrome/browser/ui/panels/panel_manager.h" 10 #include "chrome/browser/ui/panels/panel_manager.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 panel_manager->MovePanelToStrip(panel, PanelStrip::DETACHED); 48 panel_manager->MovePanelToStrip(panel, PanelStrip::DETACHED);
49 49
50 // Test that the detached panel can be dragged anywhere. 50 // Test that the detached panel can be dragged anywhere.
51 scoped_ptr<NativePanelTesting> panel_testing( 51 scoped_ptr<NativePanelTesting> panel_testing(
52 NativePanelTesting::Create(panel->native_panel())); 52 NativePanelTesting::Create(panel->native_panel()));
53 gfx::Point origin = panel->GetBounds().origin(); 53 gfx::Point origin = panel->GetBounds().origin();
54 54
55 panel_testing->PressLeftMouseButtonTitlebar(origin); 55 panel_testing->PressLeftMouseButtonTitlebar(origin);
56 EXPECT_EQ(origin, panel->GetBounds().origin()); 56 EXPECT_EQ(origin, panel->GetBounds().origin());
57 57
58 panel_testing->DragTitlebar(-51, 102); 58 origin.Offset(-51, -102);
59 origin.Offset(-51, 102); 59 panel_testing->DragTitlebar(origin);
60 WaitForBoundsAnimationFinished(panel);
60 EXPECT_EQ(origin, panel->GetBounds().origin()); 61 EXPECT_EQ(origin, panel->GetBounds().origin());
61 62
62 panel_testing->DragTitlebar(37, -42); 63 origin.Offset(37, 45);
63 origin.Offset(37, -42); 64 panel_testing->DragTitlebar(origin);
65 WaitForBoundsAnimationFinished(panel);
64 EXPECT_EQ(origin, panel->GetBounds().origin()); 66 EXPECT_EQ(origin, panel->GetBounds().origin());
65 67
66 panel_testing->FinishDragTitlebar(); 68 panel_testing->FinishDragTitlebar();
67 EXPECT_EQ(origin, panel->GetBounds().origin()); 69 EXPECT_EQ(origin, panel->GetBounds().origin());
68 70
69 // Test that cancelling the drag will return the panel the the original 71 // Test that cancelling the drag will return the panel the the original
70 // position. 72 // position.
71 gfx::Point original_position = panel->GetBounds().origin(); 73 gfx::Point original_position = panel->GetBounds().origin();
72 origin = original_position; 74 origin = original_position;
73 75
74 panel_testing->PressLeftMouseButtonTitlebar(origin); 76 panel_testing->PressLeftMouseButtonTitlebar(origin);
75 EXPECT_EQ(origin, panel->GetBounds().origin()); 77 EXPECT_EQ(origin, panel->GetBounds().origin());
76 78
77 panel_testing->DragTitlebar(-51, 102); 79 origin.Offset(-51, -102);
78 origin.Offset(-51, 102); 80 panel_testing->DragTitlebar(origin);
81 WaitForBoundsAnimationFinished(panel);
79 EXPECT_EQ(origin, panel->GetBounds().origin()); 82 EXPECT_EQ(origin, panel->GetBounds().origin());
80 83
81 panel_testing->DragTitlebar(37, -42); 84 origin.Offset(37, 45);
82 origin.Offset(37, -42); 85 panel_testing->DragTitlebar(origin);
86 WaitForBoundsAnimationFinished(panel);
83 EXPECT_EQ(origin, panel->GetBounds().origin()); 87 EXPECT_EQ(origin, panel->GetBounds().origin());
84 88
85 panel_testing->CancelDragTitlebar(); 89 panel_testing->CancelDragTitlebar();
90 WaitForBoundsAnimationFinished(panel);
86 EXPECT_EQ(original_position, panel->GetBounds().origin()); 91 EXPECT_EQ(original_position, panel->GetBounds().origin());
87 92
88 panel_manager->CloseAll(); 93 panel_manager->CloseAll();
89 } 94 }
90 95
91 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CloseDetachedPanelOnDrag) { 96 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CloseDetachedPanelOnDrag) {
92 PanelManager* panel_manager = PanelManager::GetInstance(); 97 PanelManager* panel_manager = PanelManager::GetInstance();
93 PanelDragController* drag_controller = panel_manager->drag_controller(); 98 PanelDragController* drag_controller = panel_manager->drag_controller();
94 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); 99 DetachedPanelStrip* detached_strip = panel_manager->detached_strip();
95 100
(...skipping 15 matching lines...) Expand all
111 gfx::Point panel3_position = panel3->GetBounds().origin(); 116 gfx::Point panel3_position = panel3->GetBounds().origin();
112 gfx::Point panel4_position = panel4->GetBounds().origin(); 117 gfx::Point panel4_position = panel4->GetBounds().origin();
113 118
114 // Test the scenario: drag a panel, close another panel, cancel the drag. 119 // Test the scenario: drag a panel, close another panel, cancel the drag.
115 { 120 {
116 gfx::Point panel1_new_position = panel1_old_position; 121 gfx::Point panel1_new_position = panel1_old_position;
117 panel1_new_position.Offset(-51, -102); 122 panel1_new_position.Offset(-51, -102);
118 123
119 // Start dragging a panel. 124 // Start dragging a panel.
120 panel1_testing->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin()); 125 panel1_testing->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin());
121 panel1_testing->DragTitlebar(-51, -102); 126 panel1_testing->DragTitlebar(panel1_new_position);
122 EXPECT_TRUE(drag_controller->IsDragging()); 127 EXPECT_TRUE(drag_controller->IsDragging());
123 EXPECT_EQ(panel1, drag_controller->dragging_panel()); 128 EXPECT_EQ(panel1, drag_controller->dragging_panel());
124 129
125 ASSERT_EQ(4, detached_strip->num_panels()); 130 ASSERT_EQ(4, detached_strip->num_panels());
126 EXPECT_TRUE(detached_strip->HasPanel(panel1)); 131 EXPECT_TRUE(detached_strip->HasPanel(panel1));
127 EXPECT_TRUE(detached_strip->HasPanel(panel2)); 132 EXPECT_TRUE(detached_strip->HasPanel(panel2));
128 EXPECT_TRUE(detached_strip->HasPanel(panel3)); 133 EXPECT_TRUE(detached_strip->HasPanel(panel3));
129 EXPECT_TRUE(detached_strip->HasPanel(panel4)); 134 EXPECT_TRUE(detached_strip->HasPanel(panel4));
130 EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin()); 135 EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin());
131 EXPECT_EQ(panel2_position, panel2->GetBounds().origin()); 136 EXPECT_EQ(panel2_position, panel2->GetBounds().origin());
(...skipping 27 matching lines...) Expand all
159 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); 164 EXPECT_EQ(panel4_position, panel4->GetBounds().origin());
160 } 165 }
161 166
162 // Test the scenario: drag a panel, close another panel, end the drag. 167 // Test the scenario: drag a panel, close another panel, end the drag.
163 { 168 {
164 gfx::Point panel1_new_position = panel1_old_position; 169 gfx::Point panel1_new_position = panel1_old_position;
165 panel1_new_position.Offset(-51, -102); 170 panel1_new_position.Offset(-51, -102);
166 171
167 // Start dragging a panel. 172 // Start dragging a panel.
168 panel1_testing->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin()); 173 panel1_testing->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin());
169 panel1_testing->DragTitlebar(-51, -102); 174 panel1_testing->DragTitlebar(panel1_new_position);
170 EXPECT_TRUE(drag_controller->IsDragging()); 175 EXPECT_TRUE(drag_controller->IsDragging());
171 EXPECT_EQ(panel1, drag_controller->dragging_panel()); 176 EXPECT_EQ(panel1, drag_controller->dragging_panel());
172 177
173 ASSERT_EQ(3, detached_strip->num_panels()); 178 ASSERT_EQ(3, detached_strip->num_panels());
174 EXPECT_TRUE(detached_strip->HasPanel(panel1)); 179 EXPECT_TRUE(detached_strip->HasPanel(panel1));
175 EXPECT_TRUE(detached_strip->HasPanel(panel3)); 180 EXPECT_TRUE(detached_strip->HasPanel(panel3));
176 EXPECT_TRUE(detached_strip->HasPanel(panel4)); 181 EXPECT_TRUE(detached_strip->HasPanel(panel4));
177 EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin()); 182 EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin());
178 EXPECT_EQ(panel3_position, panel3->GetBounds().origin()); 183 EXPECT_EQ(panel3_position, panel3->GetBounds().origin());
179 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); 184 EXPECT_EQ(panel4_position, panel4->GetBounds().origin());
(...skipping 21 matching lines...) Expand all
201 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); 206 EXPECT_EQ(panel4_position, panel4->GetBounds().origin());
202 } 207 }
203 208
204 // Test the scenario: drag a panel and close the dragging panel. 209 // Test the scenario: drag a panel and close the dragging panel.
205 { 210 {
206 gfx::Point panel1_new_position = panel1->GetBounds().origin(); 211 gfx::Point panel1_new_position = panel1->GetBounds().origin();
207 panel1_new_position.Offset(-51, -102); 212 panel1_new_position.Offset(-51, -102);
208 213
209 // Start dragging a panel again. 214 // Start dragging a panel again.
210 panel1_testing->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin()); 215 panel1_testing->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin());
211 panel1_testing->DragTitlebar(-51, -102); 216 panel1_testing->DragTitlebar(panel1_new_position);
212 EXPECT_TRUE(drag_controller->IsDragging()); 217 EXPECT_TRUE(drag_controller->IsDragging());
213 EXPECT_EQ(panel1, drag_controller->dragging_panel()); 218 EXPECT_EQ(panel1, drag_controller->dragging_panel());
214 219
215 ASSERT_EQ(2, detached_strip->num_panels()); 220 ASSERT_EQ(2, detached_strip->num_panels());
216 EXPECT_TRUE(detached_strip->HasPanel(panel1)); 221 EXPECT_TRUE(detached_strip->HasPanel(panel1));
217 EXPECT_TRUE(detached_strip->HasPanel(panel4)); 222 EXPECT_TRUE(detached_strip->HasPanel(panel4));
218 EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin()); 223 EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin());
219 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); 224 EXPECT_EQ(panel4_position, panel4->GetBounds().origin());
220 225
221 // Closing the dragging panel should end the drag. 226 // Closing the dragging panel should end the drag.
222 CloseWindowAndWait(panel1->browser()); 227 CloseWindowAndWait(panel1->browser());
223 EXPECT_FALSE(drag_controller->IsDragging()); 228 EXPECT_FALSE(drag_controller->IsDragging());
224 229
225 ASSERT_EQ(1, detached_strip->num_panels()); 230 ASSERT_EQ(1, detached_strip->num_panels());
226 EXPECT_TRUE(detached_strip->HasPanel(panel4)); 231 EXPECT_TRUE(detached_strip->HasPanel(panel4));
227 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); 232 EXPECT_EQ(panel4_position, panel4->GetBounds().origin());
228 } 233 }
229 234
230 panel_manager->CloseAll(); 235 panel_manager->CloseAll();
231 } 236 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/panels/native_panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698