OLD | NEW |
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/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
7 #include "base/timer.h" | 7 #include "base/timer.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
(...skipping 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 EXPECT_TRUE(delegate->begin()); | 2509 EXPECT_TRUE(delegate->begin()); |
2510 EXPECT_TRUE(delegate->end()); | 2510 EXPECT_TRUE(delegate->end()); |
2511 EXPECT_FALSE(delegate->double_tap()); | 2511 EXPECT_FALSE(delegate->double_tap()); |
2512 EXPECT_FALSE(delegate->scroll_begin()); | 2512 EXPECT_FALSE(delegate->scroll_begin()); |
2513 EXPECT_FALSE(delegate->scroll_update()); | 2513 EXPECT_FALSE(delegate->scroll_update()); |
2514 EXPECT_FALSE(delegate->scroll_end()); | 2514 EXPECT_FALSE(delegate->scroll_end()); |
2515 | 2515 |
2516 EXPECT_EQ(1, delegate->tap_count()); | 2516 EXPECT_EQ(1, delegate->tap_count()); |
2517 } | 2517 } |
2518 | 2518 |
| 2519 // Checks that if the bounding-box of a gesture changes because of change in |
| 2520 // radius of a touch-point, and not because of change in position, then there |
| 2521 // are not gesture events from that. |
| 2522 TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) { |
| 2523 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 2524 new GestureEventConsumeDelegate()); |
| 2525 const int kWindowWidth = 234; |
| 2526 const int kWindowHeight = 345; |
| 2527 const int kTouchId = 5, kTouchId2 = 7; |
| 2528 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 2529 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 2530 delegate.get(), -1234, bounds, NULL)); |
| 2531 |
| 2532 TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), kTouchId, |
| 2533 GetTime()); |
| 2534 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press1); |
| 2535 EXPECT_TRUE(delegate->bounding_box().IsEmpty()); |
| 2536 |
| 2537 delegate->Reset(); |
| 2538 |
| 2539 TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), kTouchId2, |
| 2540 press1.time_stamp() + base::TimeDelta::FromMilliseconds(400)); |
| 2541 press2.set_radius_x(5); |
| 2542 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
| 2543 EXPECT_FALSE(delegate->pinch_begin()); |
| 2544 |
| 2545 delegate->Reset(); |
| 2546 |
| 2547 TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(141, 201), kTouchId, |
| 2548 press1.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
| 2549 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move1); |
| 2550 EXPECT_TRUE(delegate->pinch_begin()); |
| 2551 EXPECT_EQ(gfx::Rect(141, 196, 65, 10).ToString(), |
| 2552 delegate->bounding_box().ToString()); |
| 2553 |
| 2554 delegate->Reset(); |
| 2555 |
| 2556 // The position doesn't move, but the radius changes. |
| 2557 TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(101, 201), kTouchId, |
| 2558 press2.time_stamp() + base::TimeDelta::FromMilliseconds(40)); |
| 2559 move2.set_radius_x(50); |
| 2560 move2.set_radius_y(60); |
| 2561 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); |
| 2562 EXPECT_FALSE(delegate->tap()); |
| 2563 EXPECT_FALSE(delegate->scroll_update()); |
| 2564 EXPECT_FALSE(delegate->pinch_update()); |
| 2565 |
| 2566 delegate->Reset(); |
| 2567 } |
| 2568 |
2519 } // namespace test | 2569 } // namespace test |
2520 } // namespace aura | 2570 } // namespace aura |
OLD | NEW |