| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 } | 618 } |
| 619 | 619 |
| 620 TEST(EventTest, PointerEventDetailsTouch) { | 620 TEST(EventTest, PointerEventDetailsTouch) { |
| 621 ui::TouchEvent touch_event_plain(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, | 621 ui::TouchEvent touch_event_plain(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, |
| 622 ui::EventTimeForNow()); | 622 ui::EventTimeForNow()); |
| 623 | 623 |
| 624 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, | 624 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, |
| 625 touch_event_plain.pointer_details().pointer_type()); | 625 touch_event_plain.pointer_details().pointer_type()); |
| 626 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_x()); | 626 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_x()); |
| 627 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_y()); | 627 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_y()); |
| 628 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().force()); | 628 EXPECT_TRUE(isnan(touch_event_plain.pointer_details().force())); |
| 629 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_x()); | 629 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_x()); |
| 630 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_y()); | 630 EXPECT_EQ(0.0f, touch_event_plain.pointer_details().tilt_y()); |
| 631 | 631 |
| 632 ui::TouchEvent touch_event_with_details(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, | 632 ui::TouchEvent touch_event_with_details(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, |
| 633 0, ui::EventTimeForNow(), 10.0f, 5.0f, | 633 0, ui::EventTimeForNow(), 10.0f, 5.0f, |
| 634 0.0f, 15.0f); | 634 0.0f, 15.0f); |
| 635 | 635 |
| 636 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, | 636 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, |
| 637 touch_event_with_details.pointer_details().pointer_type()); | 637 touch_event_with_details.pointer_details().pointer_type()); |
| 638 EXPECT_EQ(10.0f, touch_event_with_details.pointer_details().radius_x()); | 638 EXPECT_EQ(10.0f, touch_event_with_details.pointer_details().radius_x()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 652 } | 652 } |
| 653 | 653 |
| 654 TEST(EventTest, PointerEventDetailsMouse) { | 654 TEST(EventTest, PointerEventDetailsMouse) { |
| 655 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), | 655 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), |
| 656 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); | 656 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); |
| 657 | 657 |
| 658 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, | 658 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, |
| 659 mouse_event.pointer_details().pointer_type()); | 659 mouse_event.pointer_details().pointer_type()); |
| 660 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x()); | 660 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x()); |
| 661 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y()); | 661 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y()); |
| 662 EXPECT_EQ(0.0f, mouse_event.pointer_details().force()); | 662 EXPECT_TRUE(isnan(mouse_event.pointer_details().force())); |
| 663 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x()); | 663 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x()); |
| 664 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y()); | 664 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y()); |
| 665 | 665 |
| 666 ui::MouseEvent mouse_event_copy(mouse_event); | 666 ui::MouseEvent mouse_event_copy(mouse_event); |
| 667 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, | 667 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, |
| 668 mouse_event_copy.pointer_details().pointer_type()); | 668 mouse_event_copy.pointer_details().pointer_type()); |
| 669 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x()); | 669 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x()); |
| 670 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y()); | 670 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y()); |
| 671 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().force()); | 671 EXPECT_TRUE(isnan(mouse_event_copy.pointer_details().force())); |
| 672 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x()); | 672 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x()); |
| 673 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y()); | 673 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y()); |
| 674 } | 674 } |
| 675 | 675 |
| 676 TEST(EventTest, PointerEventDetailsStylus) { | 676 TEST(EventTest, PointerEventDetailsStylus) { |
| 677 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), | 677 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), |
| 678 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); | 678 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); |
| 679 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 679 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
| 680 /* radius_x */ 0.0f, | 680 /* radius_x */ 0.0f, |
| 681 /* radius_y */ 0.0f, | 681 /* radius_y */ 0.0f, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 696 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 696 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 697 stylus_event_copy.pointer_details().pointer_type()); | 697 stylus_event_copy.pointer_details().pointer_type()); |
| 698 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); | 698 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); |
| 699 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); | 699 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); |
| 700 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); | 700 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); |
| 701 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); | 701 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); |
| 702 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); | 702 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); |
| 703 } | 703 } |
| 704 | 704 |
| 705 } // namespace ui | 705 } // namespace ui |
| OLD | NEW |