| 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 6aa14c18c2dd709288efc3a63bdd3b88a8969196..26f1b49f67bde32d174e2e8ca4c0d6c791f1d0ad 100644
|
| --- a/chrome/browser/ui/panels/panel_drag_browsertest.cc
|
| +++ b/chrome/browser/ui/panels/panel_drag_browsertest.cc
|
| @@ -11,7 +11,6 @@
|
| #include "chrome/browser/ui/panels/panel_drag_controller.h"
|
| #include "chrome/browser/ui/panels/panel_manager.h"
|
| #include "chrome/browser/ui/panels/stacked_panel_collection.h"
|
| -#include "chrome/browser/ui/panels/test_panel_collection_squeeze_observer.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/test/test_utils.h"
|
| @@ -1292,21 +1291,29 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, MAYBE_DetachWithSqueeze) {
|
|
|
| gfx::Vector2d drag_delta_to_detach = GetDragDeltaToDetach();
|
|
|
| + int full_width = 200;
|
| + gfx::Rect initial_bounds = gfx::Rect(0, 0, full_width, 100);
|
| +
|
| // Create some docked panels.
|
| // docked: P1 P2 P3 P4 P5
|
| - Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
|
| - Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
|
| - Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
|
| - Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
|
| - Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
|
| + Panel* panel1 = CreateDockedPanel("1", initial_bounds);
|
| + Panel* panel2 = CreateDockedPanel("2", initial_bounds);
|
| + Panel* panel3 = CreateDockedPanel("3", initial_bounds);
|
| + Panel* panel4 = CreateDockedPanel("4", initial_bounds);
|
| + Panel* panel5 = CreateDockedPanel("5", initial_bounds);
|
| ASSERT_EQ(0, detached_collection->num_panels());
|
| ASSERT_EQ(5, docked_collection->num_panels());
|
|
|
| + EXPECT_GT(full_width, panel1->GetBounds().width());
|
| + EXPECT_GT(full_width, panel2->GetBounds().width());
|
| + EXPECT_GT(full_width, panel3->GetBounds().width());
|
| + EXPECT_GT(full_width, panel4->GetBounds().width());
|
| + EXPECT_EQ(full_width, panel5->GetBounds().width());
|
| +
|
| // Drag to detach the middle docked panel.
|
| // Expect to have:
|
| // detached: P2
|
| - // docked: P1 P3 P4 P5
|
| - gfx::Point panel2_docked_position = panel2->GetBounds().origin();
|
| + // docked: P1 P3 P4 P5
|
| DragPanelByDelta(panel2, drag_delta_to_detach);
|
| ASSERT_EQ(1, detached_collection->num_panels());
|
| ASSERT_EQ(4, docked_collection->num_panels());
|
| @@ -1315,53 +1322,49 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, MAYBE_DetachWithSqueeze) {
|
| EXPECT_EQ(PanelCollection::DOCKED, panel3->collection()->type());
|
| EXPECT_EQ(PanelCollection::DOCKED, panel4->collection()->type());
|
| EXPECT_EQ(PanelCollection::DOCKED, panel5->collection()->type());
|
| - gfx::Point panel2_new_position =
|
| - panel2_docked_position + drag_delta_to_detach;
|
| - EXPECT_EQ(panel2_new_position, panel2->GetBounds().origin());
|
| + // Expect that P2 should be restored with full width.1359
|
| +
|
| + EXPECT_EQ(full_width, panel2->GetBounds().width());
|
|
|
| // Drag to detach the left-most docked panel.
|
| // Expect to have:
|
| - // detached: P2 P4
|
| - // docked: P1 P3 P5
|
| - gfx::Point panel4_docked_position = panel4->GetBounds().origin();
|
| - DragPanelByDelta(panel4, drag_delta_to_detach);
|
| + // detached: P2 P5
|
| + // docked: P1 P3 P4
|
| + // Note that the different delta y is used for dragging in order to avoid
|
| + // possible snapping of detached panels.
|
| + drag_delta_to_detach.set_y(drag_delta_to_detach.y() - 50);
|
| + DragPanelByDelta(panel5, drag_delta_to_detach);
|
| ASSERT_EQ(2, detached_collection->num_panels());
|
| ASSERT_EQ(3, docked_collection->num_panels());
|
| EXPECT_EQ(PanelCollection::DOCKED, panel1->collection()->type());
|
| EXPECT_EQ(PanelCollection::DETACHED, panel2->collection()->type());
|
| EXPECT_EQ(PanelCollection::DOCKED, panel3->collection()->type());
|
| - EXPECT_EQ(PanelCollection::DETACHED, panel4->collection()->type());
|
| - EXPECT_EQ(PanelCollection::DOCKED, panel5->collection()->type());
|
| - EXPECT_EQ(panel2_new_position, panel2->GetBounds().origin());
|
| - gfx::Point panel4_new_position =
|
| - panel4_docked_position + drag_delta_to_detach;
|
| - EXPECT_EQ(panel4_new_position, panel4->GetBounds().origin());
|
| + EXPECT_EQ(PanelCollection::DOCKED, panel4->collection()->type());
|
| + EXPECT_EQ(PanelCollection::DETACHED, panel5->collection()->type());
|
| + // Expect that P5 should be restored with full width.
|
| + EXPECT_EQ(full_width, panel5->GetBounds().width());
|
|
|
| // Drag to detach the right-most docked panel.
|
| // Expect to have:
|
| - // detached: P1 P2 P4
|
| - // docked: P3 P5
|
| - gfx::Point docked_position1 = panel1->GetBounds().origin();
|
| - gfx::Point docked_position2 = panel3->GetBounds().origin();
|
| -
|
| + // detached: P1 P2 P5
|
| + // docked: P3 P4
|
| + // Note that the different delta y is used for dragging in order to avoid
|
| + // possible snapping of detached panels.
|
| + drag_delta_to_detach.set_y(drag_delta_to_detach.y() - 100);
|
| DragPanelByDelta(panel1, drag_delta_to_detach);
|
| ASSERT_EQ(3, detached_collection->num_panels());
|
| ASSERT_EQ(2, docked_collection->num_panels());
|
| EXPECT_EQ(PanelCollection::DETACHED, panel1->collection()->type());
|
| EXPECT_EQ(PanelCollection::DETACHED, panel2->collection()->type());
|
| EXPECT_EQ(PanelCollection::DOCKED, panel3->collection()->type());
|
| - EXPECT_EQ(PanelCollection::DETACHED, panel4->collection()->type());
|
| - EXPECT_EQ(PanelCollection::DOCKED, panel5->collection()->type());
|
| - gfx::Point panel1_new_position = docked_position1 + drag_delta_to_detach;
|
| - EXPECT_EQ(panel1_new_position, panel1->GetBounds().origin());
|
| - EXPECT_EQ(panel2_new_position, panel2->GetBounds().origin());
|
| - EXPECT_EQ(panel4_new_position, panel4->GetBounds().origin());
|
| + EXPECT_EQ(PanelCollection::DOCKED, panel4->collection()->type());
|
| + EXPECT_EQ(PanelCollection::DETACHED, panel5->collection()->type());
|
| + // Expect that P1 should be restored with full width.
|
| + EXPECT_EQ(full_width, panel1->GetBounds().width());
|
|
|
| // No more squeeze, docked panels should stay put.
|
| - EXPECT_EQ(docked_position1, panel3->GetBounds().origin());
|
| - EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
|
| - EXPECT_EQ(docked_position2, panel5->GetBounds().origin());
|
| - EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
|
| + EXPECT_EQ(full_width, panel1->GetBounds().width());
|
| + EXPECT_EQ(full_width, panel2->GetBounds().width());
|
|
|
| panel_manager->CloseAll();
|
| }
|
| @@ -1391,10 +1394,6 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, MAYBE_AttachWithSqueeze) {
|
| ASSERT_EQ(3, detached_collection->num_panels());
|
| ASSERT_EQ(4, docked_collection->num_panels());
|
|
|
| - // Wait for active states to settle.
|
| - PanelCollectionSqueezeObserver panel7_settled(docked_collection, panel7);
|
| - panel7_settled.Wait();
|
| -
|
| gfx::Point detached_position1 = panel1->GetBounds().origin();
|
| gfx::Point detached_position2 = panel2->GetBounds().origin();
|
| gfx::Point detached_position3 = panel3->GetBounds().origin();
|
| @@ -1422,9 +1421,6 @@ IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, MAYBE_AttachWithSqueeze) {
|
| EXPECT_EQ(detached_position1, panel1->GetBounds().origin());
|
| EXPECT_EQ(detached_position2, panel2->GetBounds().origin());
|
|
|
| - // Wait for active states to settle.
|
| - MessageLoopForUI::current()->RunUntilIdle();
|
| -
|
| // Panel positions should have shifted because of the "squeeze" mode.
|
| EXPECT_NE(docked_position4, panel4->GetBounds().origin());
|
| EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
|
|
|