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

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 8 years 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
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/timer.h" 8 #include "base/timer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 // Check that appropriate touch events generate tap gesture events. 524 // Check that appropriate touch events generate tap gesture events.
525 TEST_F(GestureRecognizerTest, GestureEventTap) { 525 TEST_F(GestureRecognizerTest, GestureEventTap) {
526 scoped_ptr<GestureEventConsumeDelegate> delegate( 526 scoped_ptr<GestureEventConsumeDelegate> delegate(
527 new GestureEventConsumeDelegate()); 527 new GestureEventConsumeDelegate());
528 const int kWindowWidth = 123; 528 const int kWindowWidth = 123;
529 const int kWindowHeight = 45; 529 const int kWindowHeight = 45;
530 const int kTouchId = 2; 530 const int kTouchId = 2;
531 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 531 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
532 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 532 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
533 delegate.get(), -1234, bounds, NULL)); 533 delegate.get(), -1234, bounds, root_window()));
534 534
535 delegate->Reset(); 535 delegate->Reset();
536 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 536 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
537 kTouchId, GetTime()); 537 kTouchId, GetTime());
538 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 538 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
539 EXPECT_FALSE(delegate->tap()); 539 EXPECT_FALSE(delegate->tap());
540 EXPECT_TRUE(delegate->tap_down()); 540 EXPECT_TRUE(delegate->tap_down());
541 EXPECT_FALSE(delegate->tap_cancel()); 541 EXPECT_FALSE(delegate->tap_cancel());
542 EXPECT_TRUE(delegate->begin()); 542 EXPECT_TRUE(delegate->begin());
543 EXPECT_FALSE(delegate->double_tap()); 543 EXPECT_FALSE(delegate->double_tap());
(...skipping 26 matching lines...) Expand all
570 // Check that appropriate touch events generate tap gesture events 570 // Check that appropriate touch events generate tap gesture events
571 // when information about the touch radii are provided. 571 // when information about the touch radii are provided.
572 TEST_F(GestureRecognizerTest, GestureEventTapRegion) { 572 TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
573 scoped_ptr<GestureEventConsumeDelegate> delegate( 573 scoped_ptr<GestureEventConsumeDelegate> delegate(
574 new GestureEventConsumeDelegate()); 574 new GestureEventConsumeDelegate());
575 const int kWindowWidth = 800; 575 const int kWindowWidth = 800;
576 const int kWindowHeight = 600; 576 const int kWindowHeight = 600;
577 const int kTouchId = 2; 577 const int kTouchId = 2;
578 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); 578 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight);
579 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 579 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
580 delegate.get(), -1234, bounds, NULL)); 580 delegate.get(), -1234, bounds, root_window()));
581 581
582 // Test with no ET_TOUCH_MOVED events. 582 // Test with no ET_TOUCH_MOVED events.
583 { 583 {
584 delegate->Reset(); 584 delegate->Reset();
585 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 585 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
586 kTouchId, GetTime()); 586 kTouchId, GetTime());
587 press.set_radius_x(5); 587 press.set_radius_x(5);
588 press.set_radius_y(12); 588 press.set_radius_y(12);
589 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 589 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
590 EXPECT_FALSE(delegate->tap()); 590 EXPECT_FALSE(delegate->tap());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 829
830 // Check that appropriate touch events generate scroll gesture events. 830 // Check that appropriate touch events generate scroll gesture events.
831 TEST_F(GestureRecognizerTest, GestureEventScroll) { 831 TEST_F(GestureRecognizerTest, GestureEventScroll) {
832 scoped_ptr<GestureEventConsumeDelegate> delegate( 832 scoped_ptr<GestureEventConsumeDelegate> delegate(
833 new GestureEventConsumeDelegate()); 833 new GestureEventConsumeDelegate());
834 const int kWindowWidth = 123; 834 const int kWindowWidth = 123;
835 const int kWindowHeight = 45; 835 const int kWindowHeight = 45;
836 const int kTouchId = 5; 836 const int kTouchId = 5;
837 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 837 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
838 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 838 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
839 delegate.get(), -1234, bounds, NULL)); 839 delegate.get(), -1234, bounds, root_window()));
840 840
841 delegate->Reset(); 841 delegate->Reset();
842 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 842 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
843 kTouchId, GetTime()); 843 kTouchId, GetTime());
844 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 844 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
845 EXPECT_2_EVENTS(delegate->events(), 845 EXPECT_2_EVENTS(delegate->events(),
846 ui::ET_GESTURE_BEGIN, 846 ui::ET_GESTURE_BEGIN,
847 ui::ET_GESTURE_TAP_DOWN); 847 ui::ET_GESTURE_TAP_DOWN);
848 848
849 // Move the touch-point enough so that it is considered as a scroll. This 849 // Move the touch-point enough so that it is considered as a scroll. This
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) { 895 TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
896 for (int radius = 1; radius <= 10; ++radius) { 896 for (int radius = 1; radius <= 10; ++radius) {
897 ui::GestureConfiguration::set_default_radius(radius); 897 ui::GestureConfiguration::set_default_radius(radius);
898 scoped_ptr<GestureEventConsumeDelegate> delegate( 898 scoped_ptr<GestureEventConsumeDelegate> delegate(
899 new GestureEventConsumeDelegate()); 899 new GestureEventConsumeDelegate());
900 const int kWindowWidth = 123; 900 const int kWindowWidth = 123;
901 const int kWindowHeight = 45; 901 const int kWindowHeight = 45;
902 const int kTouchId = 5; 902 const int kTouchId = 5;
903 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 903 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
904 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 904 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
905 delegate.get(), -1234, bounds, NULL)); 905 delegate.get(), -1234, bounds, root_window()));
906 906
907 const int kPositionX = 101; 907 const int kPositionX = 101;
908 const int kPositionY = 201; 908 const int kPositionY = 201;
909 delegate->Reset(); 909 delegate->Reset();
910 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 910 ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
911 gfx::Point(kPositionX, kPositionY), 911 gfx::Point(kPositionX, kPositionY),
912 kTouchId, 912 kTouchId,
913 GetTime()); 913 GetTime());
914 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 914 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
915 EXPECT_EQ(gfx::Rect(kPositionX - radius, 915 EXPECT_EQ(gfx::Rect(kPositionX - radius,
(...skipping 30 matching lines...) Expand all
946 } 946 }
947 947
948 // Check Scroll End Events report correct velocities 948 // Check Scroll End Events report correct velocities
949 // if the user was on a horizontal rail 949 // if the user was on a horizontal rail
950 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) { 950 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
951 scoped_ptr<GestureEventConsumeDelegate> delegate( 951 scoped_ptr<GestureEventConsumeDelegate> delegate(
952 new GestureEventConsumeDelegate()); 952 new GestureEventConsumeDelegate());
953 const int kTouchId = 7; 953 const int kTouchId = 7;
954 gfx::Rect bounds(0, 0, 1000, 1000); 954 gfx::Rect bounds(0, 0, 1000, 1000);
955 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 955 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
956 delegate.get(), -1234, bounds, NULL)); 956 delegate.get(), -1234, bounds, root_window()));
957 957
958 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 958 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
959 kTouchId, GetTime()); 959 kTouchId, GetTime());
960 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 960 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
961 961
962 // Move the touch-point horizontally enough that it is considered a 962 // Move the touch-point horizontally enough that it is considered a
963 // horizontal scroll. 963 // horizontal scroll.
964 SendScrollEvent(root_window(), 20, 1, kTouchId, delegate.get()); 964 SendScrollEvent(root_window(), 20, 1, kTouchId, delegate.get());
965 EXPECT_EQ(0, delegate->scroll_y()); 965 EXPECT_EQ(0, delegate->scroll_y());
966 EXPECT_EQ(20, delegate->scroll_x()); 966 EXPECT_EQ(20, delegate->scroll_x());
(...skipping 20 matching lines...) Expand all
987 } 987 }
988 988
989 // Check Scroll End Events report correct velocities 989 // Check Scroll End Events report correct velocities
990 // if the user was on a vertical rail 990 // if the user was on a vertical rail
991 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) { 991 TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
992 scoped_ptr<GestureEventConsumeDelegate> delegate( 992 scoped_ptr<GestureEventConsumeDelegate> delegate(
993 new GestureEventConsumeDelegate()); 993 new GestureEventConsumeDelegate());
994 const int kTouchId = 7; 994 const int kTouchId = 7;
995 gfx::Rect bounds(0, 0, 1000, 1000); 995 gfx::Rect bounds(0, 0, 1000, 1000);
996 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 996 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
997 delegate.get(), -1234, bounds, NULL)); 997 delegate.get(), -1234, bounds, root_window()));
998 998
999 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 999 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1000 kTouchId, GetTime()); 1000 kTouchId, GetTime());
1001 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1001 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1002 1002
1003 // Move the touch-point vertically enough that it is considered a 1003 // Move the touch-point vertically enough that it is considered a
1004 // vertical scroll. 1004 // vertical scroll.
1005 SendScrollEvent(root_window(), 1, 20, kTouchId, delegate.get()); 1005 SendScrollEvent(root_window(), 1, 20, kTouchId, delegate.get());
1006 EXPECT_EQ(20, delegate->scroll_y()); 1006 EXPECT_EQ(20, delegate->scroll_y());
1007 EXPECT_EQ(0, delegate->scroll_x()); 1007 EXPECT_EQ(0, delegate->scroll_x());
(...skipping 20 matching lines...) Expand all
1028 } 1028 }
1029 1029
1030 // Check Scroll End Events reports zero velocities 1030 // Check Scroll End Events reports zero velocities
1031 // if the user is not on a rail 1031 // if the user is not on a rail
1032 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) { 1032 TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
1033 scoped_ptr<GestureEventConsumeDelegate> delegate( 1033 scoped_ptr<GestureEventConsumeDelegate> delegate(
1034 new GestureEventConsumeDelegate()); 1034 new GestureEventConsumeDelegate());
1035 const int kTouchId = 7; 1035 const int kTouchId = 7;
1036 gfx::Rect bounds(0, 0, 1000, 1000); 1036 gfx::Rect bounds(0, 0, 1000, 1000);
1037 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1037 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1038 delegate.get(), -1234, bounds, NULL)); 1038 delegate.get(), -1234, bounds, root_window()));
1039 1039
1040 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1040 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1041 kTouchId, GetTime()); 1041 kTouchId, GetTime());
1042 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1042 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1043 1043
1044 // Move the touch-point such that a non-rail scroll begins 1044 // Move the touch-point such that a non-rail scroll begins
1045 SendScrollEvent(root_window(), 20, 20, kTouchId, delegate.get()); 1045 SendScrollEvent(root_window(), 20, 20, kTouchId, delegate.get());
1046 EXPECT_EQ(20, delegate->scroll_y()); 1046 EXPECT_EQ(20, delegate->scroll_y());
1047 EXPECT_EQ(20, delegate->scroll_x()); 1047 EXPECT_EQ(20, delegate->scroll_x());
1048 1048
(...skipping 15 matching lines...) Expand all
1064 1064
1065 // Check that appropriate touch events generate long press events 1065 // Check that appropriate touch events generate long press events
1066 TEST_F(GestureRecognizerTest, GestureEventLongPress) { 1066 TEST_F(GestureRecognizerTest, GestureEventLongPress) {
1067 scoped_ptr<GestureEventConsumeDelegate> delegate( 1067 scoped_ptr<GestureEventConsumeDelegate> delegate(
1068 new GestureEventConsumeDelegate()); 1068 new GestureEventConsumeDelegate());
1069 const int kWindowWidth = 123; 1069 const int kWindowWidth = 123;
1070 const int kWindowHeight = 45; 1070 const int kWindowHeight = 45;
1071 const int kTouchId = 2; 1071 const int kTouchId = 2;
1072 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1072 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1073 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1073 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1074 delegate.get(), -1234, bounds, NULL)); 1074 delegate.get(), -1234, bounds, root_window()));
1075 1075
1076 delegate->Reset(); 1076 delegate->Reset();
1077 1077
1078 TimerTestGestureRecognizer* gesture_recognizer = 1078 TimerTestGestureRecognizer* gesture_recognizer =
1079 new TimerTestGestureRecognizer(root_window()); 1079 new TimerTestGestureRecognizer(root_window());
1080 1080
1081 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1081 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1082 1082
1083 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1083 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1084 kTouchId, GetTime()); 1084 kTouchId, GetTime());
(...skipping 23 matching lines...) Expand all
1108 1108
1109 // Check that scrolling cancels a long press 1109 // Check that scrolling cancels a long press
1110 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) { 1110 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
1111 scoped_ptr<GestureEventConsumeDelegate> delegate( 1111 scoped_ptr<GestureEventConsumeDelegate> delegate(
1112 new GestureEventConsumeDelegate()); 1112 new GestureEventConsumeDelegate());
1113 const int kWindowWidth = 123; 1113 const int kWindowWidth = 123;
1114 const int kWindowHeight = 45; 1114 const int kWindowHeight = 45;
1115 const int kTouchId = 6; 1115 const int kTouchId = 6;
1116 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1116 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1117 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1117 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1118 delegate.get(), -1234, bounds, NULL)); 1118 delegate.get(), -1234, bounds, root_window()));
1119 1119
1120 delegate->Reset(); 1120 delegate->Reset();
1121 1121
1122 TimerTestGestureRecognizer* gesture_recognizer = 1122 TimerTestGestureRecognizer* gesture_recognizer =
1123 new TimerTestGestureRecognizer(root_window()); 1123 new TimerTestGestureRecognizer(root_window());
1124 TimerTestGestureSequence* gesture_sequence = 1124 TimerTestGestureSequence* gesture_sequence =
1125 static_cast<TimerTestGestureSequence*>( 1125 static_cast<TimerTestGestureSequence*>(
1126 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 1126 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
1127 1127
1128 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1128 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
(...skipping 24 matching lines...) Expand all
1153 1153
1154 // Check that appropriate touch events generate long tap events 1154 // Check that appropriate touch events generate long tap events
1155 TEST_F(GestureRecognizerTest, GestureEventLongTap) { 1155 TEST_F(GestureRecognizerTest, GestureEventLongTap) {
1156 scoped_ptr<GestureEventConsumeDelegate> delegate( 1156 scoped_ptr<GestureEventConsumeDelegate> delegate(
1157 new GestureEventConsumeDelegate()); 1157 new GestureEventConsumeDelegate());
1158 const int kWindowWidth = 123; 1158 const int kWindowWidth = 123;
1159 const int kWindowHeight = 45; 1159 const int kWindowHeight = 45;
1160 const int kTouchId = 2; 1160 const int kTouchId = 2;
1161 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1161 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1162 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1162 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1163 delegate.get(), -1234, bounds, NULL)); 1163 delegate.get(), -1234, bounds, root_window()));
1164 1164
1165 delegate->Reset(); 1165 delegate->Reset();
1166 1166
1167 TimerTestGestureRecognizer* gesture_recognizer = 1167 TimerTestGestureRecognizer* gesture_recognizer =
1168 new TimerTestGestureRecognizer(root_window()); 1168 new TimerTestGestureRecognizer(root_window());
1169 1169
1170 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1170 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1171 1171
1172 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1172 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1173 kTouchId, GetTime()); 1173 kTouchId, GetTime());
(...skipping 25 matching lines...) Expand all
1199 // Check that second tap cancels a long press 1199 // Check that second tap cancels a long press
1200 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) { 1200 TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
1201 scoped_ptr<GestureEventConsumeDelegate> delegate( 1201 scoped_ptr<GestureEventConsumeDelegate> delegate(
1202 new GestureEventConsumeDelegate()); 1202 new GestureEventConsumeDelegate());
1203 const int kWindowWidth = 300; 1203 const int kWindowWidth = 300;
1204 const int kWindowHeight = 400; 1204 const int kWindowHeight = 400;
1205 const int kTouchId1 = 8; 1205 const int kTouchId1 = 8;
1206 const int kTouchId2 = 2; 1206 const int kTouchId2 = 2;
1207 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1207 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1208 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1208 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1209 delegate.get(), -1234, bounds, NULL)); 1209 delegate.get(), -1234, bounds, root_window()));
1210 1210
1211 TimerTestGestureRecognizer* gesture_recognizer = 1211 TimerTestGestureRecognizer* gesture_recognizer =
1212 new TimerTestGestureRecognizer(root_window()); 1212 new TimerTestGestureRecognizer(root_window());
1213 TimerTestGestureSequence* gesture_sequence = 1213 TimerTestGestureSequence* gesture_sequence =
1214 static_cast<TimerTestGestureSequence*>( 1214 static_cast<TimerTestGestureSequence*>(
1215 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 1215 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
1216 1216
1217 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1217 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1218 1218
1219 delegate->Reset(); 1219 delegate->Reset();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 } 1251 }
1252 1252
1253 // Check that horizontal scroll gestures cause scrolls on horizontal rails. 1253 // Check that horizontal scroll gestures cause scrolls on horizontal rails.
1254 // Also tests that horizontal rails can be broken. 1254 // Also tests that horizontal rails can be broken.
1255 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) { 1255 TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
1256 scoped_ptr<GestureEventConsumeDelegate> delegate( 1256 scoped_ptr<GestureEventConsumeDelegate> delegate(
1257 new GestureEventConsumeDelegate()); 1257 new GestureEventConsumeDelegate());
1258 const int kTouchId = 7; 1258 const int kTouchId = 7;
1259 gfx::Rect bounds(0, 0, 1000, 1000); 1259 gfx::Rect bounds(0, 0, 1000, 1000);
1260 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1260 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1261 delegate.get(), -1234, bounds, NULL)); 1261 delegate.get(), -1234, bounds, root_window()));
1262 1262
1263 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1263 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1264 kTouchId, GetTime()); 1264 kTouchId, GetTime());
1265 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1265 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1266 1266
1267 // Move the touch-point horizontally enough that it is considered a 1267 // Move the touch-point horizontally enough that it is considered a
1268 // horizontal scroll. 1268 // horizontal scroll.
1269 SendScrollEvent(root_window(), 20, 1, kTouchId, delegate.get()); 1269 SendScrollEvent(root_window(), 20, 1, kTouchId, delegate.get());
1270 EXPECT_EQ(0, delegate->scroll_y()); 1270 EXPECT_EQ(0, delegate->scroll_y());
1271 EXPECT_EQ(20, delegate->scroll_x()); 1271 EXPECT_EQ(20, delegate->scroll_x());
(...skipping 27 matching lines...) Expand all
1299 } 1299 }
1300 1300
1301 // Check that vertical scroll gestures cause scrolls on vertical rails. 1301 // Check that vertical scroll gestures cause scrolls on vertical rails.
1302 // Also tests that vertical rails can be broken. 1302 // Also tests that vertical rails can be broken.
1303 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) { 1303 TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
1304 scoped_ptr<GestureEventConsumeDelegate> delegate( 1304 scoped_ptr<GestureEventConsumeDelegate> delegate(
1305 new GestureEventConsumeDelegate()); 1305 new GestureEventConsumeDelegate());
1306 const int kTouchId = 7; 1306 const int kTouchId = 7;
1307 gfx::Rect bounds(0, 0, 1000, 1000); 1307 gfx::Rect bounds(0, 0, 1000, 1000);
1308 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1308 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1309 delegate.get(), -1234, bounds, NULL)); 1309 delegate.get(), -1234, bounds, root_window()));
1310 1310
1311 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1311 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0),
1312 kTouchId, GetTime()); 1312 kTouchId, GetTime());
1313 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1313 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1314 1314
1315 // Move the touch-point vertically enough that it is considered a 1315 // Move the touch-point vertically enough that it is considered a
1316 // vertical scroll. 1316 // vertical scroll.
1317 SendScrollEvent(root_window(), 1, 20, kTouchId, delegate.get()); 1317 SendScrollEvent(root_window(), 1, 20, kTouchId, delegate.get());
1318 EXPECT_EQ(0, delegate->scroll_x()); 1318 EXPECT_EQ(0, delegate->scroll_x());
1319 EXPECT_EQ(20, delegate->scroll_y()); 1319 EXPECT_EQ(20, delegate->scroll_y());
(...skipping 26 matching lines...) Expand all
1346 1346
1347 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) { 1347 TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
1348 // First, tap. Then, do a scroll using the same touch-id. 1348 // First, tap. Then, do a scroll using the same touch-id.
1349 scoped_ptr<GestureEventConsumeDelegate> delegate( 1349 scoped_ptr<GestureEventConsumeDelegate> delegate(
1350 new GestureEventConsumeDelegate()); 1350 new GestureEventConsumeDelegate());
1351 const int kWindowWidth = 123; 1351 const int kWindowWidth = 123;
1352 const int kWindowHeight = 45; 1352 const int kWindowHeight = 45;
1353 const int kTouchId = 3; 1353 const int kTouchId = 3;
1354 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1354 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1355 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1355 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1356 delegate.get(), -1234, bounds, NULL)); 1356 delegate.get(), -1234, bounds, root_window()));
1357 1357
1358 delegate->Reset(); 1358 delegate->Reset();
1359 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1359 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1360 kTouchId, GetTime()); 1360 kTouchId, GetTime());
1361 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1361 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1362 EXPECT_FALSE(delegate->tap()); 1362 EXPECT_FALSE(delegate->tap());
1363 EXPECT_TRUE(delegate->tap_down()); 1363 EXPECT_TRUE(delegate->tap_down());
1364 EXPECT_FALSE(delegate->tap_cancel()); 1364 EXPECT_FALSE(delegate->tap_cancel());
1365 EXPECT_FALSE(delegate->double_tap()); 1365 EXPECT_FALSE(delegate->double_tap());
1366 EXPECT_FALSE(delegate->scroll_begin()); 1366 EXPECT_FALSE(delegate->scroll_begin());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 1460
1461 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) { 1461 TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
1462 scoped_ptr<QueueTouchEventDelegate> queued_delegate( 1462 scoped_ptr<QueueTouchEventDelegate> queued_delegate(
1463 new QueueTouchEventDelegate(root_window())); 1463 new QueueTouchEventDelegate(root_window()));
1464 const int kWindowWidth = 123; 1464 const int kWindowWidth = 123;
1465 const int kWindowHeight = 45; 1465 const int kWindowHeight = 45;
1466 const int kTouchId1 = 6; 1466 const int kTouchId1 = 6;
1467 const int kTouchId2 = 4; 1467 const int kTouchId2 = 4;
1468 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1468 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1469 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate( 1469 scoped_ptr<aura::Window> queue(CreateTestWindowWithDelegate(
1470 queued_delegate.get(), -1234, bounds, NULL)); 1470 queued_delegate.get(), -1234, bounds, root_window()));
1471 1471
1472 queued_delegate->set_window(queue.get()); 1472 queued_delegate->set_window(queue.get());
1473 1473
1474 // Touch down on the window. This should not generate any gesture event. 1474 // Touch down on the window. This should not generate any gesture event.
1475 queued_delegate->Reset(); 1475 queued_delegate->Reset();
1476 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1476 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1477 kTouchId1, GetTime()); 1477 kTouchId1, GetTime());
1478 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1478 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1479 EXPECT_FALSE(queued_delegate->tap()); 1479 EXPECT_FALSE(queued_delegate->tap());
1480 EXPECT_FALSE(queued_delegate->tap_down()); 1480 EXPECT_FALSE(queued_delegate->tap_down());
(...skipping 19 matching lines...) Expand all
1500 EXPECT_FALSE(queued_delegate->double_tap()); 1500 EXPECT_FALSE(queued_delegate->double_tap());
1501 EXPECT_FALSE(queued_delegate->scroll_begin()); 1501 EXPECT_FALSE(queued_delegate->scroll_begin());
1502 EXPECT_FALSE(queued_delegate->scroll_update()); 1502 EXPECT_FALSE(queued_delegate->scroll_update());
1503 EXPECT_FALSE(queued_delegate->scroll_end()); 1503 EXPECT_FALSE(queued_delegate->scroll_end());
1504 1504
1505 // Create another window, and place a touch-down on it. This should create a 1505 // Create another window, and place a touch-down on it. This should create a
1506 // tap-down gesture. 1506 // tap-down gesture.
1507 scoped_ptr<GestureEventConsumeDelegate> delegate( 1507 scoped_ptr<GestureEventConsumeDelegate> delegate(
1508 new GestureEventConsumeDelegate()); 1508 new GestureEventConsumeDelegate());
1509 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1509 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1510 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), NULL)); 1510 delegate.get(), -2345, gfx::Rect(0, 0, 50, 50), root_window()));
1511 delegate->Reset(); 1511 delegate->Reset();
1512 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), 1512 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 20),
1513 kTouchId2, GetTime()); 1513 kTouchId2, GetTime());
1514 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 1514 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
1515 EXPECT_FALSE(delegate->tap()); 1515 EXPECT_FALSE(delegate->tap());
1516 EXPECT_TRUE(delegate->tap_down()); 1516 EXPECT_TRUE(delegate->tap_down());
1517 EXPECT_FALSE(delegate->tap_cancel()); 1517 EXPECT_FALSE(delegate->tap_cancel());
1518 EXPECT_FALSE(queued_delegate->begin()); 1518 EXPECT_FALSE(queued_delegate->begin());
1519 EXPECT_FALSE(queued_delegate->end()); 1519 EXPECT_FALSE(queued_delegate->end());
1520 EXPECT_FALSE(delegate->double_tap()); 1520 EXPECT_FALSE(delegate->double_tap());
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 // Check that appropriate touch events generate pinch gesture events. 1665 // Check that appropriate touch events generate pinch gesture events.
1666 TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) { 1666 TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
1667 scoped_ptr<GestureEventConsumeDelegate> delegate( 1667 scoped_ptr<GestureEventConsumeDelegate> delegate(
1668 new GestureEventConsumeDelegate()); 1668 new GestureEventConsumeDelegate());
1669 const int kWindowWidth = 300; 1669 const int kWindowWidth = 300;
1670 const int kWindowHeight = 400; 1670 const int kWindowHeight = 400;
1671 const int kTouchId1 = 5; 1671 const int kTouchId1 = 5;
1672 const int kTouchId2 = 3; 1672 const int kTouchId2 = 3;
1673 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1673 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1674 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1674 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1675 delegate.get(), -1234, bounds, NULL)); 1675 delegate.get(), -1234, bounds, root_window()));
1676 1676
1677 aura::RootWindow* root = root_window(); 1677 aura::RootWindow* root = root_window();
1678 1678
1679 delegate->Reset(); 1679 delegate->Reset();
1680 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 1680 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
1681 kTouchId1, GetTime()); 1681 kTouchId1, GetTime());
1682 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1682 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1683 EXPECT_2_EVENTS(delegate->events(), 1683 EXPECT_2_EVENTS(delegate->events(),
1684 ui::ET_GESTURE_BEGIN, 1684 ui::ET_GESTURE_BEGIN,
1685 ui::ET_GESTURE_TAP_DOWN); 1685 ui::ET_GESTURE_TAP_DOWN);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 1752
1753 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) { 1753 TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
1754 scoped_ptr<GestureEventConsumeDelegate> delegate( 1754 scoped_ptr<GestureEventConsumeDelegate> delegate(
1755 new GestureEventConsumeDelegate()); 1755 new GestureEventConsumeDelegate());
1756 const int kWindowWidth = 300; 1756 const int kWindowWidth = 300;
1757 const int kWindowHeight = 400; 1757 const int kWindowHeight = 400;
1758 const int kTouchId1 = 5; 1758 const int kTouchId1 = 5;
1759 const int kTouchId2 = 3; 1759 const int kTouchId2 = 3;
1760 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1760 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1761 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1761 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1762 delegate.get(), -1234, bounds, NULL)); 1762 delegate.get(), -1234, bounds, root_window()));
1763 1763
1764 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 1764 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301),
1765 kTouchId1, GetTime()); 1765 kTouchId1, GetTime());
1766 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1766 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1767 delegate->Reset(); 1767 delegate->Reset();
1768 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1768 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
1769 kTouchId2, GetTime()); 1769 kTouchId2, GetTime());
1770 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 1770 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
1771 // Since the touch points are far enough we will go to pinch rather than two 1771 // Since the touch points are far enough we will go to pinch rather than two
1772 // finger tap. 1772 // finger tap.
(...skipping 30 matching lines...) Expand all
1803 1803
1804 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) { 1804 TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
1805 scoped_ptr<GestureEventConsumeDelegate> delegate( 1805 scoped_ptr<GestureEventConsumeDelegate> delegate(
1806 new GestureEventConsumeDelegate()); 1806 new GestureEventConsumeDelegate());
1807 const int kWindowWidth = 300; 1807 const int kWindowWidth = 300;
1808 const int kWindowHeight = 400; 1808 const int kWindowHeight = 400;
1809 const int kTouchId1 = 3; 1809 const int kTouchId1 = 3;
1810 const int kTouchId2 = 5; 1810 const int kTouchId2 = 5;
1811 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight); 1811 gfx::Rect bounds(5, 5, kWindowWidth, kWindowHeight);
1812 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1812 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1813 delegate.get(), -1234, bounds, NULL)); 1813 delegate.get(), -1234, bounds, root_window()));
1814 1814
1815 aura::RootWindow* root = root_window(); 1815 aura::RootWindow* root = root_window();
1816 1816
1817 delegate->Reset(); 1817 delegate->Reset();
1818 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), 1818 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 301),
1819 kTouchId1, GetTime()); 1819 kTouchId1, GetTime());
1820 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1820 root->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1821 EXPECT_2_EVENTS(delegate->events(), 1821 EXPECT_2_EVENTS(delegate->events(),
1822 ui::ET_GESTURE_BEGIN, 1822 ui::ET_GESTURE_BEGIN,
1823 ui::ET_GESTURE_TAP_DOWN); 1823 ui::ET_GESTURE_TAP_DOWN);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 window_bounds[2] = gfx::Rect(0, 500, 1, 1); 1913 window_bounds[2] = gfx::Rect(0, 500, 1, 1);
1914 window_bounds[3] = gfx::Rect(500, 500, 1, 1); 1914 window_bounds[3] = gfx::Rect(500, 500, 1, 1);
1915 1915
1916 scoped_array<aura::Window*> windows(new aura::Window*[kNumWindows]); 1916 scoped_array<aura::Window*> windows(new aura::Window*[kNumWindows]);
1917 1917
1918 // Instantiate windows with |window_bounds| and touch each window at 1918 // Instantiate windows with |window_bounds| and touch each window at
1919 // its origin. 1919 // its origin.
1920 for (int i = 0; i < kNumWindows; ++i) { 1920 for (int i = 0; i < kNumWindows; ++i) {
1921 delegates[i] = new GestureEventConsumeDelegate(); 1921 delegates[i] = new GestureEventConsumeDelegate();
1922 windows[i] = CreateTestWindowWithDelegate( 1922 windows[i] = CreateTestWindowWithDelegate(
1923 delegates[i], i, window_bounds[i], NULL); 1923 delegates[i], i, window_bounds[i], root_window());
1924 windows[i]->set_id(i); 1924 windows[i]->set_id(i);
1925 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), 1925 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(),
1926 i, GetTime()); 1926 i, GetTime());
1927 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1927 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1928 } 1928 }
1929 1929
1930 // Touches should now be associated with the closest touch within 1930 // Touches should now be associated with the closest touch within
1931 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels 1931 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels
1932 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11)); 1932 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11));
1933 EXPECT_EQ("0", WindowIDAsString(target)); 1933 EXPECT_EQ("0", WindowIDAsString(target));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 } 1978 }
1979 1979
1980 // Check that touch events outside the root window are still handled 1980 // Check that touch events outside the root window are still handled
1981 // by the root window's gesture sequence. 1981 // by the root window's gesture sequence.
1982 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { 1982 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
1983 TestGestureRecognizer* gesture_recognizer = 1983 TestGestureRecognizer* gesture_recognizer =
1984 new TestGestureRecognizer(root_window()); 1984 new TestGestureRecognizer(root_window());
1985 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1985 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1986 1986
1987 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( 1987 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds(
1988 gfx::Rect(-100, -100, 2000, 2000), NULL)); 1988 gfx::Rect(-100, -100, 2000, 2000), root_window()));
1989 1989
1990 ui::GestureSequence* window_gesture_sequence = 1990 ui::GestureSequence* window_gesture_sequence =
1991 gesture_recognizer->GetGestureSequenceForTesting(window.get()); 1991 gesture_recognizer->GetGestureSequenceForTesting(window.get());
1992 1992
1993 ui::GestureSequence* root_window_gesture_sequence = 1993 ui::GestureSequence* root_window_gesture_sequence =
1994 gesture_recognizer->GetGestureSequenceForTesting(root_window()); 1994 gesture_recognizer->GetGestureSequenceForTesting(root_window());
1995 1995
1996 gfx::Point pos1(-10, -10); 1996 gfx::Point pos1(-10, -10);
1997 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, GetTime()); 1997 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, 0, GetTime());
1998 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 1998 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
1999 1999
2000 gfx::Point pos2(1000, 1000); 2000 gfx::Point pos2(1000, 1000);
2001 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, GetTime()); 2001 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, 1, GetTime());
2002 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2002 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
2003 2003
2004 // As these presses were outside the root window, they should be 2004 // As these presses were outside the root window, they should be
2005 // associated with the root window. 2005 // associated with the root window.
2006 EXPECT_EQ(0, window_gesture_sequence->point_count()); 2006 EXPECT_EQ(0, window_gesture_sequence->point_count());
2007 EXPECT_EQ(2, root_window_gesture_sequence->point_count()); 2007 EXPECT_EQ(2, root_window_gesture_sequence->point_count());
2008 } 2008 }
2009 2009
2010 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) { 2010 TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
2011 scoped_ptr<QueueTouchEventDelegate> delegate( 2011 scoped_ptr<QueueTouchEventDelegate> delegate(
2012 new QueueTouchEventDelegate(root_window())); 2012 new QueueTouchEventDelegate(root_window()));
2013 const int kTouchId = 2; 2013 const int kTouchId = 2;
2014 gfx::Rect bounds(100, 200, 100, 100); 2014 gfx::Rect bounds(100, 200, 100, 100);
2015 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2015 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2016 delegate.get(), -1234, bounds, NULL)); 2016 delegate.get(), -1234, bounds, root_window()));
2017 delegate->set_window(window.get()); 2017 delegate->set_window(window.get());
2018 2018
2019 delegate->Reset(); 2019 delegate->Reset();
2020 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2020 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2021 kTouchId, GetTime()); 2021 kTouchId, GetTime());
2022 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2022 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
2023 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2023 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2024 kTouchId, press.time_stamp() + 2024 kTouchId, press.time_stamp() +
2025 base::TimeDelta::FromMilliseconds(50)); 2025 base::TimeDelta::FromMilliseconds(50));
2026 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2026 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
2027 2027
2028 delegate->Reset(); 2028 delegate->Reset();
2029 delegate->ReceivedAck(); 2029 delegate->ReceivedAck();
2030 EXPECT_TRUE(delegate->tap_down()); 2030 EXPECT_TRUE(delegate->tap_down());
2031 delegate->Reset(); 2031 delegate->Reset();
2032 delegate->ReceivedAckPreventDefaulted(); 2032 delegate->ReceivedAckPreventDefaulted();
2033 EXPECT_FALSE(delegate->tap()); 2033 EXPECT_FALSE(delegate->tap());
2034 EXPECT_TRUE(delegate->tap_cancel()); 2034 EXPECT_TRUE(delegate->tap_cancel());
2035 } 2035 }
2036 2036
2037 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) { 2037 TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
2038 scoped_ptr<QueueTouchEventDelegate> delegate( 2038 scoped_ptr<QueueTouchEventDelegate> delegate(
2039 new QueueTouchEventDelegate(root_window())); 2039 new QueueTouchEventDelegate(root_window()));
2040 const int kTouchId1 = 7; 2040 const int kTouchId1 = 7;
2041 const int kTouchId2 = 5; 2041 const int kTouchId2 = 5;
2042 gfx::Rect bounds(10, 20, 100, 100); 2042 gfx::Rect bounds(10, 20, 100, 100);
2043 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2043 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2044 delegate.get(), -1234, bounds, NULL)); 2044 delegate.get(), -1234, bounds, root_window()));
2045 delegate->set_window(window.get()); 2045 delegate->set_window(window.get());
2046 2046
2047 delegate->Reset(); 2047 delegate->Reset();
2048 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1, 2048 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), kTouchId1,
2049 GetTime()); 2049 GetTime());
2050 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1, 2050 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 95), kTouchId1,
2051 press.time_stamp() + base::TimeDelta::FromMilliseconds(200)); 2051 press.time_stamp() + base::TimeDelta::FromMilliseconds(200));
2052 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1, 2052 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), kTouchId1,
2053 move.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 2053 move.time_stamp() + base::TimeDelta::FromMilliseconds(50));
2054 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2054 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 } 2120 }
2121 2121
2122 TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) { 2122 TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) {
2123 scoped_ptr<GestureEventConsumeDelegate> delegate( 2123 scoped_ptr<GestureEventConsumeDelegate> delegate(
2124 new GestureEventConsumeDelegate()); 2124 new GestureEventConsumeDelegate());
2125 TestGestureRecognizer* gesture_recognizer = 2125 TestGestureRecognizer* gesture_recognizer =
2126 new TestGestureRecognizer(root_window()); 2126 new TestGestureRecognizer(root_window());
2127 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 2127 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
2128 2128
2129 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2129 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2130 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL)); 2130 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window()));
2131 EventGenerator generator(root_window()); 2131 EventGenerator generator(root_window());
2132 2132
2133 generator.MoveMouseRelativeTo(window.get(), gfx::Point(10, 10)); 2133 generator.MoveMouseRelativeTo(window.get(), gfx::Point(10, 10));
2134 generator.PressTouch(); 2134 generator.PressTouch();
2135 RunAllPendingInMessageLoop(); 2135 RunAllPendingInMessageLoop();
2136 2136
2137 EXPECT_TRUE(delegate->tap_down()); 2137 EXPECT_TRUE(delegate->tap_down());
2138 2138
2139 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( 2139 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds(
2140 gfx::Rect(10, 10, 200, 200), NULL)); 2140 gfx::Rect(10, 10, 200, 200), root_window()));
2141 capture->SetCapture(); 2141 capture->SetCapture();
2142 RunAllPendingInMessageLoop(); 2142 RunAllPendingInMessageLoop();
2143 2143
2144 EXPECT_TRUE(delegate->end()); 2144 EXPECT_TRUE(delegate->end());
2145 EXPECT_TRUE(delegate->tap_cancel()); 2145 EXPECT_TRUE(delegate->tap_cancel());
2146 } 2146 }
2147 2147
2148 TEST_F(GestureRecognizerTest, PressDoesNotCrash) { 2148 TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
2149 scoped_ptr<GestureEventConsumeDelegate> delegate( 2149 scoped_ptr<GestureEventConsumeDelegate> delegate(
2150 new GestureEventConsumeDelegate()); 2150 new GestureEventConsumeDelegate());
2151 TestGestureRecognizer* gesture_recognizer = 2151 TestGestureRecognizer* gesture_recognizer =
2152 new TestGestureRecognizer(root_window()); 2152 new TestGestureRecognizer(root_window());
2153 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 2153 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
2154 2154
2155 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2155 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2156 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL)); 2156 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window()));
2157 2157
2158 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, GetTime()); 2158 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, GetTime());
2159 press.set_radius_x(40); 2159 press.set_radius_x(40);
2160 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2160 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
2161 EXPECT_TRUE(delegate->tap_down()); 2161 EXPECT_TRUE(delegate->tap_down());
2162 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(), 2162 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(),
2163 delegate->bounding_box().ToString()); 2163 delegate->bounding_box().ToString());
2164 delegate->Reset(); 2164 delegate->Reset();
2165 2165
2166 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, GetTime()); 2166 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, GetTime());
2167 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2167 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
2168 2168
2169 // This new press should not generate a tap-down. 2169 // This new press should not generate a tap-down.
2170 EXPECT_FALSE(delegate->begin()); 2170 EXPECT_FALSE(delegate->begin());
2171 EXPECT_FALSE(delegate->tap_down()); 2171 EXPECT_FALSE(delegate->tap_down());
2172 EXPECT_FALSE(delegate->tap_cancel()); 2172 EXPECT_FALSE(delegate->tap_cancel());
2173 EXPECT_FALSE(delegate->scroll_begin()); 2173 EXPECT_FALSE(delegate->scroll_begin());
2174 } 2174 }
2175 2175
2176 TEST_F(GestureRecognizerTest, TwoFingerTap) { 2176 TEST_F(GestureRecognizerTest, TwoFingerTap) {
2177 scoped_ptr<GestureEventConsumeDelegate> delegate( 2177 scoped_ptr<GestureEventConsumeDelegate> delegate(
2178 new GestureEventConsumeDelegate()); 2178 new GestureEventConsumeDelegate());
2179 const int kWindowWidth = 123; 2179 const int kWindowWidth = 123;
2180 const int kWindowHeight = 45; 2180 const int kWindowHeight = 45;
2181 const int kTouchId1 = 2; 2181 const int kTouchId1 = 2;
2182 const int kTouchId2 = 3; 2182 const int kTouchId2 = 3;
2183 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2183 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2184 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2184 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2185 delegate.get(), -1234, bounds, NULL)); 2185 delegate.get(), -1234, bounds, root_window()));
2186 2186
2187 delegate->Reset(); 2187 delegate->Reset();
2188 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2188 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2189 kTouchId1, GetTime()); 2189 kTouchId1, GetTime());
2190 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2190 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2191 EXPECT_FALSE(delegate->tap()); 2191 EXPECT_FALSE(delegate->tap());
2192 EXPECT_TRUE(delegate->tap_down()); 2192 EXPECT_TRUE(delegate->tap_down());
2193 EXPECT_FALSE(delegate->tap_cancel()); 2193 EXPECT_FALSE(delegate->tap_cancel());
2194 EXPECT_FALSE(delegate->double_tap()); 2194 EXPECT_FALSE(delegate->double_tap());
2195 EXPECT_FALSE(delegate->scroll_begin()); 2195 EXPECT_FALSE(delegate->scroll_begin());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 2268
2269 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { 2269 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
2270 scoped_ptr<GestureEventConsumeDelegate> delegate( 2270 scoped_ptr<GestureEventConsumeDelegate> delegate(
2271 new GestureEventConsumeDelegate()); 2271 new GestureEventConsumeDelegate());
2272 const int kWindowWidth = 123; 2272 const int kWindowWidth = 123;
2273 const int kWindowHeight = 45; 2273 const int kWindowHeight = 45;
2274 const int kTouchId1 = 2; 2274 const int kTouchId1 = 2;
2275 const int kTouchId2 = 3; 2275 const int kTouchId2 = 3;
2276 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2276 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2277 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2277 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2278 delegate.get(), -1234, bounds, NULL)); 2278 delegate.get(), -1234, bounds, root_window()));
2279 2279
2280 delegate->Reset(); 2280 delegate->Reset();
2281 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2281 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2282 kTouchId1, GetTime()); 2282 kTouchId1, GetTime());
2283 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2283 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2284 2284
2285 delegate->Reset(); 2285 delegate->Reset();
2286 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2286 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2287 kTouchId2, GetTime()); 2287 kTouchId2, GetTime());
2288 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2288 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
(...skipping 24 matching lines...) Expand all
2313 new GestureEventConsumeDelegate()); 2313 new GestureEventConsumeDelegate());
2314 const int kWindowWidth = 123; 2314 const int kWindowWidth = 123;
2315 const int kWindowHeight = 45; 2315 const int kWindowHeight = 45;
2316 const int kTouchId1 = 2; 2316 const int kTouchId1 = 2;
2317 const int kTouchId2 = 3; 2317 const int kTouchId2 = 3;
2318 2318
2319 // Test moving first finger 2319 // Test moving first finger
2320 { 2320 {
2321 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2321 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2322 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2322 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2323 delegate.get(), -1234, bounds, NULL)); 2323 delegate.get(), -1234, bounds, root_window()));
2324 2324
2325 delegate->Reset(); 2325 delegate->Reset();
2326 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2326 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2327 kTouchId1, GetTime()); 2327 kTouchId1, GetTime());
2328 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2328 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2329 2329
2330 delegate->Reset(); 2330 delegate->Reset();
2331 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2331 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2332 kTouchId2, GetTime()); 2332 kTouchId2, GetTime());
2333 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2333 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
(...skipping 11 matching lines...) Expand all
2345 2345
2346 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2346 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
2347 EXPECT_FALSE(delegate->two_finger_tap()); 2347 EXPECT_FALSE(delegate->two_finger_tap());
2348 EXPECT_TRUE(delegate->pinch_end()); 2348 EXPECT_TRUE(delegate->pinch_end());
2349 } 2349 }
2350 2350
2351 // Test moving second finger 2351 // Test moving second finger
2352 { 2352 {
2353 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2353 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2354 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2354 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2355 delegate.get(), -1234, bounds, NULL)); 2355 delegate.get(), -1234, bounds, root_window()));
2356 2356
2357 delegate->Reset(); 2357 delegate->Reset();
2358 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2358 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2359 kTouchId1, GetTime()); 2359 kTouchId1, GetTime());
2360 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2360 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2361 2361
2362 delegate->Reset(); 2362 delegate->Reset();
2363 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2363 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2364 kTouchId2, GetTime()); 2364 kTouchId2, GetTime());
2365 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2365 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
(...skipping 16 matching lines...) Expand all
2382 } 2382 }
2383 2383
2384 TEST_F(GestureRecognizerTest, MultiFingerSwipe) { 2384 TEST_F(GestureRecognizerTest, MultiFingerSwipe) {
2385 scoped_ptr<GestureEventConsumeDelegate> delegate( 2385 scoped_ptr<GestureEventConsumeDelegate> delegate(
2386 new GestureEventConsumeDelegate()); 2386 new GestureEventConsumeDelegate());
2387 const int kWindowWidth = 123; 2387 const int kWindowWidth = 123;
2388 const int kWindowHeight = 45; 2388 const int kWindowHeight = 45;
2389 2389
2390 gfx::Rect bounds(5, 10, kWindowWidth, kWindowHeight); 2390 gfx::Rect bounds(5, 10, kWindowWidth, kWindowHeight);
2391 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2391 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2392 delegate.get(), -1234, bounds, NULL)); 2392 delegate.get(), -1234, bounds, root_window()));
2393 2393
2394 const int kSteps = 15; 2394 const int kSteps = 15;
2395 const int kTouchPoints = 4; 2395 const int kTouchPoints = 4;
2396 gfx::Point points[kTouchPoints] = { 2396 gfx::Point points[kTouchPoints] = {
2397 gfx::Point(10, 30), 2397 gfx::Point(10, 30),
2398 gfx::Point(30, 20), 2398 gfx::Point(30, 20),
2399 gfx::Point(50, 30), 2399 gfx::Point(50, 30),
2400 gfx::Point(80, 50) 2400 gfx::Point(80, 50)
2401 }; 2401 };
2402 2402
(...skipping 23 matching lines...) Expand all
2426 new GestureEventConsumeDelegate()); 2426 new GestureEventConsumeDelegate());
2427 const int kWindowWidth = 123; 2427 const int kWindowWidth = 123;
2428 const int kWindowHeight = 45; 2428 const int kWindowHeight = 45;
2429 const int kTouchId1 = 2; 2429 const int kTouchId1 = 2;
2430 const int kTouchId2 = 3; 2430 const int kTouchId2 = 3;
2431 2431
2432 // Test canceling first finger. 2432 // Test canceling first finger.
2433 { 2433 {
2434 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2434 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2435 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2435 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2436 delegate.get(), -1234, bounds, NULL)); 2436 delegate.get(), -1234, bounds, root_window()));
2437 2437
2438 delegate->Reset(); 2438 delegate->Reset();
2439 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2439 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2440 kTouchId1, GetTime()); 2440 kTouchId1, GetTime());
2441 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2441 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2442 2442
2443 delegate->Reset(); 2443 delegate->Reset();
2444 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2444 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2445 kTouchId2, GetTime()); 2445 kTouchId2, GetTime());
2446 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2446 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
(...skipping 12 matching lines...) Expand all
2459 base::TimeDelta::FromMilliseconds(50)); 2459 base::TimeDelta::FromMilliseconds(50));
2460 2460
2461 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 2461 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
2462 EXPECT_FALSE(delegate->two_finger_tap()); 2462 EXPECT_FALSE(delegate->two_finger_tap());
2463 } 2463 }
2464 2464
2465 // Test canceling second finger 2465 // Test canceling second finger
2466 { 2466 {
2467 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2467 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2468 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2468 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2469 delegate.get(), -1234, bounds, NULL)); 2469 delegate.get(), -1234, bounds, root_window()));
2470 2470
2471 delegate->Reset(); 2471 delegate->Reset();
2472 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2472 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2473 kTouchId1, GetTime()); 2473 kTouchId1, GetTime());
2474 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2474 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2475 2475
2476 delegate->Reset(); 2476 delegate->Reset();
2477 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), 2477 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201),
2478 kTouchId2, GetTime()); 2478 kTouchId2, GetTime());
2479 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2479 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
(...skipping 18 matching lines...) Expand all
2498 2498
2499 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) { 2499 TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
2500 scoped_ptr<GestureEventConsumeDelegate> delegate( 2500 scoped_ptr<GestureEventConsumeDelegate> delegate(
2501 new GestureEventConsumeDelegate()); 2501 new GestureEventConsumeDelegate());
2502 const int kWindowWidth = 523; 2502 const int kWindowWidth = 523;
2503 const int kWindowHeight = 45; 2503 const int kWindowHeight = 45;
2504 const int kTouchId1 = 2; 2504 const int kTouchId1 = 2;
2505 const int kTouchId2 = 3; 2505 const int kTouchId2 = 3;
2506 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2506 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2507 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2507 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2508 delegate.get(), -1234, bounds, NULL)); 2508 delegate.get(), -1234, bounds, root_window()));
2509 2509
2510 delegate->Reset(); 2510 delegate->Reset();
2511 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2511 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2512 kTouchId1, GetTime()); 2512 kTouchId1, GetTime());
2513 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2513 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2514 EXPECT_FALSE(delegate->tap()); 2514 EXPECT_FALSE(delegate->tap());
2515 EXPECT_TRUE(delegate->tap_down()); 2515 EXPECT_TRUE(delegate->tap_down());
2516 EXPECT_FALSE(delegate->tap_cancel()); 2516 EXPECT_FALSE(delegate->tap_cancel());
2517 EXPECT_FALSE(delegate->double_tap()); 2517 EXPECT_FALSE(delegate->double_tap());
2518 EXPECT_FALSE(delegate->scroll_begin()); 2518 EXPECT_FALSE(delegate->scroll_begin());
(...skipping 18 matching lines...) Expand all
2537 EXPECT_TRUE(delegate->pinch_begin()); 2537 EXPECT_TRUE(delegate->pinch_begin());
2538 } 2538 }
2539 2539
2540 // Verifies if a window is the target of multiple touch-ids and we hide the 2540 // Verifies if a window is the target of multiple touch-ids and we hide the
2541 // window everything is cleaned up correctly. 2541 // window everything is cleaned up correctly.
2542 TEST_F(GestureRecognizerTest, FlushAllOnHide) { 2542 TEST_F(GestureRecognizerTest, FlushAllOnHide) {
2543 scoped_ptr<GestureEventConsumeDelegate> delegate( 2543 scoped_ptr<GestureEventConsumeDelegate> delegate(
2544 new GestureEventConsumeDelegate()); 2544 new GestureEventConsumeDelegate());
2545 gfx::Rect bounds(0, 0, 200, 200); 2545 gfx::Rect bounds(0, 0, 200, 200);
2546 scoped_ptr<aura::Window> window( 2546 scoped_ptr<aura::Window> window(
2547 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, NULL)); 2547 CreateTestWindowWithDelegate(delegate.get(), 0, bounds, root_window()));
2548 const int kTouchId1 = 8; 2548 const int kTouchId1 = 8;
2549 const int kTouchId2 = 2; 2549 const int kTouchId2 = 2;
2550 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 2550 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10),
2551 kTouchId1, GetTime()); 2551 kTouchId1, GetTime());
2552 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2552 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2553 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 2553 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20),
2554 kTouchId2, GetTime()); 2554 kTouchId2, GetTime());
2555 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); 2555 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
2556 window->Hide(); 2556 window->Hide();
2557 EXPECT_EQ(NULL, 2557 EXPECT_EQ(NULL,
2558 root_window()->gesture_recognizer()->GetTouchLockedTarget(&press1)); 2558 root_window()->gesture_recognizer()->GetTouchLockedTarget(&press1));
2559 EXPECT_EQ(NULL, 2559 EXPECT_EQ(NULL,
2560 root_window()->gesture_recognizer()->GetTouchLockedTarget(&press2)); 2560 root_window()->gesture_recognizer()->GetTouchLockedTarget(&press2));
2561 } 2561 }
2562 2562
2563 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) { 2563 TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) {
2564 scoped_ptr<QueueTouchEventDelegate> delegate( 2564 scoped_ptr<QueueTouchEventDelegate> delegate(
2565 new QueueTouchEventDelegate(root_window())); 2565 new QueueTouchEventDelegate(root_window()));
2566 const int kTouchId = 2; 2566 const int kTouchId = 2;
2567 gfx::Rect bounds(100, 200, 100, 100); 2567 gfx::Rect bounds(100, 200, 100, 100);
2568 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2568 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2569 delegate.get(), -1234, bounds, NULL)); 2569 delegate.get(), -1234, bounds, root_window()));
2570 delegate->set_window(window.get()); 2570 delegate->set_window(window.get());
2571 2571
2572 TimerTestGestureRecognizer* gesture_recognizer = 2572 TimerTestGestureRecognizer* gesture_recognizer =
2573 new TimerTestGestureRecognizer(root_window()); 2573 new TimerTestGestureRecognizer(root_window());
2574 TimerTestGestureSequence* gesture_sequence = 2574 TimerTestGestureSequence* gesture_sequence =
2575 static_cast<TimerTestGestureSequence*>( 2575 static_cast<TimerTestGestureSequence*>(
2576 gesture_recognizer->GetGestureSequenceForTesting(window.get())); 2576 gesture_recognizer->GetGestureSequenceForTesting(window.get()));
2577 2577
2578 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 2578 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
2579 2579
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 // Same as GestureEventScroll, but tests that the behavior is the same 2619 // Same as GestureEventScroll, but tests that the behavior is the same
2620 // even if all the touch-move events are consumed. 2620 // even if all the touch-move events are consumed.
2621 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) { 2621 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
2622 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 2622 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
2623 new ConsumesTouchMovesDelegate()); 2623 new ConsumesTouchMovesDelegate());
2624 const int kWindowWidth = 123; 2624 const int kWindowWidth = 123;
2625 const int kWindowHeight = 45; 2625 const int kWindowHeight = 45;
2626 const int kTouchId = 5; 2626 const int kTouchId = 5;
2627 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2627 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2628 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2628 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2629 delegate.get(), -1234, bounds, NULL)); 2629 delegate.get(), -1234, bounds, root_window()));
2630 2630
2631 delegate->Reset(); 2631 delegate->Reset();
2632 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2632 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2633 kTouchId, GetTime()); 2633 kTouchId, GetTime());
2634 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2634 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
2635 EXPECT_FALSE(delegate->tap()); 2635 EXPECT_FALSE(delegate->tap());
2636 EXPECT_TRUE(delegate->tap_down()); 2636 EXPECT_TRUE(delegate->tap_down());
2637 EXPECT_FALSE(delegate->tap_cancel()); 2637 EXPECT_FALSE(delegate->tap_cancel());
2638 EXPECT_TRUE(delegate->begin()); 2638 EXPECT_TRUE(delegate->begin());
2639 EXPECT_FALSE(delegate->double_tap()); 2639 EXPECT_FALSE(delegate->double_tap());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 // depending on whether the events were consumed before or after the scroll 2678 // depending on whether the events were consumed before or after the scroll
2679 // started. 2679 // started.
2680 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) { 2680 TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
2681 scoped_ptr<ConsumesTouchMovesDelegate> delegate( 2681 scoped_ptr<ConsumesTouchMovesDelegate> delegate(
2682 new ConsumesTouchMovesDelegate()); 2682 new ConsumesTouchMovesDelegate());
2683 const int kWindowWidth = 123; 2683 const int kWindowWidth = 123;
2684 const int kWindowHeight = 45; 2684 const int kWindowHeight = 45;
2685 const int kTouchId = 5; 2685 const int kTouchId = 5;
2686 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2686 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2687 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2687 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2688 delegate.get(), -1234, bounds, NULL)); 2688 delegate.get(), -1234, bounds, root_window()));
2689 2689
2690 delegate->Reset(); 2690 delegate->Reset();
2691 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2691 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2692 kTouchId, GetTime()); 2692 kTouchId, GetTime());
2693 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 2693 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
2694 EXPECT_FALSE(delegate->tap()); 2694 EXPECT_FALSE(delegate->tap());
2695 EXPECT_TRUE(delegate->tap_down()); 2695 EXPECT_TRUE(delegate->tap_down());
2696 EXPECT_FALSE(delegate->tap_cancel()); 2696 EXPECT_FALSE(delegate->tap_cancel());
2697 EXPECT_TRUE(delegate->begin()); 2697 EXPECT_TRUE(delegate->begin());
2698 EXPECT_FALSE(delegate->double_tap()); 2698 EXPECT_FALSE(delegate->double_tap());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2782 2782
2783 // Check that appropriate touch events generate double tap gesture events. 2783 // Check that appropriate touch events generate double tap gesture events.
2784 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) { 2784 TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
2785 scoped_ptr<GestureEventConsumeDelegate> delegate( 2785 scoped_ptr<GestureEventConsumeDelegate> delegate(
2786 new GestureEventConsumeDelegate()); 2786 new GestureEventConsumeDelegate());
2787 const int kWindowWidth = 123; 2787 const int kWindowWidth = 123;
2788 const int kWindowHeight = 45; 2788 const int kWindowHeight = 45;
2789 const int kTouchId = 2; 2789 const int kTouchId = 2;
2790 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2790 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2791 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2791 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2792 delegate.get(), -1234, bounds, NULL)); 2792 delegate.get(), -1234, bounds, root_window()));
2793 2793
2794 // First tap (tested in GestureEventTap) 2794 // First tap (tested in GestureEventTap)
2795 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), 2795 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(104, 201),
2796 kTouchId, GetTime()); 2796 kTouchId, GetTime());
2797 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2797 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2798 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), 2798 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(104, 201),
2799 kTouchId, press1.time_stamp() + 2799 kTouchId, press1.time_stamp() +
2800 base::TimeDelta::FromMilliseconds(50)); 2800 base::TimeDelta::FromMilliseconds(50));
2801 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 2801 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
2802 delegate->Reset(); 2802 delegate->Reset();
(...skipping 23 matching lines...) Expand all
2826 2826
2827 // Check that we don't get a double tap when the two taps are far apart. 2827 // Check that we don't get a double tap when the two taps are far apart.
2828 TEST_F(GestureRecognizerTest, TwoTapsFarApart) { 2828 TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
2829 scoped_ptr<GestureEventConsumeDelegate> delegate( 2829 scoped_ptr<GestureEventConsumeDelegate> delegate(
2830 new GestureEventConsumeDelegate()); 2830 new GestureEventConsumeDelegate());
2831 const int kWindowWidth = 123; 2831 const int kWindowWidth = 123;
2832 const int kWindowHeight = 45; 2832 const int kWindowHeight = 45;
2833 const int kTouchId = 2; 2833 const int kTouchId = 2;
2834 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2834 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2835 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2835 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2836 delegate.get(), -1234, bounds, NULL)); 2836 delegate.get(), -1234, bounds, root_window()));
2837 2837
2838 // First tap (tested in GestureEventTap) 2838 // First tap (tested in GestureEventTap)
2839 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2839 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2840 kTouchId, GetTime()); 2840 kTouchId, GetTime());
2841 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2841 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2842 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2842 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2843 kTouchId, press1.time_stamp() + 2843 kTouchId, press1.time_stamp() +
2844 base::TimeDelta::FromMilliseconds(50)); 2844 base::TimeDelta::FromMilliseconds(50));
2845 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 2845 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
2846 delegate->Reset(); 2846 delegate->Reset();
(...skipping 24 matching lines...) Expand all
2871 // Check that we don't get a double tap when the two taps have a long enough 2871 // Check that we don't get a double tap when the two taps have a long enough
2872 // delay in between. 2872 // delay in between.
2873 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) { 2873 TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
2874 scoped_ptr<GestureEventConsumeDelegate> delegate( 2874 scoped_ptr<GestureEventConsumeDelegate> delegate(
2875 new GestureEventConsumeDelegate()); 2875 new GestureEventConsumeDelegate());
2876 const int kWindowWidth = 123; 2876 const int kWindowWidth = 123;
2877 const int kWindowHeight = 45; 2877 const int kWindowHeight = 45;
2878 const int kTouchId = 2; 2878 const int kTouchId = 2;
2879 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2879 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2880 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2880 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2881 delegate.get(), -1234, bounds, NULL)); 2881 delegate.get(), -1234, bounds, root_window()));
2882 2882
2883 // First tap (tested in GestureEventTap) 2883 // First tap (tested in GestureEventTap)
2884 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), 2884 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201),
2885 kTouchId, GetTime()); 2885 kTouchId, GetTime());
2886 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2886 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2887 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), 2887 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
2888 kTouchId, press1.time_stamp() + 2888 kTouchId, press1.time_stamp() +
2889 base::TimeDelta::FromMilliseconds(50)); 2889 base::TimeDelta::FromMilliseconds(50));
2890 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1); 2890 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release1);
2891 delegate->Reset(); 2891 delegate->Reset();
(...skipping 25 matching lines...) Expand all
2917 // radius of a touch-point, and not because of change in position, then there 2917 // radius of a touch-point, and not because of change in position, then there
2918 // are not gesture events from that. 2918 // are not gesture events from that.
2919 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { 2919 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
2920 scoped_ptr<GestureEventConsumeDelegate> delegate( 2920 scoped_ptr<GestureEventConsumeDelegate> delegate(
2921 new GestureEventConsumeDelegate()); 2921 new GestureEventConsumeDelegate());
2922 const int kWindowWidth = 234; 2922 const int kWindowWidth = 234;
2923 const int kWindowHeight = 345; 2923 const int kWindowHeight = 345;
2924 const int kTouchId = 5, kTouchId2 = 7; 2924 const int kTouchId = 5, kTouchId2 = 7;
2925 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2925 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2926 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2926 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2927 delegate.get(), -1234, bounds, NULL)); 2927 delegate.get(), -1234, bounds, root_window()));
2928 2928
2929 ui::TouchEvent press1( 2929 ui::TouchEvent press1(
2930 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, GetTime()); 2930 ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, GetTime());
2931 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2931 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2932 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); 2932 EXPECT_TRUE(delegate->bounding_box().IsEmpty());
2933 2933
2934 delegate->Reset(); 2934 delegate->Reset();
2935 2935
2936 ui::TouchEvent press2( 2936 ui::TouchEvent press2(
2937 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2, 2937 ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2972 TEST_F(GestureRecognizerTest, NoDriftInScroll) { 2972 TEST_F(GestureRecognizerTest, NoDriftInScroll) {
2973 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3); 2973 ui::GestureConfiguration::set_max_touch_move_in_pixels_for_click(3);
2974 ui::GestureConfiguration::set_min_scroll_delta_squared(9); 2974 ui::GestureConfiguration::set_min_scroll_delta_squared(9);
2975 scoped_ptr<GestureEventConsumeDelegate> delegate( 2975 scoped_ptr<GestureEventConsumeDelegate> delegate(
2976 new GestureEventConsumeDelegate()); 2976 new GestureEventConsumeDelegate());
2977 const int kWindowWidth = 234; 2977 const int kWindowWidth = 234;
2978 const int kWindowHeight = 345; 2978 const int kWindowHeight = 345;
2979 const int kTouchId = 5; 2979 const int kTouchId = 5;
2980 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 2980 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
2981 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 2981 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
2982 delegate.get(), -1234, bounds, NULL)); 2982 delegate.get(), -1234, bounds, root_window()));
2983 2983
2984 ui::TouchEvent press1( 2984 ui::TouchEvent press1(
2985 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, GetTime()); 2985 ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), kTouchId, GetTime());
2986 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); 2986 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1);
2987 EXPECT_TRUE(delegate->begin()); 2987 EXPECT_TRUE(delegate->begin());
2988 2988
2989 delegate->Reset(); 2989 delegate->Reset();
2990 2990
2991 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId, 2991 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(101, 206), kTouchId,
2992 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); 2992 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40));
(...skipping 23 matching lines...) Expand all
3016 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); 3016 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40));
3017 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4); 3017 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move4);
3018 EXPECT_TRUE(delegate->scroll_update()); 3018 EXPECT_TRUE(delegate->scroll_update());
3019 EXPECT_EQ(-1, delegate->scroll_y()); 3019 EXPECT_EQ(-1, delegate->scroll_y());
3020 3020
3021 delegate->Reset(); 3021 delegate->Reset();
3022 } 3022 }
3023 3023
3024 } // namespace test 3024 } // namespace test
3025 } // namespace aura 3025 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698