| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 public: | 675 public: |
| 676 GestureRecognizerTest() {} | 676 GestureRecognizerTest() {} |
| 677 | 677 |
| 678 bool UsingUnifiedGR() { | 678 bool UsingUnifiedGR() { |
| 679 return GetParam(); | 679 return GetParam(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 virtual void SetUp() OVERRIDE { | 682 virtual void SetUp() OVERRIDE { |
| 683 // TODO(tdresser): Once unified GR has landed, only run these tests once. | 683 // TODO(tdresser): Once unified GR has landed, only run these tests once. |
| 684 if (UsingUnifiedGR()) { | 684 if (UsingUnifiedGR()) { |
| 685 CommandLine::ForCurrentProcess()->AppendSwitch( | 685 // TODO(tdresser): use unified GR once it's available. |
| 686 switches::kUseUnifiedGestureDetector); | 686 // CommandLine::ForCurrentProcess()->AppendSwitch( |
| 687 // switches::kUseUnifiedGestureDetector); |
| 687 } | 688 } |
| 688 | 689 |
| 689 AuraTestBase::SetUp(); | 690 AuraTestBase::SetUp(); |
| 690 } | 691 } |
| 691 | 692 |
| 692 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest); | 693 DISALLOW_COPY_AND_ASSIGN(GestureRecognizerTest); |
| 693 }; | 694 }; |
| 694 | 695 |
| 695 // Check that appropriate touch events generate tap gesture events. | 696 // Check that appropriate touch events generate tap gesture events. |
| 696 TEST_P(GestureRecognizerTest, GestureEventTap) { | 697 TEST_P(GestureRecognizerTest, GestureEventTap) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 EXPECT_FALSE(delegate->scroll_begin()); | 739 EXPECT_FALSE(delegate->scroll_begin()); |
| 739 EXPECT_FALSE(delegate->scroll_update()); | 740 EXPECT_FALSE(delegate->scroll_update()); |
| 740 EXPECT_FALSE(delegate->scroll_end()); | 741 EXPECT_FALSE(delegate->scroll_end()); |
| 741 | 742 |
| 742 EXPECT_EQ(1, delegate->tap_count()); | 743 EXPECT_EQ(1, delegate->tap_count()); |
| 743 } | 744 } |
| 744 | 745 |
| 745 // Check that appropriate touch events generate tap gesture events | 746 // Check that appropriate touch events generate tap gesture events |
| 746 // when information about the touch radii are provided. | 747 // when information about the touch radii are provided. |
| 747 TEST_P(GestureRecognizerTest, GestureEventTapRegion) { | 748 TEST_P(GestureRecognizerTest, GestureEventTapRegion) { |
| 748 // TODO(tdresser): enable this test with unified GR once we resolve the | |
| 749 // bounding box differences. See crbug.com/366641. | |
| 750 if (UsingUnifiedGR()) | |
| 751 return; | |
| 752 | |
| 753 scoped_ptr<GestureEventConsumeDelegate> delegate( | 749 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 754 new GestureEventConsumeDelegate()); | 750 new GestureEventConsumeDelegate()); |
| 755 TimedEvents tes; | 751 TimedEvents tes; |
| 756 const int kWindowWidth = 800; | 752 const int kWindowWidth = 800; |
| 757 const int kWindowHeight = 600; | 753 const int kWindowHeight = 600; |
| 758 const int kTouchId = 2; | 754 const int kTouchId = 2; |
| 759 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 755 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 760 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 756 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 761 delegate.get(), -1234, bounds, root_window())); | 757 delegate.get(), -1234, bounds, root_window())); |
| 762 | 758 |
| (...skipping 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3706 EXPECT_FALSE(delegate->tap_down()); | 3702 EXPECT_FALSE(delegate->tap_down()); |
| 3707 EXPECT_TRUE(delegate->tap_cancel()); | 3703 EXPECT_TRUE(delegate->tap_cancel()); |
| 3708 EXPECT_FALSE(delegate->begin()); | 3704 EXPECT_FALSE(delegate->begin()); |
| 3709 EXPECT_FALSE(delegate->scroll_begin()); | 3705 EXPECT_FALSE(delegate->scroll_begin()); |
| 3710 EXPECT_FALSE(delegate->scroll_update()); | 3706 EXPECT_FALSE(delegate->scroll_update()); |
| 3711 EXPECT_FALSE(delegate->scroll_end()); | 3707 EXPECT_FALSE(delegate->scroll_end()); |
| 3712 } | 3708 } |
| 3713 | 3709 |
| 3714 TEST_P(GestureRecognizerTest, | 3710 TEST_P(GestureRecognizerTest, |
| 3715 TransferEventDispatchesTouchCancel) { | 3711 TransferEventDispatchesTouchCancel) { |
| 3716 // TODO(tdresser): enable this test with unified GR once two finger tap is | |
| 3717 // supported. See crbug.com/354396. | |
| 3718 if (UsingUnifiedGR()) | |
| 3719 return; | |
| 3720 | |
| 3721 scoped_ptr<GestureEventConsumeDelegate> delegate( | 3712 scoped_ptr<GestureEventConsumeDelegate> delegate( |
| 3722 new GestureEventConsumeDelegate()); | 3713 new GestureEventConsumeDelegate()); |
| 3723 TimedEvents tes; | 3714 TimedEvents tes; |
| 3724 const int kWindowWidth = 800; | 3715 const int kWindowWidth = 800; |
| 3725 const int kWindowHeight = 600; | 3716 const int kWindowHeight = 600; |
| 3726 const int kTouchId = 2; | 3717 const int kTouchId = 2; |
| 3727 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); | 3718 gfx::Rect bounds(0, 0, kWindowWidth, kWindowHeight); |
| 3728 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 3719 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 3729 delegate.get(), -1234, bounds, root_window())); | 3720 delegate.get(), -1234, bounds, root_window())); |
| 3730 scoped_ptr<RemoveOnTouchCancelHandler> | 3721 scoped_ptr<RemoveOnTouchCancelHandler> |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4279 DispatchEventUsingWindowDispatcher(&move1); | 4270 DispatchEventUsingWindowDispatcher(&move1); |
| 4280 EXPECT_NE(default_flags, delegate->flags()); | 4271 EXPECT_NE(default_flags, delegate->flags()); |
| 4281 } | 4272 } |
| 4282 | 4273 |
| 4283 INSTANTIATE_TEST_CASE_P(GestureRecognizer, | 4274 INSTANTIATE_TEST_CASE_P(GestureRecognizer, |
| 4284 GestureRecognizerTest, | 4275 GestureRecognizerTest, |
| 4285 ::testing::Bool()); | 4276 ::testing::Bool()); |
| 4286 | 4277 |
| 4287 } // namespace test | 4278 } // namespace test |
| 4288 } // namespace aura | 4279 } // namespace aura |
| OLD | NEW |