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 "ui/views/controls/table/table_view.h" | 5 #include "ui/views/controls/table/table_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, y), | 204 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, y), |
205 gfx::Point(0, y), ui::EventTimeForNow(), | 205 gfx::Point(0, y), ui::EventTimeForNow(), |
206 ui::EF_LEFT_MOUSE_BUTTON | flags, | 206 ui::EF_LEFT_MOUSE_BUTTON | flags, |
207 ui::EF_LEFT_MOUSE_BUTTON); | 207 ui::EF_LEFT_MOUSE_BUTTON); |
208 table_->OnMousePressed(pressed); | 208 table_->OnMousePressed(pressed); |
209 } | 209 } |
210 | 210 |
211 void TapOnRow(int row) { | 211 void TapOnRow(int row) { |
212 const int y = row * table_->row_height(); | 212 const int y = row * table_->row_height(); |
213 const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP); | 213 const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP); |
214 ui::GestureEvent tap(0, y, 0, base::TimeDelta(), event_details); | 214 ui::GestureEvent tap(0, y, 0, base::TimeTicks(), event_details); |
215 table_->OnGestureEvent(&tap); | 215 table_->OnGestureEvent(&tap); |
216 } | 216 } |
217 | 217 |
218 // Returns the state of the selection model as a string. The format is: | 218 // Returns the state of the selection model as a string. The format is: |
219 // 'active=X anchor=X selection=X X X...'. | 219 // 'active=X anchor=X selection=X X X...'. |
220 std::string SelectionStateAsString() const { | 220 std::string SelectionStateAsString() const { |
221 const ui::ListSelectionModel& model(table_->selection_model()); | 221 const ui::ListSelectionModel& model(table_->selection_model()); |
222 std::string result = "active=" + base::IntToString(model.active()) + | 222 std::string result = "active=" + base::IntToString(model.active()) + |
223 " anchor=" + base::IntToString(model.anchor()) + | 223 " anchor=" + base::IntToString(model.anchor()) + |
224 " selection="; | 224 " selection="; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 EXPECT_EQ(x - 1, table_->visible_columns()[0].width); | 313 EXPECT_EQ(x - 1, table_->visible_columns()[0].width); |
314 EXPECT_EQ(x - 1, table_->visible_columns()[1].x); | 314 EXPECT_EQ(x - 1, table_->visible_columns()[1].x); |
315 } | 315 } |
316 | 316 |
317 // Verifies resizing a column works with a gesture. | 317 // Verifies resizing a column works with a gesture. |
318 TEST_F(TableViewTest, ResizeViaGesture) { | 318 TEST_F(TableViewTest, ResizeViaGesture) { |
319 const int x = table_->visible_columns()[0].width; | 319 const int x = table_->visible_columns()[0].width; |
320 EXPECT_NE(0, x); | 320 EXPECT_NE(0, x); |
321 // Drag the mouse 1 pixel to the left. | 321 // Drag the mouse 1 pixel to the left. |
322 ui::GestureEvent scroll_begin( | 322 ui::GestureEvent scroll_begin( |
323 x, | 323 x, 0, 0, base::TimeTicks(), |
324 0, | |
325 0, | |
326 base::TimeDelta(), | |
327 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); | 324 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); |
328 helper_->header()->OnGestureEvent(&scroll_begin); | 325 helper_->header()->OnGestureEvent(&scroll_begin); |
329 ui::GestureEvent scroll_update( | 326 ui::GestureEvent scroll_update( |
330 x - 1, | 327 x - 1, 0, 0, base::TimeTicks(), |
331 0, | |
332 0, | |
333 base::TimeDelta(), | |
334 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE)); | 328 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE)); |
335 helper_->header()->OnGestureEvent(&scroll_update); | 329 helper_->header()->OnGestureEvent(&scroll_update); |
336 | 330 |
337 // This should shrink the first column and pull the second column in. | 331 // This should shrink the first column and pull the second column in. |
338 EXPECT_EQ(x - 1, table_->visible_columns()[0].width); | 332 EXPECT_EQ(x - 1, table_->visible_columns()[0].width); |
339 EXPECT_EQ(x - 1, table_->visible_columns()[1].x); | 333 EXPECT_EQ(x - 1, table_->visible_columns()[1].x); |
340 } | 334 } |
341 | 335 |
342 // Assertions for table sorting. | 336 // Assertions for table sorting. |
343 TEST_F(TableViewTest, Sort) { | 337 TEST_F(TableViewTest, Sort) { |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 new_selection.AddIndexToSelection(0); | 908 new_selection.AddIndexToSelection(0); |
915 new_selection.AddIndexToSelection(1); | 909 new_selection.AddIndexToSelection(1); |
916 new_selection.set_active(0); | 910 new_selection.set_active(0); |
917 new_selection.set_anchor(0); | 911 new_selection.set_anchor(0); |
918 helper_->SetSelectionModel(new_selection); | 912 helper_->SetSelectionModel(new_selection); |
919 model_->RemoveRow(0); | 913 model_->RemoveRow(0); |
920 helper_->OnFocus(); | 914 helper_->OnFocus(); |
921 } | 915 } |
922 | 916 |
923 } // namespace views | 917 } // namespace views |
OLD | NEW |