| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); | 449 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); |
| 450 | 450 |
| 451 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); | 451 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); |
| 452 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN); | 452 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN); |
| 453 EXPECT_TRUE(event.OnTouch(press1)); | 453 EXPECT_TRUE(event.OnTouch(press1)); |
| 454 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN, event.GetFlags()); | 454 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_DOWN, event.GetFlags()); |
| 455 } | 455 } |
| 456 | 456 |
| 457 // Once crbug.com/446852 is fixed, we should ignore redundant presses. | 457 // Once crbug.com/446852 is fixed, we should ignore redundant presses. |
| 458 TEST(MotionEventAuraTest, DoesntIgnoreRedundantPresses) { | 458 TEST(MotionEventAuraTest, DoesntIgnoreRedundantPresses) { |
| 459 int id = 7; | 459 const int id = 7; |
| 460 const int position_1 = 10; |
| 461 const int position_2 = 23; |
| 462 |
| 460 MotionEventAura event; | 463 MotionEventAura event; |
| 461 EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id))); | 464 TouchEvent press1 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_1, |
| 462 EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id))); | 465 position_1, position_1, position_1); |
| 466 EXPECT_TRUE(event.OnTouch(press1)); |
| 467 TouchEvent press2 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_2, |
| 468 position_2, position_2, position_2); |
| 469 EXPECT_TRUE(event.OnTouch(press2)); |
| 470 |
| 471 EXPECT_EQ(1U, event.GetPointerCount()); |
| 472 EXPECT_FLOAT_EQ(position_2, event.GetX(0)); |
| 463 } | 473 } |
| 464 | 474 |
| 465 TEST(MotionEventAuraTest, IgnoresEventsWithoutPress) { | 475 TEST(MotionEventAuraTest, IgnoresEventsWithoutPress) { |
| 466 int id = 7; | 476 int id = 7; |
| 467 MotionEventAura event; | 477 MotionEventAura event; |
| 468 EXPECT_FALSE(event.OnTouch(TouchWithType(ET_TOUCH_MOVED, id))); | 478 EXPECT_FALSE(event.OnTouch(TouchWithType(ET_TOUCH_MOVED, id))); |
| 469 } | 479 } |
| 470 | 480 |
| 471 TEST(MotionEventAuraTest, IgnoresStationaryMoves) { | 481 TEST(MotionEventAuraTest, IgnoresStationaryMoves) { |
| 472 int id = 7; | 482 int id = 7; |
| 473 MotionEventAura event; | 483 MotionEventAura event; |
| 474 EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id))); | 484 EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id))); |
| 475 TouchEvent move0 = TouchWithPosition(ET_TOUCH_PRESSED, id, 10, 20, 10, 20); | 485 TouchEvent move0 = TouchWithPosition(ET_TOUCH_PRESSED, id, 10, 20, 10, 20); |
| 476 EXPECT_TRUE(event.OnTouch(move0)); | 486 EXPECT_TRUE(event.OnTouch(move0)); |
| 477 | 487 |
| 478 TouchEvent move1 = TouchWithPosition(ET_TOUCH_MOVED, id, 11, 21, 11, 21); | 488 TouchEvent move1 = TouchWithPosition(ET_TOUCH_MOVED, id, 11, 21, 11, 21); |
| 479 EXPECT_TRUE(event.OnTouch(move1)); | 489 EXPECT_TRUE(event.OnTouch(move1)); |
| 480 EXPECT_FALSE(event.OnTouch(move1)); | 490 EXPECT_FALSE(event.OnTouch(move1)); |
| 481 } | 491 } |
| 482 | 492 |
| 483 } // namespace ui | 493 } // namespace ui |
| OLD | NEW |