OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/at_exit.h" |
| 6 #include "base/message_loop.h" |
| 7 #include "base/timer.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/xorg-gtest/include/xorg/gtest/environment.h" |
| 10 #include "third_party/xorg-gtest/include/xorg/gtest/evemu/device.h" |
| 11 #include "third_party/xorg-gtest/include/xorg/gtest/test.h" |
| 12 #include "ui/aura/event.h" |
| 13 #include "ui/aura/gestures/gesture_recognizer_grail.h" |
| 14 #include "ui/aura/root_window.h" |
| 15 #include "ui/aura/test/aura_test_base.h" |
| 16 #include "ui/aura/test/test_stacking_client.h" |
| 17 #include "ui/aura/test/test_window_delegate.h" |
| 18 #include "ui/aura/test/test_windows.h" |
| 19 #include "ui/base/hit_test.h" |
| 20 #include "ui/gfx/point.h" |
| 21 #include "ui/gfx/rect.h" |
| 22 |
| 23 // Starts and sets up a dummy (read: headless) xserver on display port 133. |
| 24 // Log of the server can be found at /tmp/Xorg.GTest.log. |
| 25 ::testing::Environment* const foo_env = |
| 26 ::testing::AddGlobalTestEnvironment(new ::xorg::testing::Environment()); |
| 27 |
| 28 namespace aura { |
| 29 namespace test { |
| 30 |
| 31 namespace { |
| 32 |
| 33 // A delegate that keeps track of gesture events. |
| 34 class GestureEventConsumeDelegate : public TestWindowDelegate { |
| 35 public: |
| 36 GestureEventConsumeDelegate() |
| 37 : tap_(false), |
| 38 tap_down_(false), |
| 39 double_tap_(false), |
| 40 scroll_begin_(false), |
| 41 scroll_update_(false), |
| 42 scroll_end_(false), |
| 43 pinch_begin_(false), |
| 44 pinch_update_(false), |
| 45 pinch_end_(false), |
| 46 long_press_(false), |
| 47 scroll_x_(0), |
| 48 scroll_y_(0), |
| 49 velocity_x_(0), |
| 50 velocity_y_(0) { |
| 51 } |
| 52 |
| 53 virtual ~GestureEventConsumeDelegate() {} |
| 54 |
| 55 void Reset() { |
| 56 tap_ = false; |
| 57 tap_down_ = false; |
| 58 double_tap_ = false; |
| 59 scroll_begin_ = false; |
| 60 scroll_update_ = false; |
| 61 scroll_end_ = false; |
| 62 pinch_begin_ = false; |
| 63 pinch_update_ = false; |
| 64 pinch_end_ = false; |
| 65 long_press_ = false; |
| 66 |
| 67 scroll_begin_position_.SetPoint(0, 0); |
| 68 |
| 69 scroll_x_ = 0; |
| 70 scroll_y_ = 0; |
| 71 velocity_x_ = 0; |
| 72 velocity_y_ = 0; |
| 73 } |
| 74 |
| 75 bool tap() const { return tap_; } |
| 76 bool tap_down() const { return tap_down_; } |
| 77 bool double_tap() const { return double_tap_; } |
| 78 bool scroll_begin() const { return scroll_begin_; } |
| 79 bool scroll_update() const { return scroll_update_; } |
| 80 bool scroll_end() const { return scroll_end_; } |
| 81 bool pinch_begin() const { return pinch_begin_; } |
| 82 bool pinch_update() const { return pinch_update_; } |
| 83 bool pinch_end() const { return pinch_end_; } |
| 84 bool long_press() const { return long_press_; } |
| 85 |
| 86 const gfx::Point scroll_begin_position() const { |
| 87 return scroll_begin_position_; |
| 88 } |
| 89 |
| 90 float scroll_x() const { return scroll_x_; } |
| 91 float scroll_y() const { return scroll_y_; } |
| 92 int touch_id() const { return touch_id_; } |
| 93 float velocity_x() const { return velocity_x_; } |
| 94 float velocity_y() const { return velocity_y_; } |
| 95 |
| 96 virtual ui::GestureStatus OnGestureEvent(GestureEvent* gesture) OVERRIDE { |
| 97 switch (gesture->type()) { |
| 98 case ui::ET_GESTURE_TAP: |
| 99 tap_ = true; |
| 100 break; |
| 101 case ui::ET_GESTURE_TAP_DOWN: |
| 102 tap_down_ = true; |
| 103 break; |
| 104 case ui::ET_GESTURE_DOUBLE_TAP: |
| 105 double_tap_ = true; |
| 106 break; |
| 107 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 108 scroll_begin_ = true; |
| 109 scroll_begin_position_ = gesture->location(); |
| 110 break; |
| 111 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 112 scroll_update_ = true; |
| 113 scroll_x_ += gesture->delta_x(); |
| 114 scroll_y_ += gesture->delta_y(); |
| 115 break; |
| 116 case ui::ET_GESTURE_SCROLL_END: |
| 117 velocity_x_ = gesture->delta_x(); |
| 118 velocity_y_ = gesture->delta_y(); |
| 119 scroll_end_ = true; |
| 120 break; |
| 121 case ui::ET_GESTURE_PINCH_BEGIN: |
| 122 pinch_begin_ = true; |
| 123 break; |
| 124 case ui::ET_GESTURE_PINCH_UPDATE: |
| 125 pinch_update_ = true; |
| 126 break; |
| 127 case ui::ET_GESTURE_PINCH_END: |
| 128 pinch_end_ = true; |
| 129 break; |
| 130 case ui::ET_GESTURE_LONG_PRESS: |
| 131 long_press_ = true; |
| 132 touch_id_ = gesture->point_id(); |
| 133 break; |
| 134 default: |
| 135 NOTREACHED(); |
| 136 } |
| 137 return ui::GESTURE_STATUS_CONSUMED; |
| 138 } |
| 139 |
| 140 private: |
| 141 bool tap_; |
| 142 bool tap_down_; |
| 143 bool double_tap_; |
| 144 bool scroll_begin_; |
| 145 bool scroll_update_; |
| 146 bool scroll_end_; |
| 147 bool pinch_begin_; |
| 148 bool pinch_update_; |
| 149 bool pinch_end_; |
| 150 bool long_press_; |
| 151 |
| 152 gfx::Point scroll_begin_position_; |
| 153 |
| 154 float scroll_x_; |
| 155 float scroll_y_; |
| 156 float velocity_x_; |
| 157 float velocity_y_; |
| 158 int touch_id_; |
| 159 |
| 160 DISALLOW_COPY_AND_ASSIGN(GestureEventConsumeDelegate); |
| 161 }; |
| 162 |
| 163 // A delegate that ignores gesture events but keeps track of [synthetic] mouse |
| 164 // events. |
| 165 class GestureEventSynthDelegate : public TestWindowDelegate { |
| 166 public: |
| 167 GestureEventSynthDelegate() |
| 168 : mouse_enter_(false), |
| 169 mouse_exit_(false), |
| 170 mouse_press_(false), |
| 171 mouse_release_(false), |
| 172 mouse_move_(false), |
| 173 double_click_(false) { |
| 174 } |
| 175 |
| 176 void Reset() { |
| 177 mouse_enter_ = false; |
| 178 mouse_exit_ = false; |
| 179 mouse_press_ = false; |
| 180 mouse_release_ = false; |
| 181 mouse_move_ = false; |
| 182 double_click_ = false; |
| 183 } |
| 184 |
| 185 bool mouse_enter() const { return mouse_enter_; } |
| 186 bool mouse_exit() const { return mouse_exit_; } |
| 187 bool mouse_press() const { return mouse_press_; } |
| 188 bool mouse_move() const { return mouse_move_; } |
| 189 bool mouse_release() const { return mouse_release_; } |
| 190 bool double_click() const { return double_click_; } |
| 191 |
| 192 virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE { |
| 193 switch (event->type()) { |
| 194 case ui::ET_MOUSE_PRESSED: |
| 195 double_click_ = event->flags() & ui::EF_IS_DOUBLE_CLICK; |
| 196 mouse_press_ = true; |
| 197 break; |
| 198 case ui::ET_MOUSE_RELEASED: |
| 199 mouse_release_ = true; |
| 200 break; |
| 201 case ui::ET_MOUSE_MOVED: |
| 202 mouse_move_ = true; |
| 203 break; |
| 204 case ui::ET_MOUSE_ENTERED: |
| 205 mouse_enter_ = true; |
| 206 break; |
| 207 case ui::ET_MOUSE_EXITED: |
| 208 mouse_exit_ = true; |
| 209 break; |
| 210 default: |
| 211 NOTREACHED(); |
| 212 } |
| 213 return true; |
| 214 } |
| 215 |
| 216 private: |
| 217 bool mouse_enter_; |
| 218 bool mouse_exit_; |
| 219 bool mouse_press_; |
| 220 bool mouse_release_; |
| 221 bool mouse_move_; |
| 222 bool double_click_; |
| 223 |
| 224 DISALLOW_COPY_AND_ASSIGN(GestureEventSynthDelegate); |
| 225 }; |
| 226 |
| 227 // Establishes a connection to an existing (dummy) xserver, |
| 228 // and initializes an aura root window. A device is created and |
| 229 // set up to replay sequences of touches from different devices. |
| 230 // The template-argument DeviceType is a means for injecting |
| 231 // paths to touch-sequence recordings in a device-dependent manner. |
| 232 template<typename DeviceType> |
| 233 class GestureRecognizerGrailTest : public xorg::testing::Test { |
| 234 public: |
| 235 GestureRecognizerGrailTest() |
| 236 : device_(DeviceType::DeviceFilePath()) { |
| 237 } |
| 238 |
| 239 virtual ~GestureRecognizerGrailTest() {} |
| 240 |
| 241 protected: |
| 242 void RunAllPendingInMessageLoop() { |
| 243 helper_.RunAllPendingInMessageLoop(root_window()); |
| 244 } |
| 245 |
| 246 RootWindow * root_window() { |
| 247 return root_window_.get(); |
| 248 } |
| 249 |
| 250 virtual void SetUp() OVERRIDE { |
| 251 xorg::testing::Test::SetUp(); |
| 252 root_window_.reset(new aura::RootWindow); |
| 253 helper_.InitRootWindow(root_window()); |
| 254 helper_.SetUp(); |
| 255 stacking_client_.reset(new TestStackingClient(root_window())); |
| 256 |
| 257 // Issue an inital touch to make sure that everything is setup correctly. |
| 258 TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0); |
| 259 root_window()->DispatchTouchEvent(&touchev); |
| 260 } |
| 261 |
| 262 virtual void TearDown() OVERRIDE { |
| 263 // Flush the message loop because we have pending release tasks |
| 264 // and these tasks if un-executed would upset Valgrind. |
| 265 RunAllPendingInMessageLoop(); |
| 266 |
| 267 stacking_client_.reset(); |
| 268 helper_.TearDown(); |
| 269 root_window_.reset(); |
| 270 |
| 271 xorg::testing::Test::TearDown(); |
| 272 } |
| 273 |
| 274 base::AtExitManager exit_manager_; |
| 275 AuraTestHelper helper_; |
| 276 scoped_ptr<RootWindow> root_window_; |
| 277 scoped_ptr<TestStackingClient> stacking_client_; |
| 278 ::xorg::testing::evemu::Device device_; |
| 279 |
| 280 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerGrailTest); |
| 281 }; |
| 282 |
| 283 // Model of DeviceType summarizing paths to |
| 284 // touch-sequences recorded with an apple magic trackpad. |
| 285 struct Trackpad { |
| 286 static const char * DeviceFilePath() { |
| 287 return "apple_magic_trackpad/device.prop"; |
| 288 } |
| 289 |
| 290 static const char * OneFingerTapRecording() { |
| 291 return "apple_magic_trackpad/one_finger_tap.record"; |
| 292 } |
| 293 |
| 294 static const char * TwoFingerTapRecording() { |
| 295 return "apple_magic_trackpad/two_finger_tap.record"; |
| 296 } |
| 297 |
| 298 static const char * OneFingerLongPressRecording() { |
| 299 return "apple_magic_trackpad/one_finger_long_press.record"; |
| 300 } |
| 301 |
| 302 static const char * TwoFingerLongPressRecording() { |
| 303 return "apple_magic_trackpad/two_finger_long_press.record"; |
| 304 } |
| 305 |
| 306 static const char * OneFingerDoubleTapRecording() { |
| 307 return "apple_magic_trackpad/one_finger_double_tap.record"; |
| 308 } |
| 309 |
| 310 static const char * TwoFingerDoubleTapRecording() { |
| 311 return "apple_magic_trackpad/two_finger_double_tap.record"; |
| 312 } |
| 313 |
| 314 static const char * TwoFingerDragRecording() { |
| 315 return "apple_magic_trackpad/two_finger_drag.record"; |
| 316 } |
| 317 |
| 318 static const char * TwoFingerPinchRecording() { |
| 319 return "apple_magic_trackpad/two_finger_pinch.record"; |
| 320 } |
| 321 }; |
| 322 |
| 323 // Model of DeviceType summarizing paths to |
| 324 // touch-sequences recorded on a dell touch screen. |
| 325 // |
| 326 // TODO(tvoss): Add required files here. |
| 327 struct TouchScreen { |
| 328 static const char * DeviceFilePath() { |
| 329 return "ntrig_dell_xt2/device.prop"; |
| 330 } |
| 331 }; |
| 332 |
| 333 } // namespace |
| 334 |
| 335 typedef AuraTestBase GestureRecognizerTest; |
| 336 |
| 337 typedef GestureRecognizerGrailTest<Trackpad> TrackpadTest; |
| 338 |
| 339 // Check that appropriate touch events generate tap gesture events. |
| 340 TEST_F(TrackpadTest, GestureEventOneFingerTap) { |
| 341 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 342 new GestureEventConsumeDelegate()); |
| 343 const int kWindowWidth = 1280; |
| 344 const int kWindowHeight = 800; |
| 345 |
| 346 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 347 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 348 delegate.get(), 0, bounds, root_window())); |
| 349 |
| 350 delegate->Reset(); |
| 351 |
| 352 device_.Play(Trackpad::OneFingerTapRecording()); |
| 353 RunAllPendingInMessageLoop(); |
| 354 |
| 355 EXPECT_TRUE(delegate->tap()); |
| 356 EXPECT_FALSE(delegate->tap_down()); |
| 357 EXPECT_FALSE(delegate->double_tap()); |
| 358 EXPECT_FALSE(delegate->scroll_begin()); |
| 359 EXPECT_FALSE(delegate->scroll_update()); |
| 360 EXPECT_FALSE(delegate->scroll_end()); |
| 361 EXPECT_FALSE(delegate->pinch_begin()); |
| 362 EXPECT_FALSE(delegate->pinch_update()); |
| 363 EXPECT_FALSE(delegate->pinch_end()); |
| 364 EXPECT_FALSE(delegate->long_press()); |
| 365 |
| 366 delegate->Reset(); |
| 367 } |
| 368 |
| 369 // Check that appropriate touch events generate tap gesture events. |
| 370 TEST_F(TrackpadTest, GestureEventTwoFingerTap) { |
| 371 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 372 new GestureEventConsumeDelegate()); |
| 373 const int kWindowWidth = 1280; |
| 374 const int kWindowHeight = 800; |
| 375 |
| 376 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 377 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 378 delegate.get(), -1234, bounds, NULL)); |
| 379 |
| 380 delegate->Reset(); |
| 381 |
| 382 device_.Play(Trackpad::TwoFingerTapRecording()); |
| 383 RunAllPendingInMessageLoop(); |
| 384 |
| 385 EXPECT_TRUE(delegate->tap()); |
| 386 EXPECT_FALSE(delegate->tap_down()); |
| 387 EXPECT_FALSE(delegate->double_tap()); |
| 388 EXPECT_FALSE(delegate->scroll_begin()); |
| 389 EXPECT_FALSE(delegate->scroll_update()); |
| 390 EXPECT_FALSE(delegate->scroll_end()); |
| 391 EXPECT_FALSE(delegate->pinch_begin()); |
| 392 EXPECT_FALSE(delegate->pinch_update()); |
| 393 EXPECT_FALSE(delegate->pinch_end()); |
| 394 EXPECT_FALSE(delegate->long_press()); |
| 395 |
| 396 delegate->Reset(); |
| 397 } |
| 398 |
| 399 // Check that appropriate touch events generate long-press gesture events. |
| 400 TEST_F(TrackpadTest, GestureEventOneFingerLongPress) { |
| 401 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 402 new GestureEventConsumeDelegate()); |
| 403 const int kWindowWidth = 1280; |
| 404 const int kWindowHeight = 800; |
| 405 |
| 406 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 407 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 408 delegate.get(), -1234, bounds, NULL)); |
| 409 |
| 410 delegate->Reset(); |
| 411 |
| 412 device_.Play(Trackpad::OneFingerLongPressRecording()); |
| 413 RunAllPendingInMessageLoop(); |
| 414 |
| 415 EXPECT_FALSE(delegate->tap()); |
| 416 EXPECT_FALSE(delegate->tap_down()); |
| 417 EXPECT_FALSE(delegate->double_tap()); |
| 418 EXPECT_FALSE(delegate->scroll_begin()); |
| 419 EXPECT_FALSE(delegate->scroll_update()); |
| 420 EXPECT_FALSE(delegate->scroll_end()); |
| 421 EXPECT_FALSE(delegate->pinch_begin()); |
| 422 EXPECT_FALSE(delegate->pinch_update()); |
| 423 EXPECT_FALSE(delegate->pinch_end()); |
| 424 EXPECT_TRUE(delegate->long_press()); |
| 425 |
| 426 delegate->Reset(); |
| 427 } |
| 428 |
| 429 // Check that appropriate touch events generate long-press gesture events. |
| 430 TEST_F(TrackpadTest, GestureEventTwoFingerLongPress) { |
| 431 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 432 new GestureEventConsumeDelegate()); |
| 433 const int kWindowWidth = 1280; |
| 434 const int kWindowHeight = 800; |
| 435 |
| 436 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 437 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 438 delegate.get(), -1234, bounds, NULL)); |
| 439 |
| 440 delegate->Reset(); |
| 441 |
| 442 device_.Play(Trackpad::TwoFingerLongPressRecording()); |
| 443 RunAllPendingInMessageLoop(); |
| 444 |
| 445 EXPECT_FALSE(delegate->tap()); |
| 446 EXPECT_FALSE(delegate->tap_down()); |
| 447 EXPECT_FALSE(delegate->double_tap()); |
| 448 EXPECT_FALSE(delegate->scroll_begin()); |
| 449 EXPECT_FALSE(delegate->scroll_update()); |
| 450 EXPECT_FALSE(delegate->scroll_end()); |
| 451 EXPECT_FALSE(delegate->pinch_begin()); |
| 452 EXPECT_FALSE(delegate->pinch_update()); |
| 453 EXPECT_FALSE(delegate->pinch_end()); |
| 454 EXPECT_TRUE(delegate->long_press()); |
| 455 |
| 456 delegate->Reset(); |
| 457 } |
| 458 |
| 459 // Check that appropriate touch events generate double tap gesture events. |
| 460 TEST_F(TrackpadTest, GestureEventOneFingerDoubleTap) { |
| 461 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 462 new GestureEventConsumeDelegate()); |
| 463 const int kWindowWidth = 1280; |
| 464 const int kWindowHeight = 800; |
| 465 |
| 466 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 467 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 468 delegate.get(), -1234, bounds, NULL)); |
| 469 |
| 470 delegate->Reset(); |
| 471 |
| 472 device_.Play(Trackpad::OneFingerDoubleTapRecording()); |
| 473 RunAllPendingInMessageLoop(); |
| 474 |
| 475 EXPECT_TRUE(delegate->tap()); |
| 476 EXPECT_FALSE(delegate->tap_down()); |
| 477 EXPECT_TRUE(delegate->double_tap()); |
| 478 EXPECT_FALSE(delegate->scroll_begin()); |
| 479 EXPECT_FALSE(delegate->scroll_update()); |
| 480 EXPECT_FALSE(delegate->scroll_end()); |
| 481 EXPECT_FALSE(delegate->pinch_begin()); |
| 482 EXPECT_FALSE(delegate->pinch_update()); |
| 483 EXPECT_FALSE(delegate->pinch_end()); |
| 484 EXPECT_FALSE(delegate->long_press()); |
| 485 |
| 486 delegate->Reset(); |
| 487 } |
| 488 |
| 489 // Check that appropriate touch events generate double tap gesture events. |
| 490 TEST_F(TrackpadTest, GestureEventTwoFingerDoubleTap) { |
| 491 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 492 new GestureEventConsumeDelegate()); |
| 493 const int kWindowWidth = 1280; |
| 494 const int kWindowHeight = 800; |
| 495 |
| 496 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 497 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 498 delegate.get(), -1234, bounds, NULL)); |
| 499 |
| 500 delegate->Reset(); |
| 501 |
| 502 device_.Play(Trackpad::TwoFingerDoubleTapRecording()); |
| 503 RunAllPendingInMessageLoop(); |
| 504 |
| 505 EXPECT_TRUE(delegate->tap()); |
| 506 EXPECT_FALSE(delegate->tap_down()); |
| 507 EXPECT_TRUE(delegate->double_tap()); |
| 508 EXPECT_FALSE(delegate->scroll_begin()); |
| 509 EXPECT_FALSE(delegate->scroll_update()); |
| 510 EXPECT_FALSE(delegate->scroll_end()); |
| 511 EXPECT_FALSE(delegate->pinch_begin()); |
| 512 EXPECT_FALSE(delegate->pinch_update()); |
| 513 EXPECT_FALSE(delegate->pinch_end()); |
| 514 EXPECT_FALSE(delegate->long_press()); |
| 515 |
| 516 delegate->Reset(); |
| 517 } |
| 518 |
| 519 // Check that appropriate touch events generate drag gesture events. |
| 520 TEST_F(TrackpadTest, GestureEventTwoFingerDrag) { |
| 521 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 522 new GestureEventConsumeDelegate()); |
| 523 const int kWindowWidth = 1280; |
| 524 const int kWindowHeight = 800; |
| 525 |
| 526 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 527 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 528 delegate.get(), -1234, bounds, NULL)); |
| 529 |
| 530 delegate->Reset(); |
| 531 |
| 532 device_.Play(Trackpad::TwoFingerDragRecording()); |
| 533 RunAllPendingInMessageLoop(); |
| 534 |
| 535 EXPECT_FALSE(delegate->tap()); |
| 536 EXPECT_FALSE(delegate->tap_down()); |
| 537 EXPECT_FALSE(delegate->double_tap()); |
| 538 EXPECT_TRUE(delegate->scroll_begin()); |
| 539 EXPECT_TRUE(delegate->scroll_update()); |
| 540 EXPECT_TRUE(delegate->scroll_end()); |
| 541 EXPECT_FALSE(delegate->pinch_begin()); |
| 542 EXPECT_FALSE(delegate->pinch_update()); |
| 543 EXPECT_FALSE(delegate->pinch_end()); |
| 544 EXPECT_FALSE(delegate->long_press()); |
| 545 |
| 546 delegate->Reset(); |
| 547 } |
| 548 |
| 549 // Check that appropriate touch events generate pinch gesture events. |
| 550 TEST_F(TrackpadTest, GestureEventTwoFingerPinch) { |
| 551 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 552 new GestureEventConsumeDelegate()); |
| 553 const int kWindowWidth = 1280; |
| 554 const int kWindowHeight = 800; |
| 555 |
| 556 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 557 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 558 delegate.get(), -1234, bounds, NULL)); |
| 559 |
| 560 delegate->Reset(); |
| 561 |
| 562 device_.Play(Trackpad::TwoFingerPinchRecording()); |
| 563 RunAllPendingInMessageLoop(); |
| 564 |
| 565 EXPECT_FALSE(delegate->tap()); |
| 566 EXPECT_FALSE(delegate->tap_down()); |
| 567 EXPECT_FALSE(delegate->double_tap()); |
| 568 EXPECT_FALSE(delegate->scroll_begin()); |
| 569 EXPECT_FALSE(delegate->scroll_update()); |
| 570 EXPECT_FALSE(delegate->scroll_end()); |
| 571 EXPECT_TRUE(delegate->pinch_begin()); |
| 572 EXPECT_TRUE(delegate->pinch_update()); |
| 573 EXPECT_TRUE(delegate->pinch_end()); |
| 574 EXPECT_FALSE(delegate->long_press()); |
| 575 |
| 576 delegate->Reset(); |
| 577 } |
| 578 |
| 579 } // namespace test |
| 580 } // namespace aura |
| 581 |
OLD | NEW |