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

Side by Side Diff: content/browser/renderer_host/input/touch_handle_unittest.cc

Issue 462163002: Use a minimum touch size for selection handle hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « content/browser/renderer_host/input/touch_handle.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 #include "content/browser/renderer_host/input/touch_handle.h" 5 #include "content/browser/renderer_host/input/touch_handle.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/events/test/mock_motion_event.h" 8 #include "ui/events/test/mock_motion_event.h"
9 #include "ui/gfx/geometry/rect_f.h" 9 #include "ui/gfx/geometry/rect_f.h"
10 10
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 EXPECT_FALSE(handle.WillHandleTouchEvent(event)); 417 EXPECT_FALSE(handle.WillHandleTouchEvent(event));
418 EXPECT_FALSE(IsDragging()); 418 EXPECT_FALSE(IsDragging());
419 419
420 event.SetTouchMajor(kTouchSize); 420 event.SetTouchMajor(kTouchSize);
421 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); 421 EXPECT_TRUE(handle.WillHandleTouchEvent(event));
422 EXPECT_TRUE(IsDragging()); 422 EXPECT_TRUE(IsDragging());
423 423
424 event.SetTouchMajor(kTouchSize * 2.f); 424 event.SetTouchMajor(kTouchSize * 2.f);
425 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); 425 EXPECT_TRUE(handle.WillHandleTouchEvent(event));
426 EXPECT_TRUE(IsDragging()); 426 EXPECT_TRUE(IsDragging());
427
428 // Ensure a touch size of 0 can still register a hit.
429 event = MockMotionEvent(MockMotionEvent::ACTION_DOWN,
430 event_time,
431 kDefaultDrawableSize / 2.f,
432 kDefaultDrawableSize / 2.f);
433 event.SetTouchMajor(0);
434 EXPECT_TRUE(handle.WillHandleTouchEvent(event));
435 EXPECT_TRUE(IsDragging());
427 } 436 }
428 437
429 TEST_F(TouchHandleTest, Tap) { 438 TEST_F(TouchHandleTest, Tap) {
430 TouchHandle handle(this, TOUCH_HANDLE_CENTER); 439 TouchHandle handle(this, TOUCH_HANDLE_CENTER);
431 handle.SetVisible(true, TouchHandle::ANIMATION_NONE); 440 handle.SetVisible(true, TouchHandle::ANIMATION_NONE);
432 441
433 base::TimeTicks event_time = base::TimeTicks::Now(); 442 base::TimeTicks event_time = base::TimeTicks::Now();
434 443
435 // ACTION_CANCEL shouldn't trigger a tap. 444 // ACTION_CANCEL shouldn't trigger a tap.
436 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); 445 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
(...skipping 14 matching lines...) Expand all
451 // Only a brief tap should trigger a tap. 460 // Only a brief tap should trigger a tap.
452 event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); 461 event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
453 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); 462 EXPECT_TRUE(handle.WillHandleTouchEvent(event));
454 event_time += base::TimeDelta::FromMilliseconds(50); 463 event_time += base::TimeDelta::FromMilliseconds(50);
455 event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0); 464 event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0);
456 EXPECT_TRUE(handle.WillHandleTouchEvent(event)); 465 EXPECT_TRUE(handle.WillHandleTouchEvent(event));
457 EXPECT_TRUE(GetAndResetHandleTapped()); 466 EXPECT_TRUE(GetAndResetHandleTapped());
458 } 467 }
459 468
460 } // namespace content 469 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_handle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698