Chromium Code Reviews| 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 "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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, | 635 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, |
| 636 touch_event_copy.pointer_details().pointer_type()); | 636 touch_event_copy.pointer_details().pointer_type()); |
| 637 EXPECT_EQ(10.0f, touch_event_copy.pointer_details().radius_x()); | 637 EXPECT_EQ(10.0f, touch_event_copy.pointer_details().radius_x()); |
| 638 EXPECT_EQ(5.0f, touch_event_copy.pointer_details().radius_y()); | 638 EXPECT_EQ(5.0f, touch_event_copy.pointer_details().radius_y()); |
| 639 EXPECT_EQ(15.0f, touch_event_copy.pointer_details().force()); | 639 EXPECT_EQ(15.0f, touch_event_copy.pointer_details().force()); |
| 640 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_x()); | 640 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_x()); |
| 641 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_y()); | 641 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_y()); |
| 642 } | 642 } |
| 643 | 643 |
| 644 TEST(EventTest, PointerEventDetailsMouse) { | 644 TEST(EventTest, PointerEventDetailsMouse) { |
| 645 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::PointF(0, 0), | 645 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), |
|
sky
2015/10/30 22:20:44
0,0 is synonymous with gfx::Point()
danakj
2015/10/30 22:39:45
Ya, it is. vmpstr recently convinced me that writi
| |
| 646 gfx::PointF(0, 0), ui::EventTimeForNow(), 0, 0); | 646 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); |
| 647 | 647 |
| 648 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, | 648 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, |
| 649 mouse_event.pointer_details().pointer_type()); | 649 mouse_event.pointer_details().pointer_type()); |
| 650 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x()); | 650 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x()); |
| 651 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y()); | 651 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y()); |
| 652 EXPECT_EQ(0.0f, mouse_event.pointer_details().force()); | 652 EXPECT_EQ(0.0f, mouse_event.pointer_details().force()); |
| 653 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x()); | 653 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x()); |
| 654 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y()); | 654 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y()); |
| 655 | 655 |
| 656 ui::MouseEvent mouse_event_copy(mouse_event); | 656 ui::MouseEvent mouse_event_copy(mouse_event); |
| 657 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, | 657 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, |
| 658 mouse_event_copy.pointer_details().pointer_type()); | 658 mouse_event_copy.pointer_details().pointer_type()); |
| 659 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x()); | 659 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x()); |
| 660 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y()); | 660 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y()); |
| 661 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().force()); | 661 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().force()); |
| 662 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x()); | 662 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x()); |
| 663 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y()); | 663 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y()); |
| 664 } | 664 } |
| 665 | 665 |
| 666 TEST(EventTest, PointerEventDetailsStylus) { | 666 TEST(EventTest, PointerEventDetailsStylus) { |
| 667 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::PointF(0, 0), | 667 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), |
| 668 gfx::PointF(0, 0), ui::EventTimeForNow(), 0, 0); | 668 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); |
| 669 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 669 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
| 670 /* radius_x */ 0.0f, | 670 /* radius_x */ 0.0f, |
| 671 /* radius_y */ 0.0f, | 671 /* radius_y */ 0.0f, |
| 672 /* force */ 21.0f, | 672 /* force */ 21.0f, |
| 673 /* tilt_x */ 45.0f, | 673 /* tilt_x */ 45.0f, |
| 674 /* tilt_y */ -45.0f); | 674 /* tilt_y */ -45.0f); |
| 675 | 675 |
| 676 stylus_event.set_pointer_details(pointer_details); | 676 stylus_event.set_pointer_details(pointer_details); |
| 677 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 677 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 678 stylus_event.pointer_details().pointer_type()); | 678 stylus_event.pointer_details().pointer_type()); |
| 679 EXPECT_EQ(21.0f, stylus_event.pointer_details().force()); | 679 EXPECT_EQ(21.0f, stylus_event.pointer_details().force()); |
| 680 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x()); | 680 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x()); |
| 681 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y()); | 681 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y()); |
| 682 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x()); | 682 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x()); |
| 683 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y()); | 683 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y()); |
| 684 | 684 |
| 685 ui::MouseEvent stylus_event_copy(stylus_event); | 685 ui::MouseEvent stylus_event_copy(stylus_event); |
| 686 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 686 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 687 stylus_event_copy.pointer_details().pointer_type()); | 687 stylus_event_copy.pointer_details().pointer_type()); |
| 688 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); | 688 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); |
| 689 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); | 689 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); |
| 690 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); | 690 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); |
| 691 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); | 691 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); |
| 692 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); | 692 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); |
| 693 } | 693 } |
| 694 | 694 |
| 695 } // namespace ui | 695 } // namespace ui |
| OLD | NEW |