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

Side by Side Diff: ui/events/gestures/motion_event_aura_unittest.cc

Issue 1907323003: Drag and drop cleans up touch sequences from the source window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac. Created 4 years, 7 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/gestures/motion_event_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 EXPECT_EQ(2U, cancel->GetPointerCount()); 424 EXPECT_EQ(2U, cancel->GetPointerCount());
425 } 425 }
426 426
427 TEST(MotionEventAuraTest, ToolType) { 427 TEST(MotionEventAuraTest, ToolType) {
428 MotionEventAura event; 428 MotionEventAura event;
429 TouchEvent touch_event = TouchWithType(ET_TOUCH_PRESSED, 7); 429 TouchEvent touch_event = TouchWithType(ET_TOUCH_PRESSED, 7);
430 EXPECT_TRUE(event.OnTouch(touch_event)); 430 EXPECT_TRUE(event.OnTouch(touch_event));
431 ASSERT_EQ(1U, event.GetPointerCount()); 431 ASSERT_EQ(1U, event.GetPointerCount());
432 EXPECT_EQ(MotionEvent::TOOL_TYPE_FINGER, event.GetToolType(0)); 432 EXPECT_EQ(MotionEvent::TOOL_TYPE_FINGER, event.GetToolType(0));
433 433
434 touch_event = TouchWithType(ET_TOUCH_RELEASED, 7);
434 PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, 5.0f, 5.0f, 435 PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN, 5.0f, 5.0f,
435 1.0f, 0.0f, 0.0f); 436 1.0f, 0.0f, 0.0f);
436 touch_event.set_pointer_details(pointer_details); 437 touch_event.set_pointer_details(pointer_details);
437 EXPECT_TRUE(event.OnTouch(touch_event)); 438 EXPECT_TRUE(event.OnTouch(touch_event));
438 EXPECT_EQ(MotionEvent::TOOL_TYPE_STYLUS, event.GetToolType(0)); 439 EXPECT_EQ(MotionEvent::TOOL_TYPE_STYLUS, event.GetToolType(0));
439 } 440 }
440 441
441 TEST(MotionEventAuraTest, Flags) { 442 TEST(MotionEventAuraTest, Flags) {
442 int ids[] = {7, 11}; 443 int ids[] = {7, 11};
443 MotionEventAura event; 444 MotionEventAura event;
444 445
445 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]); 446 TouchEvent press0 = TouchWithType(ET_TOUCH_PRESSED, ids[0]);
446 press0.set_flags(EF_CONTROL_DOWN); 447 press0.set_flags(EF_CONTROL_DOWN);
447 EXPECT_TRUE(event.OnTouch(press0)); 448 EXPECT_TRUE(event.OnTouch(press0));
448 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags()); 449 EXPECT_EQ(EF_CONTROL_DOWN, event.GetFlags());
449 450
450 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]); 451 TouchEvent press1 = TouchWithType(ET_TOUCH_PRESSED, ids[1]);
451 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_ON); 452 press1.set_flags(EF_CONTROL_DOWN | EF_CAPS_LOCK_ON);
452 EXPECT_TRUE(event.OnTouch(press1)); 453 EXPECT_TRUE(event.OnTouch(press1));
453 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_ON, event.GetFlags()); 454 EXPECT_EQ(EF_CONTROL_DOWN | EF_CAPS_LOCK_ON, event.GetFlags());
454 } 455 }
455 456
456 // Once crbug.com/446852 is fixed, we should ignore redundant presses. 457 TEST(MotionEventAuraTest, IgnoresRedundantPresses) {
457 TEST(MotionEventAuraTest, DoesntIgnoreRedundantPresses) {
458 const int id = 7; 458 const int id = 7;
459 const int position_1 = 10; 459 const int position_1 = 10;
460 const int position_2 = 23; 460 const int position_2 = 23;
461 461
462 MotionEventAura event; 462 MotionEventAura event;
463 TouchEvent press1 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_1, 463 TouchEvent press1 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_1,
464 position_1, position_1, position_1); 464 position_1, position_1, position_1);
465 EXPECT_TRUE(event.OnTouch(press1)); 465 EXPECT_TRUE(event.OnTouch(press1));
466 TouchEvent press2 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_2, 466 TouchEvent press2 = TouchWithPosition(ET_TOUCH_PRESSED, id, position_2,
467 position_2, position_2, position_2); 467 position_2, position_2, position_2);
468 EXPECT_TRUE(event.OnTouch(press2)); 468 EXPECT_FALSE(event.OnTouch(press2));
469 469
470 EXPECT_EQ(1U, event.GetPointerCount()); 470 EXPECT_EQ(1U, event.GetPointerCount());
471 EXPECT_FLOAT_EQ(position_2, event.GetX(0)); 471 EXPECT_FLOAT_EQ(position_1, event.GetX(0));
472 } 472 }
473 473
474 TEST(MotionEventAuraTest, IgnoresEventsWithoutPress) { 474 TEST(MotionEventAuraTest, IgnoresEventsWithoutPress) {
475 int id = 7; 475 int id = 7;
476 MotionEventAura event; 476 MotionEventAura event;
477 EXPECT_FALSE(event.OnTouch(TouchWithType(ET_TOUCH_MOVED, id))); 477 EXPECT_FALSE(event.OnTouch(TouchWithType(ET_TOUCH_MOVED, id)));
478 } 478 }
479 479
480 TEST(MotionEventAuraTest, IgnoresStationaryMoves) { 480 TEST(MotionEventAuraTest, IgnoresStationaryMoves) {
481 int id = 7; 481 int id = 7;
482 MotionEventAura event; 482 MotionEventAura event;
483 EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id))); 483 EXPECT_TRUE(event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, id)));
484 TouchEvent move0 = TouchWithPosition(ET_TOUCH_PRESSED, id, 10, 20, 10, 20); 484 TouchEvent move0 = TouchWithPosition(ET_TOUCH_MOVED, id, 10, 20, 10, 20);
485 EXPECT_TRUE(event.OnTouch(move0)); 485 EXPECT_TRUE(event.OnTouch(move0));
486 486
487 TouchEvent move1 = TouchWithPosition(ET_TOUCH_MOVED, id, 11, 21, 11, 21); 487 TouchEvent move1 = TouchWithPosition(ET_TOUCH_MOVED, id, 11, 21, 11, 21);
488 EXPECT_TRUE(event.OnTouch(move1)); 488 EXPECT_TRUE(event.OnTouch(move1));
489 EXPECT_FALSE(event.OnTouch(move1)); 489 EXPECT_FALSE(event.OnTouch(move1));
490 } 490 }
491 491
492 // Test after converting touch events into motion events, motion events should 492 // Test after converting touch events into motion events, motion events should
493 // have the same unique_event_id as touch events. 493 // have the same unique_event_id as touch events.
494 TEST(MotionEventAuraTest, UniqueEventID) { 494 TEST(MotionEventAuraTest, UniqueEventID) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 int id = i + kIdOffset; 526 int id = i + kIdOffset;
527 TouchEvent release = TouchWithType(ET_TOUCH_RELEASED, id); 527 TouchEvent release = TouchWithType(ET_TOUCH_RELEASED, id);
528 if (i < MotionEvent::MAX_TOUCH_POINT_COUNT) 528 if (i < MotionEvent::MAX_TOUCH_POINT_COUNT)
529 EXPECT_TRUE(event.OnTouch(release)); 529 EXPECT_TRUE(event.OnTouch(release));
530 else 530 else
531 EXPECT_FALSE(event.OnTouch(release)); 531 EXPECT_FALSE(event.OnTouch(release));
532 } 532 }
533 } 533 }
534 534
535 } // namespace ui 535 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/gestures/motion_event_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698