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

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

Issue 197273003: Add support for touch-action: manipulation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move validation to IPC layer Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_action_filter.h" 5 #include "content/browser/renderer_host/input/touch_action_filter.h"
6 #include "content/common/input/synthetic_web_input_event_builders.h" 6 #include "content/common/input/synthetic_web_input_event_builders.h"
7 #include "content/port/browser/event_with_latency_info.h" 7 #include "content/port/browser/event_with_latency_info.h"
8 #include "content/port/common/input_event_ack_state.h" 8 #include "content/port/common/input_event_ack_state.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/web/WebInputEvent.h" 10 #include "third_party/WebKit/public/web/WebInputEvent.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 // Pinch is not allowed with touch-action: pan-x pan-y. 409 // Pinch is not allowed with touch-action: pan-x pan-y.
410 filter.ResetTouchAction(); 410 filter.ResetTouchAction();
411 filter.OnSetTouchAction(TOUCH_ACTION_PAN_X_Y); 411 filter.OnSetTouchAction(TOUCH_ACTION_PAN_X_Y);
412 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin)); 412 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
413 EXPECT_TRUE(filter.FilterGestureEvent(&pinch_begin)); 413 EXPECT_TRUE(filter.FilterGestureEvent(&pinch_begin));
414 EXPECT_TRUE(filter.FilterGestureEvent(&pinch_update)); 414 EXPECT_TRUE(filter.FilterGestureEvent(&pinch_update));
415 EXPECT_TRUE(filter.FilterGestureEvent(&pinch_end)); 415 EXPECT_TRUE(filter.FilterGestureEvent(&pinch_end));
416 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end)); 416 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
417 417
418 // Pinch is allowed with touch-action: manipulation.
419 filter.ResetTouchAction();
420 filter.OnSetTouchAction(TOUCH_ACTION_MANIPULATION);
421 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
422 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
423 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
424 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
425 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
426
418 // Pinch state is automatically reset at the end of a scroll. 427 // Pinch state is automatically reset at the end of a scroll.
419 filter.ResetTouchAction(); 428 filter.ResetTouchAction();
420 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin)); 429 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
421 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin)); 430 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_begin));
422 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update)); 431 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_update));
423 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end)); 432 EXPECT_FALSE(filter.FilterGestureEvent(&pinch_end));
424 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end)); 433 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_end));
425 434
426 // Pinching can become disallowed during a single scroll gesture, but 435 // Pinching can become disallowed during a single scroll gesture, but
427 // can't become allowed again until the scroll terminates. 436 // can't become allowed again until the scroll terminates.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 WebInputEvent::GestureTapDown, WebGestureEvent::Touchscreen); 506 WebInputEvent::GestureTapDown, WebGestureEvent::Touchscreen);
498 WebGestureEvent unconfirmed_tap = SyntheticWebGestureEventBuilder::Build( 507 WebGestureEvent unconfirmed_tap = SyntheticWebGestureEventBuilder::Build(
499 WebInputEvent::GestureTapUnconfirmed, WebGestureEvent::Touchscreen); 508 WebInputEvent::GestureTapUnconfirmed, WebGestureEvent::Touchscreen);
500 WebGestureEvent tap_cancel = SyntheticWebGestureEventBuilder::Build( 509 WebGestureEvent tap_cancel = SyntheticWebGestureEventBuilder::Build(
501 WebInputEvent::GestureTapCancel, WebGestureEvent::Touchscreen); 510 WebInputEvent::GestureTapCancel, WebGestureEvent::Touchscreen);
502 WebGestureEvent double_tap = SyntheticWebGestureEventBuilder::Build( 511 WebGestureEvent double_tap = SyntheticWebGestureEventBuilder::Build(
503 WebInputEvent::GestureDoubleTap, WebGestureEvent::Touchscreen); 512 WebInputEvent::GestureDoubleTap, WebGestureEvent::Touchscreen);
504 513
505 // Double tap is disabled with any touch action other than auto. 514 // Double tap is disabled with any touch action other than auto.
506 filter.ResetTouchAction(); 515 filter.ResetTouchAction();
507 filter.OnSetTouchAction(TOUCH_ACTION_NONE); 516 filter.OnSetTouchAction(TOUCH_ACTION_MANIPULATION);
508 EXPECT_FALSE(filter.FilterGestureEvent(&tap_down)); 517 EXPECT_FALSE(filter.FilterGestureEvent(&tap_down));
509 EXPECT_FALSE(filter.FilterGestureEvent(&unconfirmed_tap)); 518 EXPECT_FALSE(filter.FilterGestureEvent(&unconfirmed_tap));
510 EXPECT_EQ(WebInputEvent::GestureTap, unconfirmed_tap.type); 519 EXPECT_EQ(WebInputEvent::GestureTap, unconfirmed_tap.type);
511 // Changing the touch action for the second tap doesn't effect the behaviour 520 // Changing the touch action for the second tap doesn't effect the behaviour
512 // of the event. The tap cancel will come as part of the next touch sequence. 521 // of the event. The tap cancel will come as part of the next touch sequence.
513 filter.ResetTouchAction(); 522 filter.ResetTouchAction();
514 filter.OnSetTouchAction(TOUCH_ACTION_AUTO); 523 filter.OnSetTouchAction(TOUCH_ACTION_AUTO);
515 EXPECT_TRUE(filter.FilterGestureEvent(&tap_cancel)); 524 EXPECT_TRUE(filter.FilterGestureEvent(&tap_cancel));
516 EXPECT_FALSE(filter.FilterGestureEvent(&tap_down)); 525 EXPECT_FALSE(filter.FilterGestureEvent(&tap_down));
517 EXPECT_FALSE(filter.FilterGestureEvent(&double_tap)); 526 EXPECT_FALSE(filter.FilterGestureEvent(&double_tap));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 584
576 filter.ResetTouchAction(); 585 filter.ResetTouchAction();
577 filter.OnSetTouchAction(TOUCH_ACTION_NONE); 586 filter.OnSetTouchAction(TOUCH_ACTION_NONE);
578 EXPECT_FALSE(filter.FilterGestureEvent(&tap)); 587 EXPECT_FALSE(filter.FilterGestureEvent(&tap));
579 588
580 filter.ResetTouchAction(); 589 filter.ResetTouchAction();
581 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin)); 590 EXPECT_FALSE(filter.FilterGestureEvent(&scroll_begin));
582 } 591 }
583 592
584 } // namespace content 593 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_action_filter.cc ('k') | content/common/input/touch_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698