Index: chrome/browser/ui/panels/panel_browsertest.cc |
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc |
index 2e88fc3e44d7ac7dae3ec1b0774f89cd3312f2a3..a15d9e3da93f83d8094733e2247734f597964d34 100644 |
--- a/chrome/browser/ui/panels/panel_browsertest.cc |
+++ b/chrome/browser/ui/panels/panel_browsertest.cc |
@@ -27,6 +27,8 @@ |
#include "content/browser/tab_contents/test_tab_contents.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+using base::PlatformThread; |
jianli
2011/08/23 17:27:12
Why is need needed?
prasadt
2011/08/23 18:05:10
Not needed. I was using it to get the Sleep metho
|
+ |
#if defined(OS_MACOSX) |
#include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
#endif |
@@ -154,116 +156,108 @@ class PanelBrowserTest : public InProcessBrowserTest { |
panel6->Close(); |
} |
- struct DragTestData { |
- DragTestData(int drag_delta_x, |
- int drag_delta_y, |
- bool is_big_delta, |
- bool should_cancel_drag) |
- : drag_delta_x(drag_delta_x), drag_delta_y(drag_delta_y), |
- is_big_delta(is_big_delta), should_cancel_drag(should_cancel_drag) {} |
- int drag_delta_x; |
- int drag_delta_y; |
- bool is_big_delta; // Drag big enough to cause shuffling. |
- bool should_cancel_drag; |
- }; |
+ void SetWorkArea(const gfx::Rect& work_area) { |
+ PanelManager::GetInstance()->SetWorkArea(gfx::Rect(0, 0, 800, 600)); |
+ } |
- void TestDragging(std::vector<Panel*>* panels, |
- const DragTestData& drag_test_data) { |
- size_t num_panels = panels->size(); |
+ void RestoreWorkArea() { |
+ PanelManager::GetInstance()->OnDisplayChanged(); |
+ } |
- // Test dragging each panel in the list. |
- for (size_t drag_index = 0; drag_index < num_panels; ++drag_index) { |
- std::vector<int> expected_delta_x_after_drag(num_panels, 0); |
- std::vector<int> expected_delta_x_after_finish(num_panels, 0); |
+ int horizontal_spacing() { |
+ return PanelManager::horizontal_spacing(); |
+ } |
- for (size_t j = 0; j < num_panels; ++j) { |
- expected_delta_x_after_drag.push_back(0); |
- expected_delta_x_after_finish.push_back(0); |
- } |
+ void CloseAllPanels() { |
+ const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels_; |
+ for (size_t i = 0; i < panels.size(); ++i) |
+ panels[i]->Close(); |
jennb
2011/08/23 17:14:16
Is it safe to modify the vector as you're iteratin
prasadt
2011/08/23 18:05:10
We're not modifying the vector, rather the object
jennb
2011/08/23 18:09:31
Closing a panel could remove the panel from PanelM
prasadt
2011/08/23 18:26:25
Good point. Its probably not closing all the pane
|
+ } |
- expected_delta_x_after_drag[drag_index] = drag_test_data.drag_delta_x; |
- size_t swap_index = drag_index; |
- if (drag_test_data.is_big_delta) { |
- if (drag_test_data.drag_delta_x > 0 && drag_index != 0) { |
- // Dragged to right. |
- swap_index = drag_index - 1; |
- } else if (drag_test_data.drag_delta_x < 0 && |
- drag_index != num_panels - 1) { |
- // Dragged to left. |
- swap_index = drag_index + 1; |
- } |
- } |
- if (swap_index != drag_index) { |
- expected_delta_x_after_drag[swap_index] = |
- (*panels)[drag_index]->GetRestoredBounds().x() - |
- (*panels)[swap_index]->GetRestoredBounds().x(); |
- expected_delta_x_after_finish[swap_index] = |
- expected_delta_x_after_drag[swap_index]; |
- expected_delta_x_after_finish[drag_index] = |
- -expected_delta_x_after_drag[swap_index]; |
- } |
- ValidateDragging(*panels, drag_index, drag_test_data.drag_delta_x, |
- drag_test_data.drag_delta_y, expected_delta_x_after_drag, |
- expected_delta_x_after_finish, drag_test_data.should_cancel_drag); |
- |
- if (swap_index != drag_index && !drag_test_data.should_cancel_drag) { |
- // Swap the panels in the vector so they reflect their true relative |
- // positions. |
- Panel* tmp_panel = (*panels)[swap_index]; |
- (*panels)[swap_index] = (*panels)[drag_index]; |
- (*panels)[drag_index] = tmp_panel; |
- } |
+ std::vector<gfx::Rect> GetAllPanelsBounds() { |
+ std::vector<gfx::Rect> panels_bounds; |
+ const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels_; |
+ for (size_t i = 0; i < panels.size(); ++i) |
+ panels_bounds.push_back(panels[i]->GetRestoredBounds()); |
+ return panels_bounds; |
+ } |
+ |
+ // Helper function for debugging. |
+ void PrintPanelBounds() { |
+ const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels_; |
+ DLOG(WARNING) << "PanelBounds:"; |
+ for (size_t i = 0; i < panels.size(); ++i) { |
+ DLOG(WARNING) << "#=" << i |
+ << ", ptr=" << panels[i] |
+ << ", x=" << panels[i]->GetRestoredBounds().x() |
+ << ", y=" << panels[i]->GetRestoredBounds().y() |
+ << ", width=" << panels[i]->GetRestoredBounds().width() |
+ << ", height" << panels[i]->GetRestoredBounds().height(); |
} |
} |
- void ValidateDragging(const std::vector<Panel*>& panels, |
- int index_to_drag, |
- int delta_x, |
- int delta_y, |
- const std::vector<int>& expected_delta_x_after_drag, |
- const std::vector<int>& expected_delta_x_after_finish, |
- bool should_cancel_drag) { |
- // Keep track of the initial bounds for comparison. |
- std::vector<gfx::Rect> initial_bounds(panels.size()); |
- for (size_t i = 0; i < panels.size(); ++i) |
- initial_bounds[i] = panels[i]->GetRestoredBounds(); |
+ // This is a set of flags that controls the specific drag actions to be |
+ // carried out by TestDragging function. |
+ enum HandleDrag { |
jennb
2011/08/23 17:14:16
Would DragAction be more descriptive?
prasadt
2011/08/23 18:05:10
Sounds good. Done.
|
+ HANDLE_DRAG_BEGIN = 1, |
+ HANDLE_DRAG_FINISH = 2, |
+ HANDLE_DRAG_CANCEL = 4 |
+ }; |
- // Trigger the mouse-pressed event. |
- // All panels should remain in their original positions. |
- NativePanel* panel_to_drag = panels[index_to_drag]->native_panel(); |
+ void TestDragging(int delta_x, |
+ int delta_y, |
+ size_t drag_index, |
+ std::vector<int>expected_delta_x_after_drag, |
+ std::vector<int>expected_delta_x_after_finish, |
+ std::vector<gfx::Rect> initial_bounds, |
+ int handle_drag) { |
+ std::vector<Panel*> panels = PanelManager::GetInstance()->panels_; |
+ |
+ // These are bounds at the beginning of this test. This would be different |
jennb
2011/08/23 17:14:16
I'm still having trouble understanding how initial
prasadt
2011/08/23 18:05:10
Done.
I added an example, hope that helps.
|
+ // from initial_bounds in the case where we're testing for the case of |
+ // multiple drags before finishing the drag. |
+ std::vector<gfx::Rect> test_begin_bounds = GetAllPanelsBounds(); |
+ |
+ NativePanel* panel_to_drag = panels[drag_index]->native_panel(); |
scoped_ptr<NativePanelTesting> panel_testing_to_drag( |
NativePanelTesting::Create(panel_to_drag)); |
- gfx::Point button_press_point(initial_bounds[index_to_drag].x(), |
- initial_bounds[index_to_drag].y()); |
- panel_testing_to_drag->PressLeftMouseButtonTitlebar(button_press_point); |
- for (size_t i = 0; i < panels.size(); ++i) |
- EXPECT_EQ(initial_bounds[i], panels[i]->GetRestoredBounds()); |
+ if (handle_drag & HANDLE_DRAG_BEGIN) { |
jennb
2011/08/23 17:14:16
Oh, it's a bitmask. Could you add a comment to the
prasadt
2011/08/23 18:05:10
Done.
There is a comment already that says its a s
|
+ // Trigger the mouse-pressed event. |
+ // All panels should remain in their original positions. |
+ gfx::Point button_press_point( |
+ panels[drag_index]->GetRestoredBounds().x(), |
+ panels[drag_index]->GetRestoredBounds().y()); |
+ panel_testing_to_drag->PressLeftMouseButtonTitlebar(button_press_point); |
+ for (size_t i = 0; i < panels.size(); ++i) |
+ EXPECT_EQ(test_begin_bounds[i], panels[i]->GetRestoredBounds()); |
+ } |
// Trigger the drag. |
+ // Compare against expected bounds. |
panel_testing_to_drag->DragTitlebar(delta_x, delta_y); |
- |
for (size_t i = 0; i < panels.size(); ++i) { |
- gfx::Rect expected_bounds = initial_bounds[i]; |
+ gfx::Rect expected_bounds = test_begin_bounds[i]; |
expected_bounds.Offset(expected_delta_x_after_drag[i], 0); |
EXPECT_EQ(expected_bounds, panels[i]->GetRestoredBounds()); |
} |
- // Cancel drag if asked. |
- // All panels should stay in their original positions. |
- if (should_cancel_drag) { |
+ if (handle_drag & HANDLE_DRAG_CANCEL) { |
+ // Cancel the drag. |
+ // All panels should return to their initial positions. |
panel_testing_to_drag->CancelDragTitlebar(); |
+ std::vector<gfx::Rect> current_bounds = GetAllPanelsBounds(); |
for (size_t i = 0; i < panels.size(); ++i) |
- EXPECT_EQ(initial_bounds[i], panels[i]->GetRestoredBounds()); |
- return; |
- } |
- |
- // Otherwise finish the drag. |
- panel_testing_to_drag->FinishDragTitlebar(); |
- for (size_t i = 0; i < panels.size(); ++i) { |
- gfx::Rect expected_bounds = initial_bounds[i]; |
- expected_bounds.Offset(expected_delta_x_after_finish[i], 0); |
- EXPECT_EQ(expected_bounds, panels[i]->GetRestoredBounds()); |
+ EXPECT_EQ(initial_bounds[i], current_bounds[i]); |
+ } else if (handle_drag & HANDLE_DRAG_FINISH) { |
+ // Finish the drag. |
+ // Compare against expected bounds. |
+ panel_testing_to_drag->FinishDragTitlebar(); |
+ for (size_t i = 0; i < panels.size(); ++i) { |
+ gfx::Rect expected_bounds = test_begin_bounds[i]; |
+ expected_bounds.Offset(expected_delta_x_after_finish[i], 0); |
+ EXPECT_EQ(expected_bounds, panels[i]->GetRestoredBounds()); |
+ } |
} |
} |
}; |
@@ -311,37 +305,267 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_CreatePanelOnOverflow) { |
#endif |
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DragPanels) { |
- std::vector<Panel*> panels; |
- panels.push_back(CreatePanel("PanelTest0", gfx::Rect())); |
- |
- int small_delta = 5; |
- int big_delta = panels[0]->GetRestoredBounds().width() * 0.5 + 5; |
- |
- // Setup test data. |
- // Template - DragTestData(delta_x, delta_y, is_big_delta, should_cancel_drag) |
- std::vector<DragTestData> drag_test_data; |
- drag_test_data.push_back(DragTestData( |
- small_delta, small_delta, false, false)); |
- drag_test_data.push_back(DragTestData( |
- -small_delta, -small_delta, false, false)); |
- drag_test_data.push_back(DragTestData(big_delta, big_delta, true, false)); |
- drag_test_data.push_back(DragTestData(big_delta, small_delta, true, false)); |
- drag_test_data.push_back(DragTestData(-big_delta, -big_delta, true, false)); |
- drag_test_data.push_back(DragTestData(-big_delta, 0, true, false)); |
- drag_test_data.push_back(DragTestData(big_delta, big_delta, true, true)); |
- drag_test_data.push_back(DragTestData(-big_delta, -big_delta, true, true)); |
- |
- for (int num_panels = 1; num_panels <= 3; ++num_panels) { |
- if (num_panels > 1) |
- panels.push_back(CreatePanel("PanelTest", gfx::Rect())); |
- for (size_t j = 0; j < drag_test_data.size(); ++j) { |
- // Test for each combination of drag test data and number of panels. |
- TestDragging(&panels, drag_test_data[j]); |
- } |
- } |
- |
- for (size_t i = 0; i < panels.size(); ++i) |
- panels[i]->Close(); |
+ // Set work area to make the test consistent on different monitor sizes. |
+ SetWorkArea(gfx::Rect(0, 0, 800, 600)); |
+ |
+ int max_panels = 4; |
jianli
2011/08/23 17:27:12
You can add "static const" for this variable.
prasadt
2011/08/23 18:05:10
Done. Also changed the value to 3.
|
+ int small_delta = 10; |
+ int big_delta = 60; |
+ std::vector<int> zero_delta(max_panels, 0); |
+ std::vector<int> expected_delta_x_after_drag(max_panels, 0); |
+ std::vector<int> expected_delta_x_after_finish(max_panels, 0); |
+ |
+ // **** Tests with a single panel. |
jennb
2011/08/23 17:14:16
Not a big fan of extra **** or ==== in the comment
prasadt
2011/08/23 18:05:10
Sure. They make sense here though.
jennb
2011/08/23 18:09:31
What about subroutines then for testing one panel,
prasadt
2011/08/23 18:26:25
I don't see a net win. The variable declarations
prasadt
2011/08/23 20:15:10
Removed the special markers and replaced with scop
|
+ CreatePanel("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
+ |
+ // ==== Drag left. |
+ expected_delta_x_after_drag[0] = -big_delta; |
+ expected_delta_x_after_finish = zero_delta; |
+ TestDragging(-big_delta, 0, 0, expected_delta_x_after_drag, |
+ zero_delta, GetAllPanelsBounds(), |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag left and cancel. |
+ expected_delta_x_after_drag[0] = -big_delta; |
+ expected_delta_x_after_finish = zero_delta; |
+ TestDragging(-big_delta, 0, 0, expected_delta_x_after_drag, |
+ zero_delta, GetAllPanelsBounds(), |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_CANCEL); |
+ |
+ // ==== Drag right. |
+ expected_delta_x_after_drag[0] = big_delta; |
+ TestDragging(big_delta, 0, 0, expected_delta_x_after_drag, |
+ zero_delta, GetAllPanelsBounds(), |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag right and up. Expect no vertical movement. |
+ TestDragging(big_delta, big_delta, 0, expected_delta_x_after_drag, |
+ zero_delta, GetAllPanelsBounds(), |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag up. Expect no movement on drag. |
+ TestDragging(0, -big_delta, 0, zero_delta, zero_delta, |
+ GetAllPanelsBounds(), HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag down. Expect no movement on drag. |
+ TestDragging(0, big_delta, 0, zero_delta, zero_delta, |
+ GetAllPanelsBounds(), HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // **** Tests with two panels. |
+ CreatePanel("PanelTest2", gfx::Rect(0, 0, 90, 90)); |
jianli
2011/08/23 17:27:12
For now, do not create the panel with size smaller
prasadt
2011/08/23 18:05:10
Done. Made it bigger.
You're such a savior Jian!
|
+ |
+ // ==== Drag left, small delta, expect no shuffle. |
+ expected_delta_x_after_drag = zero_delta; |
+ expected_delta_x_after_drag[0] = -small_delta; |
+ TestDragging(-small_delta, 1, 0, expected_delta_x_after_drag, zero_delta, |
+ GetAllPanelsBounds(), HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // Drag right panel i.e index 0, towards left, big delta, expect shuffle. |
+ std::vector<gfx::Rect> initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ |
+ // Deltas for panel being dragged. |
+ expected_delta_x_after_drag[0] = -big_delta; |
+ expected_delta_x_after_finish[0] = |
+ -(initial_bounds[1].width() + horizontal_spacing()); |
+ |
+ // Deltas for panel being shuffled. |
+ expected_delta_x_after_drag[1] = |
+ initial_bounds[0].width() + horizontal_spacing(); |
+ expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; |
+ |
+ TestDragging(-big_delta, 0, 0, expected_delta_x_after_drag, |
+ expected_delta_x_after_finish, initial_bounds, |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag left panel i.e index 1, towards right, big delta, expect shuffle. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ expected_delta_x_after_finish = zero_delta; |
+ |
+ // Deltas for panel being dragged. |
+ expected_delta_x_after_drag[1] = big_delta; |
+ expected_delta_x_after_finish[1] = |
+ initial_bounds[0].width() + horizontal_spacing(); |
+ |
+ // Deltas for panel being shuffled. |
+ expected_delta_x_after_drag[0] = |
+ -(initial_bounds[1].width() + horizontal_spacing()); |
+ expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; |
+ |
+ TestDragging(big_delta, 0, 1, expected_delta_x_after_drag, |
+ expected_delta_x_after_finish, initial_bounds, |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag left panel i.e index 1, towards right, big delta, expect shuffle. |
+ // Cancel drag. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ |
+ // Delta for panel being dragged. |
+ expected_delta_x_after_drag[1] = big_delta; |
+ |
+ // Delta for panel being shuffled. |
+ expected_delta_x_after_drag[0] = |
+ -(initial_bounds[1].width() + horizontal_spacing()); |
+ |
+ // As the drag is being canceled, we don't need expected_delta_x_after_finish. |
+ // Instead initial_bounds will be used. |
+ TestDragging(big_delta, 0, 1, expected_delta_x_after_drag, |
+ zero_delta, initial_bounds, |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_CANCEL); |
+ |
+ // **** Tests with three panels. |
+ CreatePanel("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
jennb
2011/08/23 17:14:16
PanelTest3
prasadt
2011/08/23 18:05:10
Done.
|
+ |
+ // #### Drag left most panel to become right most with two shuffles. |
+ // We test both shuffles. |
+ |
+ // ==== First drag and shuffle. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ |
+ // Delta for panel being dragged. |
+ expected_delta_x_after_drag[2] = big_delta; |
+ |
+ // Delta for panel being shuffled. |
+ expected_delta_x_after_drag[1] = |
+ -(initial_bounds[2].width() + horizontal_spacing()); |
+ |
+ // There is no delta after finish as drag is done yet. |
+ TestDragging(big_delta, 0, 2, expected_delta_x_after_drag, |
+ zero_delta, initial_bounds, HANDLE_DRAG_BEGIN); |
+ |
+ // ==== Second drag and shuffle. We finish the drag here. The drag index |
+ // changes from 2 to 1 because of the first shuffle above. |
+ std::vector<gfx::Rect> current_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ expected_delta_x_after_finish = zero_delta; |
+ |
+ // big_delta is not enough to cause the second shuffle as the panel being |
+ // dragged is in the middle of a drag and big_delta won't go far enough. |
+ int bigger_delta = 100; |
+ |
+ // Deltas for panel being dragged. |
+ expected_delta_x_after_drag[1] = bigger_delta; |
+ int x_after_finish = current_bounds[0].x() + |
+ (current_bounds[0].width() - current_bounds[1].width()); |
+ expected_delta_x_after_finish[1] = x_after_finish - current_bounds[1].x(); |
+ |
+ // Deltas for panel being shuffled. |
+ expected_delta_x_after_drag[0] = |
+ -(current_bounds[1].width() + horizontal_spacing()); |
+ expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; |
+ |
+ TestDragging(bigger_delta, 0, 1, expected_delta_x_after_drag, |
+ expected_delta_x_after_finish, initial_bounds, |
+ HANDLE_DRAG_FINISH); |
+ |
+ // #### Drag right most panel to become left most with two shuffles. |
+ // And then cancel the drag. |
+ |
+ // ==== First drag and shuffle. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ |
+ // Delta for panel being dragged. |
+ expected_delta_x_after_drag[0] = -big_delta; |
+ |
+ // Delta for panel being shuffled. |
+ expected_delta_x_after_drag[1] = |
+ (initial_bounds[0].width() + horizontal_spacing()); |
+ |
+ // There is no delta after finish as drag is done yet. |
+ TestDragging(-big_delta, 0, 0, expected_delta_x_after_drag, |
+ zero_delta, initial_bounds, HANDLE_DRAG_BEGIN); |
+ |
+ // ==== Second drag and shuffle. We cancel the drag here. The drag index |
+ // changes from 0 to 1 because of the first shuffle above. |
+ current_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ |
+ // Delta for panel being dragged. |
+ expected_delta_x_after_drag[1] = -bigger_delta; |
+ |
+ // Deltas for panel being shuffled. |
+ int x_after_shuffle = |
+ current_bounds[0].x() - horizontal_spacing() - current_bounds[2].width(); |
+ expected_delta_x_after_drag[2] = x_after_shuffle - current_bounds[2].x(); |
+ |
+ // There is no delta after finish as drag canceled. |
+ TestDragging(-bigger_delta, 0, 1, expected_delta_x_after_drag, |
+ zero_delta, initial_bounds, HANDLE_DRAG_CANCEL); |
+ |
+ // ==== Drag left most panel to become the right most in a single drag. This |
+ // will shuffle middle panel to left most and right most to middle. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ expected_delta_x_after_finish = zero_delta; |
+ int biggest_delta = 200; |
+ |
+ // Deltas for panel being dragged. |
+ expected_delta_x_after_drag[2] = biggest_delta; |
+ expected_delta_x_after_finish[2] = |
+ initial_bounds[1].width() + horizontal_spacing() + |
+ initial_bounds[0].width() + horizontal_spacing(); |
+ |
+ // Deltas for middle panels being shuffled. |
+ expected_delta_x_after_drag[1] = |
+ -(initial_bounds[2].width() + horizontal_spacing()); |
+ expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; |
+ |
+ expected_delta_x_after_drag[0] = expected_delta_x_after_drag[1]; |
+ expected_delta_x_after_finish[0] = expected_delta_x_after_drag[0]; |
+ |
+ TestDragging(biggest_delta, 0, 2, expected_delta_x_after_drag, |
+ expected_delta_x_after_finish, initial_bounds, |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag right most panel to become the left most in a single drag. This |
+ // will shuffle middle panel to right most and left most to middle. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ expected_delta_x_after_finish = zero_delta; |
+ |
+ // Deltas for panel being dragged. |
+ expected_delta_x_after_drag[0] = -biggest_delta; |
+ expected_delta_x_after_finish[0] = |
+ -(initial_bounds[1].width() + horizontal_spacing() + |
+ initial_bounds[2].width() + horizontal_spacing()); |
+ |
+ // Deltas for panels being shuffled. |
+ expected_delta_x_after_drag[1] = |
+ initial_bounds[0].width() + horizontal_spacing(); |
+ expected_delta_x_after_finish[1] = expected_delta_x_after_drag[1]; |
+ |
+ expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; |
+ expected_delta_x_after_finish[2] = expected_delta_x_after_drag[2]; |
+ |
+ TestDragging(-biggest_delta, 0, 0, expected_delta_x_after_drag, |
+ expected_delta_x_after_finish, initial_bounds, |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_FINISH); |
+ |
+ // ==== Drag right most panel to become the left most in a single drag. Then |
+ // cancel the drag. |
+ initial_bounds = GetAllPanelsBounds(); |
+ expected_delta_x_after_drag = zero_delta; |
+ |
+ // Deltas for panel being dragged. |
+ expected_delta_x_after_drag[0] = -biggest_delta; |
+ |
+ // Deltas for panels being shuffled. |
+ expected_delta_x_after_drag[1] = |
+ initial_bounds[0].width() + horizontal_spacing(); |
+ expected_delta_x_after_drag[2] = expected_delta_x_after_drag[1]; |
+ |
+ // No delta after finish as drag is canceled. |
+ TestDragging(-biggest_delta, 0, 0, expected_delta_x_after_drag, |
+ zero_delta, initial_bounds, |
+ HANDLE_DRAG_BEGIN | HANDLE_DRAG_CANCEL); |
+ |
+ // Close panels and restore work area. |
+ CloseAllPanels(); |
+ RestoreWorkArea(); |
jianli
2011/08/23 17:27:12
No need to restore work area.
prasadt
2011/08/23 18:05:10
Done.
|
} |
class PanelDownloadTest : public PanelBrowserTest { |