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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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/events/event_utils.h" 10 #include "ui/events/event_utils.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 columns[1].sortable = true; 191 columns[1].sortable = true;
192 table_ = new TestTableView(model_.get(), columns); 192 table_ = new TestTableView(model_.get(), columns);
193 parent_.reset(table_->CreateParentIfNecessary()); 193 parent_.reset(table_->CreateParentIfNecessary());
194 parent_->SetBounds(0, 0, 10000, 10000); 194 parent_->SetBounds(0, 0, 10000, 10000);
195 parent_->Layout(); 195 parent_->Layout();
196 helper_.reset(new TableViewTestHelper(table_)); 196 helper_.reset(new TableViewTestHelper(table_));
197 } 197 }
198 198
199 void ClickOnRow(int row, int flags) { 199 void ClickOnRow(int row, int flags) {
200 const int y = row * table_->row_height(); 200 const int y = row * table_->row_height();
201 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(0, y), 201 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::PointF(0.f, y),
202 gfx::Point(0, y), ui::EventTimeForNow(), 202 gfx::PointF(0.f, y), ui::EventTimeForNow(),
203 ui::EF_LEFT_MOUSE_BUTTON | flags, 203 ui::EF_LEFT_MOUSE_BUTTON | flags,
204 ui::EF_LEFT_MOUSE_BUTTON); 204 ui::EF_LEFT_MOUSE_BUTTON);
205 table_->OnMousePressed(pressed); 205 table_->OnMousePressed(pressed);
206 } 206 }
207 207
208 void TapOnRow(int row) { 208 void TapOnRow(int row) {
209 const int y = row * table_->row_height(); 209 const int y = row * table_->row_height();
210 const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP); 210 const ui::GestureEventDetails event_details(ui::ET_GESTURE_TAP);
211 ui::GestureEvent tap(0, y, 0, base::TimeDelta(), event_details); 211 ui::GestureEvent tap(0, y, 0, base::TimeDelta(), event_details);
212 table_->OnGestureEvent(&tap); 212 table_->OnGestureEvent(&tap);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 EXPECT_EQ(1, table_->visible_columns()[0].column.id); 289 EXPECT_EQ(1, table_->visible_columns()[0].column.id);
290 EXPECT_EQ(0, table_->visible_columns()[1].column.id); 290 EXPECT_EQ(0, table_->visible_columns()[1].column.id);
291 EXPECT_EQ("rows=0 4 cols=0 2", helper_->GetPaintRegion(table_->bounds())); 291 EXPECT_EQ("rows=0 4 cols=0 2", helper_->GetPaintRegion(table_->bounds()));
292 } 292 }
293 293
294 // Verifies resizing a column works. 294 // Verifies resizing a column works.
295 TEST_F(TableViewTest, Resize) { 295 TEST_F(TableViewTest, Resize) {
296 const int x = table_->visible_columns()[0].width; 296 const int x = table_->visible_columns()[0].width;
297 EXPECT_NE(0, x); 297 EXPECT_NE(0, x);
298 // Drag the mouse 1 pixel to the left. 298 // Drag the mouse 1 pixel to the left.
299 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(x, 0), 299 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::PointF(x, 0.f),
300 gfx::Point(x, 0), ui::EventTimeForNow(), 300 gfx::PointF(x, 0.f), ui::EventTimeForNow(),
301 ui::EF_LEFT_MOUSE_BUTTON, 301 ui::EF_LEFT_MOUSE_BUTTON,
302 ui::EF_LEFT_MOUSE_BUTTON); 302 ui::EF_LEFT_MOUSE_BUTTON);
303 helper_->header()->OnMousePressed(pressed); 303 helper_->header()->OnMousePressed(pressed);
304 const ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, gfx::Point(x - 1, 0), 304 const ui::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, gfx::PointF(x - 1.f, 0.f),
305 gfx::Point(x - 1, 0), ui::EventTimeForNow(), 305 gfx::PointF(x - 1.f, 0.f), ui::EventTimeForNow(),
306 ui::EF_LEFT_MOUSE_BUTTON, 0); 306 ui::EF_LEFT_MOUSE_BUTTON, 0);
307 helper_->header()->OnMouseDragged(dragged); 307 helper_->header()->OnMouseDragged(dragged);
308 308
309 // This should shrink the first column and pull the second column in. 309 // This should shrink the first column and pull the second column in.
310 EXPECT_EQ(x - 1, table_->visible_columns()[0].width); 310 EXPECT_EQ(x - 1, table_->visible_columns()[0].width);
311 EXPECT_EQ(x - 1, table_->visible_columns()[1].x); 311 EXPECT_EQ(x - 1, table_->visible_columns()[1].x);
312 } 312 }
313 313
314 // Verifies resizing a column works with a gesture. 314 // Verifies resizing a column works with a gesture.
315 TEST_F(TableViewTest, ResizeViaGesture) { 315 TEST_F(TableViewTest, ResizeViaGesture) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 EXPECT_EQ("3 1 2 0", GetModelToViewAsString(table_)); 387 EXPECT_EQ("3 1 2 0", GetModelToViewAsString(table_));
388 } 388 }
389 389
390 // Verfies clicking on the header sorts. 390 // Verfies clicking on the header sorts.
391 TEST_F(TableViewTest, SortOnMouse) { 391 TEST_F(TableViewTest, SortOnMouse) {
392 EXPECT_TRUE(table_->sort_descriptors().empty()); 392 EXPECT_TRUE(table_->sort_descriptors().empty());
393 393
394 const int x = table_->visible_columns()[0].width / 2; 394 const int x = table_->visible_columns()[0].width / 2;
395 EXPECT_NE(0, x); 395 EXPECT_NE(0, x);
396 // Press and release the mouse. 396 // Press and release the mouse.
397 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(x, 0), 397 const ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::PointF(x, 0.f),
398 gfx::Point(x, 0), ui::EventTimeForNow(), 398 gfx::PointF(x, 0.f), ui::EventTimeForNow(),
399 ui::EF_LEFT_MOUSE_BUTTON, 399 ui::EF_LEFT_MOUSE_BUTTON,
400 ui::EF_LEFT_MOUSE_BUTTON); 400 ui::EF_LEFT_MOUSE_BUTTON);
401 // The header must return true, else it won't normally get the release. 401 // The header must return true, else it won't normally get the release.
402 EXPECT_TRUE(helper_->header()->OnMousePressed(pressed)); 402 EXPECT_TRUE(helper_->header()->OnMousePressed(pressed));
403 const ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(x, 0), 403 const ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::PointF(x, 0.f),
404 gfx::Point(x, 0), ui::EventTimeForNow(), 404 gfx::PointF(x, 0.f), ui::EventTimeForNow(),
405 ui::EF_LEFT_MOUSE_BUTTON, 405 ui::EF_LEFT_MOUSE_BUTTON,
406 ui::EF_LEFT_MOUSE_BUTTON); 406 ui::EF_LEFT_MOUSE_BUTTON);
407 helper_->header()->OnMouseReleased(release); 407 helper_->header()->OnMouseReleased(release);
408 408
409 ASSERT_EQ(1u, table_->sort_descriptors().size()); 409 ASSERT_EQ(1u, table_->sort_descriptors().size());
410 EXPECT_EQ(0, table_->sort_descriptors()[0].column_id); 410 EXPECT_EQ(0, table_->sort_descriptors()[0].column_id);
411 EXPECT_TRUE(table_->sort_descriptors()[0].ascending); 411 EXPECT_TRUE(table_->sort_descriptors()[0].ascending);
412 } 412 }
413 413
414 namespace { 414 namespace {
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 new_selection.AddIndexToSelection(0); 861 new_selection.AddIndexToSelection(0);
862 new_selection.AddIndexToSelection(1); 862 new_selection.AddIndexToSelection(1);
863 new_selection.set_active(0); 863 new_selection.set_active(0);
864 new_selection.set_anchor(0); 864 new_selection.set_anchor(0);
865 helper_->SetSelectionModel(new_selection); 865 helper_->SetSelectionModel(new_selection);
866 model_->RemoveRow(0); 866 model_->RemoveRow(0);
867 helper_->OnFocus(); 867 helper_->OnFocus();
868 } 868 }
869 869
870 } // namespace views 870 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698