| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/views/controls/single_split_view.h" | 8 #include "ui/views/controls/single_split_view.h" |
| 9 #include "ui/views/controls/single_split_view_listener.h" | 9 #include "ui/views/controls/single_split_view_listener.h" |
| 10 | 10 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 const int kTotalSplitSize = 100; | 159 const int kTotalSplitSize = 100; |
| 160 split.SetBounds(0, 0, 10, kTotalSplitSize); | 160 split.SetBounds(0, 0, 10, kTotalSplitSize); |
| 161 const int kInitialDividerOffset = 33; | 161 const int kInitialDividerOffset = 33; |
| 162 const int kMouseOffset = 2; // Mouse offset in the divider. | 162 const int kMouseOffset = 2; // Mouse offset in the divider. |
| 163 const int kMouseMoveDelta = 7; | 163 const int kMouseMoveDelta = 7; |
| 164 split.set_divider_offset(kInitialDividerOffset); | 164 split.set_divider_offset(kInitialDividerOffset); |
| 165 split.Layout(); | 165 split.Layout(); |
| 166 | 166 |
| 167 gfx::Point press_point(7, kInitialDividerOffset + kMouseOffset); | 167 gfx::Point press_point(7, kInitialDividerOffset + kMouseOffset); |
| 168 ui::MouseEvent mouse_pressed( | 168 ui::MouseEvent mouse_pressed( |
| 169 ui::ET_MOUSE_PRESSED, press_point, press_point, 0); | 169 ui::ET_MOUSE_PRESSED, press_point, press_point, 0, 0); |
| 170 ASSERT_TRUE(split.OnMousePressed(mouse_pressed)); | 170 ASSERT_TRUE(split.OnMousePressed(mouse_pressed)); |
| 171 EXPECT_EQ(kInitialDividerOffset, split.divider_offset()); | 171 EXPECT_EQ(kInitialDividerOffset, split.divider_offset()); |
| 172 | 172 |
| 173 // Drag divider to the bottom. | 173 // Drag divider to the bottom. |
| 174 gfx::Point drag_1_point( | 174 gfx::Point drag_1_point( |
| 175 5, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta); | 175 5, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta); |
| 176 ui::MouseEvent mouse_dragged_1( | 176 ui::MouseEvent mouse_dragged_1( |
| 177 ui::ET_MOUSE_DRAGGED, drag_1_point, drag_1_point, 0); | 177 ui::ET_MOUSE_DRAGGED, drag_1_point, drag_1_point, 0, 0); |
| 178 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_1)); | 178 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_1)); |
| 179 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta, split.divider_offset()); | 179 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta, split.divider_offset()); |
| 180 | 180 |
| 181 // Drag divider to the top, beyond first child minimum size. | 181 // Drag divider to the top, beyond first child minimum size. |
| 182 gfx::Point drag_2_point( | 182 gfx::Point drag_2_point( |
| 183 7, kMinimumChildSize - 5); | 183 7, kMinimumChildSize - 5); |
| 184 ui::MouseEvent mouse_dragged_2( | 184 ui::MouseEvent mouse_dragged_2( |
| 185 ui::ET_MOUSE_DRAGGED, drag_2_point, drag_2_point, 0); | 185 ui::ET_MOUSE_DRAGGED, drag_2_point, drag_2_point, 0,0 ); |
| 186 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2)); | 186 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_2)); |
| 187 EXPECT_EQ(kMinimumChildSize, | 187 EXPECT_EQ(kMinimumChildSize, |
| 188 split.divider_offset()); | 188 split.divider_offset()); |
| 189 | 189 |
| 190 // Drag divider to the bottom, beyond second child minimum size. | 190 // Drag divider to the bottom, beyond second child minimum size. |
| 191 gfx::Point drag_3_point( | 191 gfx::Point drag_3_point( |
| 192 7, kTotalSplitSize - kMinimumChildSize + 5); | 192 7, kTotalSplitSize - kMinimumChildSize + 5); |
| 193 ui::MouseEvent mouse_dragged_3( | 193 ui::MouseEvent mouse_dragged_3( |
| 194 ui::ET_MOUSE_DRAGGED, drag_3_point, drag_3_point, 0); | 194 ui::ET_MOUSE_DRAGGED, drag_3_point, drag_3_point, 0, 0); |
| 195 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_3)); | 195 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_3)); |
| 196 EXPECT_EQ(kTotalSplitSize - kMinimumChildSize - split.GetDividerSize(), | 196 EXPECT_EQ(kTotalSplitSize - kMinimumChildSize - split.GetDividerSize(), |
| 197 split.divider_offset()); | 197 split.divider_offset()); |
| 198 | 198 |
| 199 // Drag divider between childs' minimum sizes. | 199 // Drag divider between childs' minimum sizes. |
| 200 gfx::Point drag_4_point( | 200 gfx::Point drag_4_point( |
| 201 6, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2); | 201 6, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2); |
| 202 ui::MouseEvent mouse_dragged_4( | 202 ui::MouseEvent mouse_dragged_4( |
| 203 ui::ET_MOUSE_DRAGGED, drag_4_point, drag_4_point, 0); | 203 ui::ET_MOUSE_DRAGGED, drag_4_point, drag_4_point, 0, 0); |
| 204 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_4)); | 204 ASSERT_TRUE(split.OnMouseDragged(mouse_dragged_4)); |
| 205 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, | 205 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, |
| 206 split.divider_offset()); | 206 split.divider_offset()); |
| 207 | 207 |
| 208 gfx::Point release_point( | 208 gfx::Point release_point( |
| 209 7, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2); | 209 7, kInitialDividerOffset + kMouseOffset + kMouseMoveDelta * 2); |
| 210 ui::MouseEvent mouse_released( | 210 ui::MouseEvent mouse_released( |
| 211 ui::ET_MOUSE_RELEASED, release_point, release_point, 0); | 211 ui::ET_MOUSE_RELEASED, release_point, release_point, 0, 0); |
| 212 split.OnMouseReleased(mouse_released); | 212 split.OnMouseReleased(mouse_released); |
| 213 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, | 213 EXPECT_EQ(kInitialDividerOffset + kMouseMoveDelta * 2, |
| 214 split.divider_offset()); | 214 split.divider_offset()); |
| 215 | 215 |
| 216 // Expect intial offset after a system/user gesture cancels the drag. | 216 // Expect intial offset after a system/user gesture cancels the drag. |
| 217 // This shouldn't occur after mouse release, but it's sufficient for testing. | 217 // This shouldn't occur after mouse release, but it's sufficient for testing. |
| 218 split.OnMouseCaptureLost(); | 218 split.OnMouseCaptureLost(); |
| 219 EXPECT_EQ(kInitialDividerOffset, split.divider_offset()); | 219 EXPECT_EQ(kInitialDividerOffset, split.divider_offset()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace views | 222 } // namespace views |
| OLD | NEW |