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/old_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_mouse_watcher.h" | 13 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" |
14 | 14 |
15 class PanelDragBrowserTest : public BasePanelBrowserTest { | 15 class OldPanelDragBrowserTest : public OldBasePanelBrowserTest { |
16 public: | 16 public: |
17 PanelDragBrowserTest() : BasePanelBrowserTest() { | 17 OldPanelDragBrowserTest() : OldBasePanelBrowserTest() { |
18 } | 18 } |
19 | 19 |
20 virtual ~PanelDragBrowserTest() { | 20 virtual ~OldPanelDragBrowserTest() { |
21 } | 21 } |
22 | 22 |
23 virtual void SetUpOnMainThread() OVERRIDE { | 23 virtual void SetUpOnMainThread() OVERRIDE { |
24 BasePanelBrowserTest::SetUpOnMainThread(); | 24 OldBasePanelBrowserTest::SetUpOnMainThread(); |
25 | 25 |
26 // All the tests here assume using mocked 800x600 screen area for the | 26 // All the tests here assume using mocked 800x600 screen area for the |
27 // primary monitor. Do the check now. | 27 // primary monitor. Do the check now. |
28 gfx::Rect primary_screen_area = PanelManager::GetInstance()-> | 28 gfx::Rect primary_screen_area = PanelManager::GetInstance()-> |
29 display_settings_provider()->GetPrimaryScreenArea(); | 29 display_settings_provider()->GetPrimaryScreenArea(); |
30 DCHECK(primary_screen_area.width() == 800); | 30 DCHECK(primary_screen_area.width() == 800); |
31 DCHECK(primary_screen_area.height() == 600); | 31 DCHECK(primary_screen_area.height() == 600); |
32 } | 32 } |
33 | 33 |
34 // Drag |panel| from its origin by the offset |delta|. | 34 // Drag |panel| from its origin by the offset |delta|. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 static gfx::Point GetDragDeltaToAttach(Panel* panel) { | 75 static gfx::Point GetDragDeltaToAttach(Panel* panel) { |
76 int distance = panel->manager()->docked_strip()->display_area().bottom() - | 76 int distance = panel->manager()->docked_strip()->display_area().bottom() - |
77 panel->GetBounds().bottom(); | 77 panel->GetBounds().bottom(); |
78 return gfx::Point( | 78 return gfx::Point( |
79 -20, | 79 -20, |
80 distance - PanelDragController::GetDockDetachedPanelThreshold() / 2); | 80 distance - PanelDragController::GetDockDetachedPanelThreshold() / 2); |
81 } | 81 } |
82 }; | 82 }; |
83 | 83 |
84 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragOneDockedPanel) { | 84 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DragOneDockedPanel) { |
85 static const int big_delta_x = 70; | 85 static const int big_delta_x = 70; |
86 static const int big_delta_y = 30; // Do not exceed the threshold to detach. | 86 static const int big_delta_y = 30; // Do not exceed the threshold to detach. |
87 | 87 |
88 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); | 88 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); |
89 scoped_ptr<NativePanelTesting> panel_testing( | 89 scoped_ptr<NativePanelTesting> panel_testing( |
90 NativePanelTesting::Create(panel->native_panel())); | 90 NativePanelTesting::Create(panel->native_panel())); |
91 gfx::Rect panel_old_bounds = panel->GetBounds(); | 91 gfx::Rect panel_old_bounds = panel->GetBounds(); |
92 | 92 |
93 // Drag left. | 93 // Drag left. |
94 gfx::Point mouse_location = panel_old_bounds.origin(); | 94 gfx::Point mouse_location = panel_old_bounds.origin(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 mouse_location.Offset(0, big_delta_y); | 166 mouse_location.Offset(0, big_delta_y); |
167 panel_testing->DragTitlebar(mouse_location); | 167 panel_testing->DragTitlebar(mouse_location); |
168 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | 168 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
169 | 169 |
170 panel_testing->FinishDragTitlebar(); | 170 panel_testing->FinishDragTitlebar(); |
171 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | 171 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
172 | 172 |
173 PanelManager::GetInstance()->CloseAll(); | 173 PanelManager::GetInstance()->CloseAll(); |
174 } | 174 } |
175 | 175 |
176 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragTwoDockedPanels) { | 176 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DragTwoDockedPanels) { |
177 static const gfx::Point small_delta(10, 0); | 177 static const gfx::Point small_delta(10, 0); |
178 | 178 |
179 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); | 179 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); |
180 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 100, 100)); | 180 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 100, 100)); |
181 scoped_ptr<NativePanelTesting> panel1_testing( | 181 scoped_ptr<NativePanelTesting> panel1_testing( |
182 NativePanelTesting::Create(panel1->native_panel())); | 182 NativePanelTesting::Create(panel1->native_panel())); |
183 scoped_ptr<NativePanelTesting> panel2_testing( | 183 scoped_ptr<NativePanelTesting> panel2_testing( |
184 NativePanelTesting::Create(panel2->native_panel())); | 184 NativePanelTesting::Create(panel2->native_panel())); |
185 gfx::Point position1 = panel1->GetBounds().origin(); | 185 gfx::Point position1 = panel1->GetBounds().origin(); |
186 gfx::Point position2 = panel2->GetBounds().origin(); | 186 gfx::Point position2 = panel2->GetBounds().origin(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 EXPECT_EQ(mouse_location, panel1->GetBounds().origin()); | 262 EXPECT_EQ(mouse_location, panel1->GetBounds().origin()); |
263 EXPECT_EQ(position1, panel2->GetBounds().origin()); | 263 EXPECT_EQ(position1, panel2->GetBounds().origin()); |
264 | 264 |
265 panel1_testing->CancelDragTitlebar(); | 265 panel1_testing->CancelDragTitlebar(); |
266 EXPECT_EQ(position1, panel1->GetBounds().origin()); | 266 EXPECT_EQ(position1, panel1->GetBounds().origin()); |
267 EXPECT_EQ(position2, panel2->GetBounds().origin()); | 267 EXPECT_EQ(position2, panel2->GetBounds().origin()); |
268 | 268 |
269 PanelManager::GetInstance()->CloseAll(); | 269 PanelManager::GetInstance()->CloseAll(); |
270 } | 270 } |
271 | 271 |
272 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragThreeDockedPanels) { | 272 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DragThreeDockedPanels) { |
273 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); | 273 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); |
274 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 100, 100)); | 274 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 100, 100)); |
275 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 100, 100)); | 275 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 100, 100)); |
276 scoped_ptr<NativePanelTesting> panel2_testing( | 276 scoped_ptr<NativePanelTesting> panel2_testing( |
277 NativePanelTesting::Create(panel2->native_panel())); | 277 NativePanelTesting::Create(panel2->native_panel())); |
278 scoped_ptr<NativePanelTesting> panel3_testing( | 278 scoped_ptr<NativePanelTesting> panel3_testing( |
279 NativePanelTesting::Create(panel3->native_panel())); | 279 NativePanelTesting::Create(panel3->native_panel())); |
280 gfx::Point position1 = panel1->GetBounds().origin(); | 280 gfx::Point position1 = panel1->GetBounds().origin(); |
281 gfx::Point position2 = panel2->GetBounds().origin(); | 281 gfx::Point position2 = panel2->GetBounds().origin(); |
282 gfx::Point position3 = panel3->GetBounds().origin(); | 282 gfx::Point position3 = panel3->GetBounds().origin(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 EXPECT_EQ(mouse_location, panel3->GetBounds().origin()); | 395 EXPECT_EQ(mouse_location, panel3->GetBounds().origin()); |
396 | 396 |
397 panel3_testing->CancelDragTitlebar(); | 397 panel3_testing->CancelDragTitlebar(); |
398 EXPECT_EQ(position2, panel1->GetBounds().origin()); | 398 EXPECT_EQ(position2, panel1->GetBounds().origin()); |
399 EXPECT_EQ(position3, panel2->GetBounds().origin()); | 399 EXPECT_EQ(position3, panel2->GetBounds().origin()); |
400 EXPECT_EQ(position1, panel3->GetBounds().origin()); | 400 EXPECT_EQ(position1, panel3->GetBounds().origin()); |
401 | 401 |
402 PanelManager::GetInstance()->CloseAll(); | 402 PanelManager::GetInstance()->CloseAll(); |
403 } | 403 } |
404 | 404 |
405 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragMinimizedPanel) { | 405 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DragMinimizedPanel) { |
406 // We'll simulate mouse movements for test. | 406 // We'll simulate mouse movements for test. |
407 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 407 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
408 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 408 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
409 | 409 |
410 Panel* panel = CreatePanel("panel1"); | 410 Panel* panel = CreatePanel("panel1"); |
411 scoped_ptr<NativePanelTesting> panel_testing( | 411 scoped_ptr<NativePanelTesting> panel_testing( |
412 NativePanelTesting::Create(panel->native_panel())); | 412 NativePanelTesting::Create(panel->native_panel())); |
413 | 413 |
414 panel->Minimize(); | 414 panel->Minimize(); |
415 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 415 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
(...skipping 21 matching lines...) Expand all Loading... |
437 // mouse moves away from panel. | 437 // mouse moves away from panel. |
438 panel_testing->FinishDragTitlebar(); | 438 panel_testing->FinishDragTitlebar(); |
439 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 439 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
440 | 440 |
441 MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); | 441 MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); |
442 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 442 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
443 | 443 |
444 panel->Close(); | 444 panel->Close(); |
445 } | 445 } |
446 | 446 |
447 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, | 447 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, |
448 DragMinimizedPanelWhileDrawingAttention) { | 448 DragMinimizedPanelWhileDrawingAttention) { |
449 // We'll simulate mouse movements for test. | 449 // We'll simulate mouse movements for test. |
450 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 450 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
451 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 451 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
452 | 452 |
453 Panel* panel = CreatePanel("panel1"); | 453 Panel* panel = CreatePanel("panel1"); |
454 scoped_ptr<NativePanelTesting> panel_testing( | 454 scoped_ptr<NativePanelTesting> panel_testing( |
455 NativePanelTesting::Create(panel->native_panel())); | 455 NativePanelTesting::Create(panel->native_panel())); |
456 CreatePanel("panel2"); | 456 CreatePanel("panel2"); |
457 | 457 |
(...skipping 27 matching lines...) Expand all Loading... |
485 panel_testing->FinishDragTitlebar(); | 485 panel_testing->FinishDragTitlebar(); |
486 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 486 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
487 | 487 |
488 mouse_location.Offset(0, -50); | 488 mouse_location.Offset(0, -50); |
489 MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); | 489 MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); |
490 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 490 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
491 | 491 |
492 PanelManager::GetInstance()->CloseAll(); | 492 PanelManager::GetInstance()->CloseAll(); |
493 } | 493 } |
494 | 494 |
495 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDockedPanelOnDrag) { | 495 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, CloseDockedPanelOnDrag) { |
496 PanelManager* panel_manager = PanelManager::GetInstance(); | 496 PanelManager* panel_manager = PanelManager::GetInstance(); |
497 PanelDragController* drag_controller = panel_manager->drag_controller(); | 497 PanelDragController* drag_controller = panel_manager->drag_controller(); |
498 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 498 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
499 | 499 |
500 // Create 4 docked panels. | 500 // Create 4 docked panels. |
501 // We have: P4 P3 P2 P1 | 501 // We have: P4 P3 P2 P1 |
502 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 100, 100)); | 502 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 100, 100)); |
503 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 100, 100)); | 503 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 100, 100)); |
504 Panel* panel3 = CreatePanelWithBounds("Panel3", gfx::Rect(0, 0, 100, 100)); | 504 Panel* panel3 = CreatePanelWithBounds("Panel3", gfx::Rect(0, 0, 100, 100)); |
505 Panel* panel4 = CreatePanelWithBounds("Panel4", gfx::Rect(0, 0, 100, 100)); | 505 Panel* panel4 = CreatePanelWithBounds("Panel4", gfx::Rect(0, 0, 100, 100)); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 649 |
650 ASSERT_EQ(1, docked_strip->num_panels()); | 650 ASSERT_EQ(1, docked_strip->num_panels()); |
651 panels = PanelManager::GetInstance()->panels(); | 651 panels = PanelManager::GetInstance()->panels(); |
652 EXPECT_EQ(panel4, panels[0]); | 652 EXPECT_EQ(panel4, panels[0]); |
653 EXPECT_EQ(position1, panel4->GetBounds().origin()); | 653 EXPECT_EQ(position1, panel4->GetBounds().origin()); |
654 } | 654 } |
655 | 655 |
656 panel_manager->CloseAll(); | 656 panel_manager->CloseAll(); |
657 } | 657 } |
658 | 658 |
659 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragOneDetachedPanel) { | 659 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DragOneDetachedPanel) { |
660 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 660 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
661 | 661 |
662 // Test that the detached panel can be dragged almost anywhere except getting | 662 // Test that the detached panel can be dragged almost anywhere except getting |
663 // close to the bottom of the docked area to trigger the attach. | 663 // close to the bottom of the docked area to trigger the attach. |
664 scoped_ptr<NativePanelTesting> panel_testing( | 664 scoped_ptr<NativePanelTesting> panel_testing( |
665 NativePanelTesting::Create(panel->native_panel())); | 665 NativePanelTesting::Create(panel->native_panel())); |
666 gfx::Point origin = panel->GetBounds().origin(); | 666 gfx::Point origin = panel->GetBounds().origin(); |
667 | 667 |
668 panel_testing->PressLeftMouseButtonTitlebar(origin); | 668 panel_testing->PressLeftMouseButtonTitlebar(origin); |
669 EXPECT_EQ(origin, panel->GetBounds().origin()); | 669 EXPECT_EQ(origin, panel->GetBounds().origin()); |
(...skipping 25 matching lines...) Expand all Loading... |
695 panel_testing->DragTitlebar(origin); | 695 panel_testing->DragTitlebar(origin); |
696 EXPECT_EQ(origin, panel->GetBounds().origin()); | 696 EXPECT_EQ(origin, panel->GetBounds().origin()); |
697 | 697 |
698 panel_testing->CancelDragTitlebar(); | 698 panel_testing->CancelDragTitlebar(); |
699 WaitForBoundsAnimationFinished(panel); | 699 WaitForBoundsAnimationFinished(panel); |
700 EXPECT_EQ(original_position, panel->GetBounds().origin()); | 700 EXPECT_EQ(original_position, panel->GetBounds().origin()); |
701 | 701 |
702 PanelManager::GetInstance()->CloseAll(); | 702 PanelManager::GetInstance()->CloseAll(); |
703 } | 703 } |
704 | 704 |
705 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDetachedPanelOnDrag) { | 705 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, CloseDetachedPanelOnDrag) { |
706 PanelManager* panel_manager = PanelManager::GetInstance(); | 706 PanelManager* panel_manager = PanelManager::GetInstance(); |
707 PanelDragController* drag_controller = panel_manager->drag_controller(); | 707 PanelDragController* drag_controller = panel_manager->drag_controller(); |
708 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 708 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
709 | 709 |
710 // Create 4 detached panels. | 710 // Create 4 detached panels. |
711 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 200, 100, 100)); | 711 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 200, 100, 100)); |
712 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 210, 110, 110)); | 712 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 210, 110, 110)); |
713 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); | 713 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); |
714 Panel* panel4 = CreateDetachedPanel("4", gfx::Rect(400, 230, 130, 130)); | 714 Panel* panel4 = CreateDetachedPanel("4", gfx::Rect(400, 230, 130, 130)); |
715 ASSERT_EQ(4, detached_strip->num_panels()); | 715 ASSERT_EQ(4, detached_strip->num_panels()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 EXPECT_FALSE(drag_controller->IsDragging()); | 834 EXPECT_FALSE(drag_controller->IsDragging()); |
835 | 835 |
836 ASSERT_EQ(1, detached_strip->num_panels()); | 836 ASSERT_EQ(1, detached_strip->num_panels()); |
837 EXPECT_TRUE(detached_strip->HasPanel(panel4)); | 837 EXPECT_TRUE(detached_strip->HasPanel(panel4)); |
838 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); | 838 EXPECT_EQ(panel4_position, panel4->GetBounds().origin()); |
839 } | 839 } |
840 | 840 |
841 panel_manager->CloseAll(); | 841 panel_manager->CloseAll(); |
842 } | 842 } |
843 | 843 |
844 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, Detach) { | 844 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, Detach) { |
845 PanelManager* panel_manager = PanelManager::GetInstance(); | 845 PanelManager* panel_manager = PanelManager::GetInstance(); |
846 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 846 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
847 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 847 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
848 | 848 |
849 // Create one docked panel. | 849 // Create one docked panel. |
850 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); | 850 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); |
851 ASSERT_EQ(1, docked_strip->num_panels()); | 851 ASSERT_EQ(1, docked_strip->num_panels()); |
852 ASSERT_EQ(0, detached_strip->num_panels()); | 852 ASSERT_EQ(0, detached_strip->num_panels()); |
853 | 853 |
854 gfx::Rect panel_old_bounds = panel->GetBounds(); | 854 gfx::Rect panel_old_bounds = panel->GetBounds(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 // Expect that the panel stays as detached. | 889 // Expect that the panel stays as detached. |
890 panel_testing->FinishDragTitlebar(); | 890 panel_testing->FinishDragTitlebar(); |
891 ASSERT_EQ(0, docked_strip->num_panels()); | 891 ASSERT_EQ(0, docked_strip->num_panels()); |
892 ASSERT_EQ(1, detached_strip->num_panels()); | 892 ASSERT_EQ(1, detached_strip->num_panels()); |
893 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 893 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
894 EXPECT_EQ(panel_new_bounds, panel->GetBounds()); | 894 EXPECT_EQ(panel_new_bounds, panel->GetBounds()); |
895 | 895 |
896 panel_manager->CloseAll(); | 896 panel_manager->CloseAll(); |
897 } | 897 } |
898 | 898 |
899 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAndCancel) { | 899 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DetachAndCancel) { |
900 PanelManager* panel_manager = PanelManager::GetInstance(); | 900 PanelManager* panel_manager = PanelManager::GetInstance(); |
901 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 901 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
902 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 902 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
903 | 903 |
904 // Create one docked panel. | 904 // Create one docked panel. |
905 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); | 905 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); |
906 ASSERT_EQ(1, docked_strip->num_panels()); | 906 ASSERT_EQ(1, docked_strip->num_panels()); |
907 ASSERT_EQ(0, detached_strip->num_panels()); | 907 ASSERT_EQ(0, detached_strip->num_panels()); |
908 | 908 |
909 gfx::Rect panel_old_bounds = panel->GetBounds(); | 909 gfx::Rect panel_old_bounds = panel->GetBounds(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 // Expect that the panel is back as docked. | 944 // Expect that the panel is back as docked. |
945 panel_testing->CancelDragTitlebar(); | 945 panel_testing->CancelDragTitlebar(); |
946 ASSERT_EQ(1, docked_strip->num_panels()); | 946 ASSERT_EQ(1, docked_strip->num_panels()); |
947 ASSERT_EQ(0, detached_strip->num_panels()); | 947 ASSERT_EQ(0, detached_strip->num_panels()); |
948 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); | 948 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); |
949 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | 949 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
950 | 950 |
951 panel_manager->CloseAll(); | 951 panel_manager->CloseAll(); |
952 } | 952 } |
953 | 953 |
954 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, Attach) { | 954 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, Attach) { |
955 PanelManager* panel_manager = PanelManager::GetInstance(); | 955 PanelManager* panel_manager = PanelManager::GetInstance(); |
956 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 956 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
957 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 957 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
958 | 958 |
959 // Create one detached panel. | 959 // Create one detached panel. |
960 Panel* panel = CreateDetachedPanel("1", gfx::Rect(400, 300, 100, 100)); | 960 Panel* panel = CreateDetachedPanel("1", gfx::Rect(400, 300, 100, 100)); |
961 ASSERT_EQ(0, docked_strip->num_panels()); | 961 ASSERT_EQ(0, docked_strip->num_panels()); |
962 ASSERT_EQ(1, detached_strip->num_panels()); | 962 ASSERT_EQ(1, detached_strip->num_panels()); |
963 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 963 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
964 | 964 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); | 1003 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); |
1004 panel_new_bounds.set_x( | 1004 panel_new_bounds.set_x( |
1005 docked_strip->StartingRightPosition() - panel_new_bounds.width()); | 1005 docked_strip->StartingRightPosition() - panel_new_bounds.width()); |
1006 panel_new_bounds.set_y( | 1006 panel_new_bounds.set_y( |
1007 docked_strip->display_area().bottom() - panel_new_bounds.height()); | 1007 docked_strip->display_area().bottom() - panel_new_bounds.height()); |
1008 EXPECT_EQ(panel_new_bounds, panel->GetBounds()); | 1008 EXPECT_EQ(panel_new_bounds, panel->GetBounds()); |
1009 | 1009 |
1010 panel_manager->CloseAll(); | 1010 panel_manager->CloseAll(); |
1011 } | 1011 } |
1012 | 1012 |
1013 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, AttachAndCancel) { | 1013 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, AttachAndCancel) { |
1014 PanelManager* panel_manager = PanelManager::GetInstance(); | 1014 PanelManager* panel_manager = PanelManager::GetInstance(); |
1015 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 1015 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
1016 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 1016 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
1017 | 1017 |
1018 // Create one detached panel. | 1018 // Create one detached panel. |
1019 Panel* panel = CreateDetachedPanel("1", gfx::Rect(400, 300, 100, 100)); | 1019 Panel* panel = CreateDetachedPanel("1", gfx::Rect(400, 300, 100, 100)); |
1020 ASSERT_EQ(0, docked_strip->num_panels()); | 1020 ASSERT_EQ(0, docked_strip->num_panels()); |
1021 ASSERT_EQ(1, detached_strip->num_panels()); | 1021 ASSERT_EQ(1, detached_strip->num_panels()); |
1022 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 1022 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
1023 | 1023 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // Expect that the panel is back as detached. | 1058 // Expect that the panel is back as detached. |
1059 panel_testing->CancelDragTitlebar(); | 1059 panel_testing->CancelDragTitlebar(); |
1060 ASSERT_EQ(0, docked_strip->num_panels()); | 1060 ASSERT_EQ(0, docked_strip->num_panels()); |
1061 ASSERT_EQ(1, detached_strip->num_panels()); | 1061 ASSERT_EQ(1, detached_strip->num_panels()); |
1062 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 1062 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
1063 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | 1063 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
1064 | 1064 |
1065 panel_manager->CloseAll(); | 1065 panel_manager->CloseAll(); |
1066 } | 1066 } |
1067 | 1067 |
1068 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachAttachAndCancel) { | 1068 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DetachAttachAndCancel) { |
1069 PanelManager* panel_manager = PanelManager::GetInstance(); | 1069 PanelManager* panel_manager = PanelManager::GetInstance(); |
1070 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 1070 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
1071 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 1071 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
1072 | 1072 |
1073 // Create one docked panel. | 1073 // Create one docked panel. |
1074 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); | 1074 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 100, 100)); |
1075 ASSERT_EQ(1, docked_strip->num_panels()); | 1075 ASSERT_EQ(1, docked_strip->num_panels()); |
1076 ASSERT_EQ(0, detached_strip->num_panels()); | 1076 ASSERT_EQ(0, detached_strip->num_panels()); |
1077 | 1077 |
1078 gfx::Rect panel_old_bounds = panel->GetBounds(); | 1078 gfx::Rect panel_old_bounds = panel->GetBounds(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 // Expect that the panel stays as docked. | 1119 // Expect that the panel stays as docked. |
1120 panel_testing->CancelDragTitlebar(); | 1120 panel_testing->CancelDragTitlebar(); |
1121 ASSERT_EQ(1, docked_strip->num_panels()); | 1121 ASSERT_EQ(1, docked_strip->num_panels()); |
1122 ASSERT_EQ(0, detached_strip->num_panels()); | 1122 ASSERT_EQ(0, detached_strip->num_panels()); |
1123 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); | 1123 EXPECT_EQ(PanelStrip::DOCKED, panel->panel_strip()->type()); |
1124 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | 1124 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); |
1125 | 1125 |
1126 panel_manager->CloseAll(); | 1126 panel_manager->CloseAll(); |
1127 } | 1127 } |
1128 | 1128 |
1129 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DetachWithSqueeze) { | 1129 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DetachWithSqueeze) { |
1130 PanelManager* panel_manager = PanelManager::GetInstance(); | 1130 PanelManager* panel_manager = PanelManager::GetInstance(); |
1131 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 1131 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
1132 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 1132 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
1133 | 1133 |
1134 gfx::Point drag_delta_to_detach = GetDragDeltaToDetach(); | 1134 gfx::Point drag_delta_to_detach = GetDragDeltaToDetach(); |
1135 | 1135 |
1136 // Create some docked panels. | 1136 // Create some docked panels. |
1137 // docked: P1 P2 P3 P4 P5 | 1137 // docked: P1 P2 P3 P4 P5 |
1138 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); | 1138 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); |
1139 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); | 1139 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 | 1200 |
1201 // No more squeeze, docked panels should stay put. | 1201 // No more squeeze, docked panels should stay put. |
1202 EXPECT_EQ(docked_position1, panel3->GetBounds().origin()); | 1202 EXPECT_EQ(docked_position1, panel3->GetBounds().origin()); |
1203 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); | 1203 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); |
1204 EXPECT_EQ(docked_position2, panel5->GetBounds().origin()); | 1204 EXPECT_EQ(docked_position2, panel5->GetBounds().origin()); |
1205 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); | 1205 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); |
1206 | 1206 |
1207 panel_manager->CloseAll(); | 1207 panel_manager->CloseAll(); |
1208 } | 1208 } |
1209 | 1209 |
1210 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, AttachWithSqueeze) { | 1210 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, AttachWithSqueeze) { |
1211 PanelManager* panel_manager = PanelManager::GetInstance(); | 1211 PanelManager* panel_manager = PanelManager::GetInstance(); |
1212 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 1212 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
1213 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 1213 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
1214 | 1214 |
1215 // Create some detached, docked panels. | 1215 // Create some detached, docked panels. |
1216 // detached: P1 P2 P3 | 1216 // detached: P1 P2 P3 |
1217 // docked: P4 P5 P6 P7 | 1217 // docked: P4 P5 P6 P7 |
1218 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 300, 200, 100)); | 1218 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 300, 200, 100)); |
1219 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 300, 200, 100)); | 1219 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 300, 200, 100)); |
1220 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(400, 300, 200, 100)); | 1220 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(400, 300, 200, 100)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 EXPECT_EQ(PanelStrip::DOCKED, panel2->panel_strip()->type()); | 1308 EXPECT_EQ(PanelStrip::DOCKED, panel2->panel_strip()->type()); |
1309 EXPECT_EQ(PanelStrip::DOCKED, panel3->panel_strip()->type()); | 1309 EXPECT_EQ(PanelStrip::DOCKED, panel3->panel_strip()->type()); |
1310 EXPECT_EQ(PanelStrip::DOCKED, panel4->panel_strip()->type()); | 1310 EXPECT_EQ(PanelStrip::DOCKED, panel4->panel_strip()->type()); |
1311 EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type()); | 1311 EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type()); |
1312 EXPECT_EQ(PanelStrip::DOCKED, panel6->panel_strip()->type()); | 1312 EXPECT_EQ(PanelStrip::DOCKED, panel6->panel_strip()->type()); |
1313 EXPECT_EQ(PanelStrip::DOCKED, panel7->panel_strip()->type()); | 1313 EXPECT_EQ(PanelStrip::DOCKED, panel7->panel_strip()->type()); |
1314 | 1314 |
1315 panel_manager->CloseAll(); | 1315 panel_manager->CloseAll(); |
1316 } | 1316 } |
1317 | 1317 |
1318 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragDetachedPanelToTop) { | 1318 IN_PROC_BROWSER_TEST_F(OldPanelDragBrowserTest, DragDetachedPanelToTop) { |
1319 // Setup the test areas to have top-aligned bar excluded from work area. | 1319 // Setup the test areas to have top-aligned bar excluded from work area. |
1320 const gfx::Rect primary_screen_area(0, 0, 800, 600); | 1320 const gfx::Rect primary_screen_area(0, 0, 800, 600); |
1321 const gfx::Rect work_area(0, 10, 800, 590); | 1321 const gfx::Rect work_area(0, 10, 800, 590); |
1322 SetTestingAreas(primary_screen_area, work_area); | 1322 SetTestingAreas(primary_screen_area, work_area); |
1323 | 1323 |
1324 PanelManager* panel_manager = PanelManager::GetInstance(); | 1324 PanelManager* panel_manager = PanelManager::GetInstance(); |
1325 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 1325 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
1326 | 1326 |
1327 // Drag up the panel. Expect that the panel should not go outside the top of | 1327 // Drag up the panel. Expect that the panel should not go outside the top of |
1328 // the work area. | 1328 // the work area. |
1329 gfx::Point drag_to_location(250, 0); | 1329 gfx::Point drag_to_location(250, 0); |
1330 DragPanelToMouseLocation(panel, drag_to_location); | 1330 DragPanelToMouseLocation(panel, drag_to_location); |
1331 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 1331 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
1332 EXPECT_EQ(drag_to_location.x(), panel->GetBounds().origin().x()); | 1332 EXPECT_EQ(drag_to_location.x(), panel->GetBounds().origin().x()); |
1333 EXPECT_EQ(work_area.y(), panel->GetBounds().origin().y()); | 1333 EXPECT_EQ(work_area.y(), panel->GetBounds().origin().y()); |
1334 | 1334 |
1335 // Drag down the panel. Expect that the panel can be dragged without | 1335 // Drag down the panel. Expect that the panel can be dragged without |
1336 // constraint. | 1336 // constraint. |
1337 drag_to_location = gfx::Point(280, 150); | 1337 drag_to_location = gfx::Point(280, 150); |
1338 DragPanelToMouseLocation(panel, drag_to_location); | 1338 DragPanelToMouseLocation(panel, drag_to_location); |
1339 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); | 1339 EXPECT_EQ(PanelStrip::DETACHED, panel->panel_strip()->type()); |
1340 EXPECT_EQ(drag_to_location, panel->GetBounds().origin()); | 1340 EXPECT_EQ(drag_to_location, panel->GetBounds().origin()); |
1341 | 1341 |
1342 panel_manager->CloseAll(); | 1342 panel_manager->CloseAll(); |
1343 } | 1343 } |
OLD | NEW |