Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: ui/views/controls/table/table_view_unittest.cc

Issue 572593002: Revert of Clean up GestureEventDetails constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/views/controls/table/table_grouper.h" 10 #include "ui/views/controls/table/table_grouper.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 const int y = row * table_->row_height(); 191 const int y = row * table_->row_height();
192 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, y), 192 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, y),
193 gfx::Point(0, y), 193 gfx::Point(0, y),
194 ui::EF_LEFT_MOUSE_BUTTON | flags, 194 ui::EF_LEFT_MOUSE_BUTTON | flags,
195 ui::EF_LEFT_MOUSE_BUTTON); 195 ui::EF_LEFT_MOUSE_BUTTON);
196 table_->OnMousePressed(pressed); 196 table_->OnMousePressed(pressed);
197 } 197 }
198 198
199 void TapOnRow(int row) { 199 void TapOnRow(int row) {
200 const int y = row * table_->row_height(); 200 const int y = row * table_->row_height();
201 const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP); 201 const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP,
202 .0f, .0f);
202 ui::GestureEvent tap(0, y, 0, base::TimeDelta(), event_details); 203 ui::GestureEvent tap(0, y, 0, base::TimeDelta(), event_details);
203 table_->OnGestureEvent(&tap); 204 table_->OnGestureEvent(&tap);
204 } 205 }
205 206
206 // Returns the state of the selection model as a string. The format is: 207 // Returns the state of the selection model as a string. The format is:
207 // 'active=X anchor=X selection=X X X...'. 208 // 'active=X anchor=X selection=X X X...'.
208 std::string SelectionStateAsString() const { 209 std::string SelectionStateAsString() const {
209 const ui::ListSelectionModel& model(table_->selection_model()); 210 const ui::ListSelectionModel& model(table_->selection_model());
210 std::string result = "active=" + base::IntToString(model.active()) + 211 std::string result = "active=" + base::IntToString(model.active()) +
211 " anchor=" + base::IntToString(model.anchor()) + 212 " anchor=" + base::IntToString(model.anchor()) +
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Verifies resizing a column works with a gesture. 305 // Verifies resizing a column works with a gesture.
305 TEST_F(TableViewTest, ResizeViaGesture) { 306 TEST_F(TableViewTest, ResizeViaGesture) {
306 const int x = table_->visible_columns()[0].width; 307 const int x = table_->visible_columns()[0].width;
307 EXPECT_NE(0, x); 308 EXPECT_NE(0, x);
308 // Drag the mouse 1 pixel to the left. 309 // Drag the mouse 1 pixel to the left.
309 ui::GestureEvent scroll_begin( 310 ui::GestureEvent scroll_begin(
310 x, 311 x,
311 0, 312 0,
312 0, 313 0,
313 base::TimeDelta(), 314 base::TimeDelta(),
314 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); 315 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, .0f, .0f));
315 helper_->header()->OnGestureEvent(&scroll_begin); 316 helper_->header()->OnGestureEvent(&scroll_begin);
316 ui::GestureEvent scroll_update( 317 ui::GestureEvent scroll_update(
317 x - 1, 318 x - 1,
318 0, 319 0,
319 0, 320 0,
320 base::TimeDelta(), 321 base::TimeDelta(),
321 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE)); 322 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, .0f, .0f));
322 helper_->header()->OnGestureEvent(&scroll_update); 323 helper_->header()->OnGestureEvent(&scroll_update);
323 324
324 // This should shrink the first column and pull the second column in. 325 // This should shrink the first column and pull the second column in.
325 EXPECT_EQ(x - 1, table_->visible_columns()[0].width); 326 EXPECT_EQ(x - 1, table_->visible_columns()[0].width);
326 EXPECT_EQ(x - 1, table_->visible_columns()[1].x); 327 EXPECT_EQ(x - 1, table_->visible_columns()[1].x);
327 } 328 }
328 329
329 // Assertions for table sorting. 330 // Assertions for table sorting.
330 TEST_F(TableViewTest, Sort) { 331 TEST_F(TableViewTest, Sort) {
331 // Toggle the sort order of the first column, shouldn't change anything. 332 // Toggle the sort order of the first column, shouldn't change anything.
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 837
837 // Extend selection to first row. 838 // Extend selection to first row.
838 ClickOnRow(0, ui::EF_SHIFT_DOWN); 839 ClickOnRow(0, ui::EF_SHIFT_DOWN);
839 EXPECT_EQ(1, observer.GetChangedCountAndClear()); 840 EXPECT_EQ(1, observer.GetChangedCountAndClear());
840 EXPECT_EQ("active=2 anchor=4 selection=2 3 4", SelectionStateAsString()); 841 EXPECT_EQ("active=2 anchor=4 selection=2 3 4", SelectionStateAsString());
841 842
842 table_->SetObserver(NULL); 843 table_->SetObserver(NULL);
843 } 844 }
844 845
845 } // namespace views 846 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button_unittest.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698