| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 KeyEvent keyev3(event); | 51 KeyEvent keyev3(event); |
| 52 EXPECT_EQ(10, keyev3.GetCharacter()); | 52 EXPECT_EQ(10, keyev3.GetCharacter()); |
| 53 | 53 |
| 54 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, EF_NONE); | 54 event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, EF_NONE); |
| 55 KeyEvent keyev4(event); | 55 KeyEvent keyev4(event); |
| 56 EXPECT_EQ(13, keyev4.GetCharacter()); | 56 EXPECT_EQ(13, keyev4.GetCharacter()); |
| 57 #endif | 57 #endif |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST(EventTest, ClickCount) { | 60 TEST(EventTest, ClickCount) { |
| 61 const gfx::Point origin(0, 0); | 61 const gfx::PointF origin; |
| 62 MouseEvent mouseev(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, 0); | 62 MouseEvent mouseev(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, 0); |
| 63 for (int i = 1; i <=3 ; ++i) { | 63 for (int i = 1; i <=3 ; ++i) { |
| 64 mouseev.SetClickCount(i); | 64 mouseev.SetClickCount(i); |
| 65 EXPECT_EQ(i, mouseev.GetClickCount()); | 65 EXPECT_EQ(i, mouseev.GetClickCount()); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 TEST(EventTest, RepeatedClick) { | 69 TEST(EventTest, RepeatedClick) { |
| 70 const gfx::Point origin(0, 0); | 70 const gfx::PointF origin; |
| 71 MouseEvent mouse_ev1(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, | 71 MouseEvent mouse_ev1(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, |
| 72 0); | 72 0); |
| 73 MouseEvent mouse_ev2(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, | 73 MouseEvent mouse_ev2(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), 0, |
| 74 0); | 74 0); |
| 75 LocatedEventTestApi test_ev1(&mouse_ev1); | 75 LocatedEventTestApi test_ev1(&mouse_ev1); |
| 76 LocatedEventTestApi test_ev2(&mouse_ev2); | 76 LocatedEventTestApi test_ev2(&mouse_ev2); |
| 77 | 77 |
| 78 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); | 78 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); |
| 79 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1); | 79 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1); |
| 80 base::TimeDelta later = start + base::TimeDelta::FromMilliseconds(1000); | 80 base::TimeDelta later = start + base::TimeDelta::FromMilliseconds(1000); |
| 81 | 81 |
| 82 // Same event. | 82 // Same event. |
| 83 test_ev1.set_location(gfx::Point(0, 0)); | 83 test_ev1.set_location(gfx::PointF()); |
| 84 test_ev2.set_location(gfx::Point(1, 0)); | 84 test_ev2.set_location(gfx::PointF(1.f, 0.f)); |
| 85 test_ev1.set_time_stamp(start); | 85 test_ev1.set_time_stamp(start); |
| 86 test_ev2.set_time_stamp(start); | 86 test_ev2.set_time_stamp(start); |
| 87 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); | 87 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); |
| 88 MouseEvent mouse_ev3(mouse_ev1); | 88 MouseEvent mouse_ev3(mouse_ev1); |
| 89 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev3)); | 89 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev3)); |
| 90 | 90 |
| 91 // Close point. | 91 // Close point. |
| 92 test_ev1.set_location(gfx::Point(0, 0)); | 92 test_ev1.set_location(gfx::PointF()); |
| 93 test_ev2.set_location(gfx::Point(1, 0)); | 93 test_ev2.set_location(gfx::PointF(1.f, 0.f)); |
| 94 test_ev1.set_time_stamp(start); | 94 test_ev1.set_time_stamp(start); |
| 95 test_ev2.set_time_stamp(soon); | 95 test_ev2.set_time_stamp(soon); |
| 96 EXPECT_TRUE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); | 96 EXPECT_TRUE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); |
| 97 | 97 |
| 98 // Too far. | 98 // Too far. |
| 99 test_ev1.set_location(gfx::Point(0, 0)); | 99 test_ev1.set_location(gfx::PointF()); |
| 100 test_ev2.set_location(gfx::Point(10, 0)); | 100 test_ev2.set_location(gfx::PointF(10.f, 0.f)); |
| 101 test_ev1.set_time_stamp(start); | 101 test_ev1.set_time_stamp(start); |
| 102 test_ev2.set_time_stamp(soon); | 102 test_ev2.set_time_stamp(soon); |
| 103 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); | 103 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); |
| 104 | 104 |
| 105 // Too long a time between clicks. | 105 // Too long a time between clicks. |
| 106 test_ev1.set_location(gfx::Point(0, 0)); | 106 test_ev1.set_location(gfx::PointF()); |
| 107 test_ev2.set_location(gfx::Point(0, 0)); | 107 test_ev2.set_location(gfx::PointF()); |
| 108 test_ev1.set_time_stamp(start); | 108 test_ev1.set_time_stamp(start); |
| 109 test_ev2.set_time_stamp(later); | 109 test_ev2.set_time_stamp(later); |
| 110 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); | 110 EXPECT_FALSE(MouseEvent::IsRepeatedClickEvent(mouse_ev1, mouse_ev2)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Tests that an event only increases the click count and gets marked as a | 113 // Tests that an event only increases the click count and gets marked as a |
| 114 // double click if a release event was seen for the previous click. This | 114 // double click if a release event was seen for the previous click. This |
| 115 // prevents the same PRESSED event from being processed twice: | 115 // prevents the same PRESSED event from being processed twice: |
| 116 // http://crbug.com/389162 | 116 // http://crbug.com/389162 |
| 117 TEST(EventTest, DoubleClickRequiresRelease) { | 117 TEST(EventTest, DoubleClickRequiresRelease) { |
| 118 const gfx::Point origin1(0, 0); | 118 const gfx::PointF origin1; |
| 119 const gfx::Point origin2(100, 0); | 119 const gfx::PointF origin2(100.f, 0.f); |
| 120 scoped_ptr<MouseEvent> ev; | 120 scoped_ptr<MouseEvent> ev; |
| 121 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); | 121 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); |
| 122 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1); | 122 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1); |
| 123 | 123 |
| 124 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, EventTimeForNow(), | 124 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, EventTimeForNow(), |
| 125 0, 0)); | 125 0, 0)); |
| 126 ev->set_time_stamp(start); | 126 ev->set_time_stamp(start); |
| 127 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); | 127 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); |
| 128 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, EventTimeForNow(), | 128 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin1, origin1, EventTimeForNow(), |
| 129 0, 0)); | 129 0, 0)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 145 ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, | 145 ev.reset(new MouseEvent(ET_MOUSE_RELEASED, origin2, origin2, |
| 146 EventTimeForNow(), 0, 0)); | 146 EventTimeForNow(), 0, 0)); |
| 147 ev->set_time_stamp(soon); | 147 ev->set_time_stamp(soon); |
| 148 EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev)); | 148 EXPECT_EQ(2, MouseEvent::GetRepeatCount(*ev)); |
| 149 MouseEvent::ResetLastClickForTest(); | 149 MouseEvent::ResetLastClickForTest(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Tests that clicking right and then left clicking does not generate a double | 152 // Tests that clicking right and then left clicking does not generate a double |
| 153 // click. | 153 // click. |
| 154 TEST(EventTest, SingleClickRightLeft) { | 154 TEST(EventTest, SingleClickRightLeft) { |
| 155 const gfx::Point origin(0, 0); | 155 const gfx::PointF origin; |
| 156 scoped_ptr<MouseEvent> ev; | 156 scoped_ptr<MouseEvent> ev; |
| 157 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); | 157 base::TimeDelta start = base::TimeDelta::FromMilliseconds(0); |
| 158 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1); | 158 base::TimeDelta soon = start + base::TimeDelta::FromMilliseconds(1); |
| 159 | 159 |
| 160 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), | 160 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), |
| 161 ui::EF_RIGHT_MOUSE_BUTTON, | 161 ui::EF_RIGHT_MOUSE_BUTTON, |
| 162 ui::EF_RIGHT_MOUSE_BUTTON)); | 162 ui::EF_RIGHT_MOUSE_BUTTON)); |
| 163 ev->set_time_stamp(start); | 163 ev->set_time_stamp(start); |
| 164 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); | 164 EXPECT_EQ(1, MouseEvent::GetRepeatCount(*ev)); |
| 165 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), | 165 ev.reset(new MouseEvent(ET_MOUSE_PRESSED, origin, origin, EventTimeForNow(), |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 540 } |
| 541 #endif | 541 #endif |
| 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::PointF(), 0, 0, time, |
| 551 non_zero_length1, 0, 0, 0); | 551 non_zero_length1, 0, 0, 0); |
| 552 EXPECT_EQ(non_zero_length1, event1.pointer_details().radius_x()); | 552 EXPECT_EQ(non_zero_length1, event1.pointer_details().radius_x()); |
| 553 EXPECT_EQ(non_zero_length1, event1.pointer_details().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::PointF(), 0, 0, time, 0, |
| 556 0, non_zero_length2, 0, 0); | 556 non_zero_length2, 0, 0); |
| 557 EXPECT_EQ(non_zero_length2, event2.pointer_details().radius_x()); | 557 EXPECT_EQ(non_zero_length2, event2.pointer_details().radius_x()); |
| 558 EXPECT_EQ(non_zero_length2, event2.pointer_details().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::PointF(), 0, 0, time, radius_x, |
| 569 radius_x, radius_y, angle_in_range, 0); | 569 radius_y, angle_in_range, 0); |
| 570 EXPECT_FLOAT_EQ(angle_in_range, event.rotation_angle()); | 570 EXPECT_FLOAT_EQ(angle_in_range, event.rotation_angle()); |
| 571 } | 571 } |
| 572 | 572 |
| 573 { | 573 { |
| 574 const float angle_in_range = 179.9f; | 574 const float angle_in_range = 179.9f; |
| 575 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 575 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::PointF(), 0, 0, time, radius_x, |
| 576 radius_x, radius_y, angle_in_range, 0); | 576 radius_y, angle_in_range, 0); |
| 577 EXPECT_FLOAT_EQ(angle_in_range, event.rotation_angle()); | 577 EXPECT_FLOAT_EQ(angle_in_range, event.rotation_angle()); |
| 578 } | 578 } |
| 579 | 579 |
| 580 { | 580 { |
| 581 const float angle_negative = -0.1f; | 581 const float angle_negative = -0.1f; |
| 582 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 582 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::PointF(), 0, 0, time, radius_x, |
| 583 radius_x, radius_y, angle_negative, 0); | 583 radius_y, angle_negative, 0); |
| 584 EXPECT_FLOAT_EQ(180 - 0.1f, event.rotation_angle()); | 584 EXPECT_FLOAT_EQ(180 - 0.1f, event.rotation_angle()); |
| 585 } | 585 } |
| 586 | 586 |
| 587 { | 587 { |
| 588 const float angle_negative = -200; | 588 const float angle_negative = -200; |
| 589 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 589 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::PointF(), 0, 0, time, radius_x, |
| 590 radius_x, radius_y, angle_negative, 0); | 590 radius_y, angle_negative, 0); |
| 591 EXPECT_FLOAT_EQ(360 - 200, event.rotation_angle()); | 591 EXPECT_FLOAT_EQ(360 - 200, event.rotation_angle()); |
| 592 } | 592 } |
| 593 | 593 |
| 594 { | 594 { |
| 595 const float angle_too_big = 180; | 595 const float angle_too_big = 180; |
| 596 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 596 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::PointF(), 0, 0, time, radius_x, |
| 597 radius_x, radius_y, angle_too_big, 0); | 597 radius_y, angle_too_big, 0); |
| 598 EXPECT_FLOAT_EQ(0, event.rotation_angle()); | 598 EXPECT_FLOAT_EQ(0, event.rotation_angle()); |
| 599 } | 599 } |
| 600 | 600 |
| 601 { | 601 { |
| 602 const float angle_too_big = 400; | 602 const float angle_too_big = 400; |
| 603 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0, time, | 603 TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::PointF(), 0, 0, time, radius_x, |
| 604 radius_x, radius_y, angle_too_big, 0); | 604 radius_y, angle_too_big, 0); |
| 605 EXPECT_FLOAT_EQ(400 - 360, event.rotation_angle()); | 605 EXPECT_FLOAT_EQ(400 - 360, event.rotation_angle()); |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 TEST(EventTest, PointerEventDetailsTouch) { | 609 TEST(EventTest, PointerEventDetailsTouch) { |
| 610 ui::TouchEvent touch_event_plain(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, | 610 ui::TouchEvent touch_event_plain(ET_TOUCH_PRESSED, gfx::PointF(), 0, |
| 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 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::PointF(), 0, 0, |
| 622 0, ui::EventTimeForNow(), 10.0f, 5.0f, | 622 ui::EventTimeForNow(), 10.0f, 5.0f, |
| 623 0.0f, 15.0f); | 623 0.0f, 15.0f); |
| 624 | 624 |
| 625 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, | 625 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, |
| 626 touch_event_with_details.pointer_details().pointer_type()); | 626 touch_event_with_details.pointer_details().pointer_type()); |
| 627 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()); |
| 628 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()); |
| 629 EXPECT_EQ(15.0f, touch_event_with_details.pointer_details().force()); | 629 EXPECT_EQ(15.0f, touch_event_with_details.pointer_details().force()); |
| 630 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()); |
| 631 EXPECT_EQ(0.0f, touch_event_with_details.pointer_details().tilt_y()); | 631 EXPECT_EQ(0.0f, touch_event_with_details.pointer_details().tilt_y()); |
| 632 | 632 |
| 633 ui::TouchEvent touch_event_copy(touch_event_with_details); | 633 ui::TouchEvent touch_event_copy(touch_event_with_details); |
| 634 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, | 634 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, |
| 635 touch_event_copy.pointer_details().pointer_type()); | 635 touch_event_copy.pointer_details().pointer_type()); |
| 636 EXPECT_EQ(10.0f, touch_event_copy.pointer_details().radius_x()); | 636 EXPECT_EQ(10.0f, touch_event_copy.pointer_details().radius_x()); |
| 637 EXPECT_EQ(5.0f, touch_event_copy.pointer_details().radius_y()); | 637 EXPECT_EQ(5.0f, touch_event_copy.pointer_details().radius_y()); |
| 638 EXPECT_EQ(15.0f, touch_event_copy.pointer_details().force()); | 638 EXPECT_EQ(15.0f, touch_event_copy.pointer_details().force()); |
| 639 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_x()); | 639 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_x()); |
| 640 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_y()); | 640 EXPECT_EQ(0.0f, touch_event_copy.pointer_details().tilt_y()); |
| 641 } | 641 } |
| 642 | 642 |
| 643 TEST(EventTest, PointerEventDetailsMouse) { | 643 TEST(EventTest, PointerEventDetailsMouse) { |
| 644 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::PointF(0, 0), | 644 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::PointF(), gfx::PointF(), |
| 645 gfx::PointF(0, 0), ui::EventTimeForNow(), 0, 0); | 645 ui::EventTimeForNow(), 0, 0); |
| 646 | 646 |
| 647 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, | 647 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, |
| 648 mouse_event.pointer_details().pointer_type()); | 648 mouse_event.pointer_details().pointer_type()); |
| 649 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x()); | 649 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x()); |
| 650 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y()); | 650 EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y()); |
| 651 EXPECT_EQ(0.0f, mouse_event.pointer_details().force()); | 651 EXPECT_EQ(0.0f, mouse_event.pointer_details().force()); |
| 652 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x()); | 652 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_x()); |
| 653 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y()); | 653 EXPECT_EQ(0.0f, mouse_event.pointer_details().tilt_y()); |
| 654 | 654 |
| 655 ui::MouseEvent mouse_event_copy(mouse_event); | 655 ui::MouseEvent mouse_event_copy(mouse_event); |
| 656 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, | 656 EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE, |
| 657 mouse_event_copy.pointer_details().pointer_type()); | 657 mouse_event_copy.pointer_details().pointer_type()); |
| 658 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x()); | 658 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_x()); |
| 659 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y()); | 659 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().radius_y()); |
| 660 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().force()); | 660 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().force()); |
| 661 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x()); | 661 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_x()); |
| 662 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y()); | 662 EXPECT_EQ(0.0f, mouse_event_copy.pointer_details().tilt_y()); |
| 663 } | 663 } |
| 664 | 664 |
| 665 TEST(EventTest, PointerEventDetailsStylus) { | 665 TEST(EventTest, PointerEventDetailsStylus) { |
| 666 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::PointF(0, 0), | 666 ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::PointF(), gfx::PointF(), |
| 667 gfx::PointF(0, 0), ui::EventTimeForNow(), 0, 0); | 667 ui::EventTimeForNow(), 0, 0); |
| 668 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, | 668 ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, |
| 669 /* radius_x */ 0.0f, | 669 /* radius_x */ 0.0f, |
| 670 /* radius_y */ 0.0f, | 670 /* radius_y */ 0.0f, |
| 671 /* force */ 21.0f, | 671 /* force */ 21.0f, |
| 672 /* tilt_x */ 45.0f, | 672 /* tilt_x */ 45.0f, |
| 673 /* tilt_y */ -45.0f); | 673 /* tilt_y */ -45.0f); |
| 674 | 674 |
| 675 stylus_event.set_pointer_details(pointer_details); | 675 stylus_event.set_pointer_details(pointer_details); |
| 676 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 676 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 677 stylus_event.pointer_details().pointer_type()); | 677 stylus_event.pointer_details().pointer_type()); |
| 678 EXPECT_EQ(21.0f, stylus_event.pointer_details().force()); | 678 EXPECT_EQ(21.0f, stylus_event.pointer_details().force()); |
| 679 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x()); | 679 EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x()); |
| 680 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y()); | 680 EXPECT_EQ(-45.0f, stylus_event.pointer_details().tilt_y()); |
| 681 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x()); | 681 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_x()); |
| 682 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y()); | 682 EXPECT_EQ(0.0f, stylus_event.pointer_details().radius_y()); |
| 683 | 683 |
| 684 ui::MouseEvent stylus_event_copy(stylus_event); | 684 ui::MouseEvent stylus_event_copy(stylus_event); |
| 685 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, | 685 EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN, |
| 686 stylus_event_copy.pointer_details().pointer_type()); | 686 stylus_event_copy.pointer_details().pointer_type()); |
| 687 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); | 687 EXPECT_EQ(21.0f, stylus_event_copy.pointer_details().force()); |
| 688 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); | 688 EXPECT_EQ(45.0f, stylus_event_copy.pointer_details().tilt_x()); |
| 689 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); | 689 EXPECT_EQ(-45.0f, stylus_event_copy.pointer_details().tilt_y()); |
| 690 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); | 690 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_x()); |
| 691 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); | 691 EXPECT_EQ(0.0f, stylus_event_copy.pointer_details().radius_y()); |
| 692 } | 692 } |
| 693 | 693 |
| 694 } // namespace ui | 694 } // namespace ui |
| OLD | NEW |