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

Side by Side Diff: ui/events/event_unittest.cc

Issue 1300803003: Drop ui::TouchEvent shims for radius_{x,y} and force (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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
« no previous file with comments | « ui/events/event.h ('k') | ui/events/gestures/motion_event_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/events/event.h" 7 #include "ui/events/event.h"
8 #include "ui/events/event_utils.h" 8 #include "ui/events/event_utils.h"
9 #include "ui/events/keycodes/dom/dom_code.h" 9 #include "ui/events/keycodes/dom/dom_code.h"
10 #include "ui/events/keycodes/dom/keycode_converter.h" 10 #include "ui/events/keycodes/dom/keycode_converter.h"
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 542 }
543 #endif // USE_X11 || OS_WIN 543 #endif // USE_X11 || OS_WIN
544 544
545 TEST(EventTest, TouchEventRadiusDefaultsToOtherAxis) { 545 TEST(EventTest, TouchEventRadiusDefaultsToOtherAxis) {
546 const base::TimeDelta time = base::TimeDelta::FromMilliseconds(0); 546 const base::TimeDelta time = base::TimeDelta::FromMilliseconds(0);
547 const float non_zero_length1 = 30; 547 const float non_zero_length1 = 30;
548 const float non_zero_length2 = 46; 548 const float non_zero_length2 = 46;
549 549
550 TouchEvent event1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, 550 TouchEvent event1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time,
551 non_zero_length1, 0, 0, 0); 551 non_zero_length1, 0, 0, 0);
552 EXPECT_EQ(non_zero_length1, event1.radius_x()); 552 EXPECT_EQ(non_zero_length1, event1.pointer_details().radius_x());
553 EXPECT_EQ(non_zero_length1, event1.radius_y()); 553 EXPECT_EQ(non_zero_length1, event1.pointer_details().radius_y());
554 554
555 TouchEvent event2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, 555 TouchEvent event2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time,
556 0, non_zero_length2, 0, 0); 556 0, non_zero_length2, 0, 0);
557 EXPECT_EQ(non_zero_length2, event2.radius_x()); 557 EXPECT_EQ(non_zero_length2, event2.pointer_details().radius_x());
558 EXPECT_EQ(non_zero_length2, event2.radius_y()); 558 EXPECT_EQ(non_zero_length2, event2.pointer_details().radius_y());
559 } 559 }
560 560
561 TEST(EventTest, TouchEventRotationAngleFixing) { 561 TEST(EventTest, TouchEventRotationAngleFixing) {
562 const base::TimeDelta time = base::TimeDelta::FromMilliseconds(0); 562 const base::TimeDelta time = base::TimeDelta::FromMilliseconds(0);
563 const float radius_x = 20; 563 const float radius_x = 20;
564 const float radius_y = 10; 564 const float radius_y = 10;
565 565
566 { 566 {
567 const float angle_in_range = 0; 567 const float angle_in_range = 0;
568 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, 568 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 ui::EventTimeForNow()); 611 ui::EventTimeForNow());
612 612
613 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, 613 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
614 touch_event_plain.pointer_details().pointer_type()); 614 touch_event_plain.pointer_details().pointer_type());
615 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_x()); 615 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_x());
616 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_y()); 616 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_y());
617 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().force()); 617 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().force());
618 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_x()); 618 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_x());
619 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_y()); 619 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_y());
620 620
621 EXPECT_EQ(0.0f, touch_event_plain.radius_x());
622 EXPECT_EQ(0.0f, touch_event_plain.radius_y());
623 EXPECT_EQ(0.0f, touch_event_plain.force());
624
625 ui::TouchEvent touch_event_with_details(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 621 ui::TouchEvent touch_event_with_details(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0,
626 0, ui::EventTimeForNow(), 10.0f, 5.0f, 622 0, ui::EventTimeForNow(), 10.0f, 5.0f,
627 0.0f, 15.0f); 623 0.0f, 15.0f);
628 624
629 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, 625 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
630 touch_event_with_details.pointer_details().pointer_type()); 626 touch_event_with_details.pointer_details().pointer_type());
631 EXPECT_EQ(10.0f, touch_event_with_details.pointer_details().radius_x()); 627 EXPECT_EQ(10.0f, touch_event_with_details.pointer_details().radius_x());
632 EXPECT_EQ(5.0f, touch_event_with_details.pointer_details().radius_y()); 628 EXPECT_EQ(5.0f, touch_event_with_details.pointer_details().radius_y());
633 EXPECT_EQ(15.0f, touch_event_with_details.pointer_details().force()); 629 EXPECT_EQ(15.0f, touch_event_with_details.pointer_details().force());
634 EXPECT_EQ(0.0f, touch_event_with_details.pointer_details().tilt_x()); 630 EXPECT_EQ(0.0f, touch_event_with_details.pointer_details().tilt_x());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, 685 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
690 stylus_event_copy.pointer_details().pointer_type()); 686 stylus_event_copy.pointer_details().pointer_type());
691 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); 687 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force());
692 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); 688 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x());
693 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); 689 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y());
694 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); 690 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x());
695 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); 691 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y());
696 } 692 }
697 693
698 } // namespace ui 694 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.h ('k') | ui/events/gestures/motion_event_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698