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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
7 #include "chrome/browser/ui/panels/detached_panel_strip.h" | 7 #include "chrome/browser/ui/panels/detached_panel_strip.h" |
8 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 8 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
9 #include "chrome/browser/ui/panels/native_panel.h" | 9 #include "chrome/browser/ui/panels/native_panel.h" |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
11 #include "chrome/browser/ui/panels/panel_drag_controller.h" | 11 #include "chrome/browser/ui/panels/panel_drag_controller.h" |
12 #include "chrome/browser/ui/panels/panel_manager.h" | 12 #include "chrome/browser/ui/panels/panel_manager.h" |
| 13 #include "chrome/browser/ui/panels/test_panel_strip_squeeze_observer.h" |
| 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/test/test_utils.h" |
13 | 17 |
14 class PanelDragBrowserTest : public BasePanelBrowserTest { | 18 class PanelDragBrowserTest : public BasePanelBrowserTest { |
15 public: | 19 public: |
16 PanelDragBrowserTest() : BasePanelBrowserTest() { | 20 PanelDragBrowserTest() : BasePanelBrowserTest() { |
17 } | 21 } |
18 | 22 |
19 virtual ~PanelDragBrowserTest() { | 23 virtual ~PanelDragBrowserTest() { |
20 } | 24 } |
21 | 25 |
22 virtual void SetUpOnMainThread() OVERRIDE { | 26 virtual void SetUpOnMainThread() OVERRIDE { |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 300, 200, 100)); | 1218 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 300, 200, 100)); |
1215 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 300, 200, 100)); | 1219 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 300, 200, 100)); |
1216 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(400, 300, 200, 100)); | 1220 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(400, 300, 200, 100)); |
1217 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); | 1221 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); |
1218 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); | 1222 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); |
1219 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); | 1223 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); |
1220 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); | 1224 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); |
1221 ASSERT_EQ(3, detached_strip->num_panels()); | 1225 ASSERT_EQ(3, detached_strip->num_panels()); |
1222 ASSERT_EQ(4, docked_strip->num_panels()); | 1226 ASSERT_EQ(4, docked_strip->num_panels()); |
1223 | 1227 |
| 1228 // Wait for active states to settle. |
| 1229 PanelStripSqueezeObserver panel7_settled(docked_strip, panel7); |
| 1230 panel7_settled.Wait(); |
| 1231 |
1224 gfx::Point detached_position1 = panel1->GetBounds().origin(); | 1232 gfx::Point detached_position1 = panel1->GetBounds().origin(); |
1225 gfx::Point detached_position2 = panel2->GetBounds().origin(); | 1233 gfx::Point detached_position2 = panel2->GetBounds().origin(); |
1226 gfx::Point detached_position3 = panel3->GetBounds().origin(); | 1234 gfx::Point detached_position3 = panel3->GetBounds().origin(); |
1227 gfx::Point docked_position4 = panel4->GetBounds().origin(); | 1235 gfx::Point docked_position4 = panel4->GetBounds().origin(); |
1228 gfx::Point docked_position5 = panel5->GetBounds().origin(); | 1236 gfx::Point docked_position5 = panel5->GetBounds().origin(); |
1229 gfx::Point docked_position6 = panel6->GetBounds().origin(); | 1237 gfx::Point docked_position6 = panel6->GetBounds().origin(); |
1230 gfx::Point docked_position7 = panel7->GetBounds().origin(); | 1238 gfx::Point docked_position7 = panel7->GetBounds().origin(); |
1231 | 1239 |
1232 // Drag to attach a detached panel between 2 docked panels. | 1240 // Drag to attach a detached panel between 2 docked panels. |
1233 // Expect to have: | 1241 // Expect to have: |
(...skipping 25 matching lines...) Expand all Loading... |
1259 | 1267 |
1260 #if defined(OS_WIN) | 1268 #if defined(OS_WIN) |
1261 // The panel we dragged becomes the active one. | 1269 // The panel we dragged becomes the active one. |
1262 EXPECT_EQ(true, panel3->IsActive()); | 1270 EXPECT_EQ(true, panel3->IsActive()); |
1263 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); | 1271 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); |
1264 | 1272 |
1265 EXPECT_NE(docked_position6, panel6->GetBounds().origin()); | 1273 EXPECT_NE(docked_position6, panel6->GetBounds().origin()); |
1266 #else | 1274 #else |
1267 // The last panel is active so these positions do not change. | 1275 // The last panel is active so these positions do not change. |
1268 // TODO (ABurago) this is wrong behavior, a panel should activate | 1276 // TODO (ABurago) this is wrong behavior, a panel should activate |
1269 // when it is dragged. Change the test when the behavior is fixed. | 1277 // when it is dragged (it does in real usage, but not when drag is |
| 1278 // simulated in a test). Change this test when the behavior is fixed. |
1270 EXPECT_EQ(true, panel7->IsActive()); | 1279 EXPECT_EQ(true, panel7->IsActive()); |
1271 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); | 1280 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); |
1272 | 1281 |
1273 EXPECT_EQ(docked_position6, panel6->GetBounds().origin()); | 1282 EXPECT_EQ(docked_position6, panel6->GetBounds().origin()); |
1274 #endif | 1283 #endif |
1275 EXPECT_EQ(docked_position7, panel7->GetBounds().origin()); | 1284 EXPECT_EQ(docked_position7, panel7->GetBounds().origin()); |
1276 | 1285 |
1277 // Drag to attach a detached panel to most-right. | 1286 // Drag to attach a detached panel to most-right. |
1278 // Expect to have: | 1287 // Expect to have: |
1279 // detached: P1 | 1288 // detached: P1 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 | 1339 |
1331 // Drag down the panel. Expect that the panel can be dragged without | 1340 // Drag down the panel. Expect that the panel can be dragged without |
1332 // constraint. | 1341 // constraint. |
1333 drag_to_location = gfx::Point(280, 150); | 1342 drag_to_location = gfx::Point(280, 150); |
1334 DragPanelToMouseLocation(panel, drag_to_location); | 1343 DragPanelToMouseLocation(panel, drag_to_location); |
1335 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 1344 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
1336 EXPECT_EQ(drag_to_location, panel->GetBounds().origin()); | 1345 EXPECT_EQ(drag_to_location, panel->GetBounds().origin()); |
1337 | 1346 |
1338 panel_manager->CloseAll(); | 1347 panel_manager->CloseAll(); |
1339 } | 1348 } |
OLD | NEW |