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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 821 |
822 TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { | 822 TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { |
823 CaptureWindowDelegateImpl delegate1; | 823 CaptureWindowDelegateImpl delegate1; |
824 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( | 824 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( |
825 &delegate1, 0, gfx::Rect(0, 0, 50, 50), root_window())); | 825 &delegate1, 0, gfx::Rect(0, 0, 50, 50), root_window())); |
826 CaptureWindowDelegateImpl delegate2; | 826 CaptureWindowDelegateImpl delegate2; |
827 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( | 827 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( |
828 &delegate2, 0, gfx::Rect(50, 50, 50, 50), root_window())); | 828 &delegate2, 0, gfx::Rect(50, 50, 50, 50), root_window())); |
829 | 829 |
830 // Press on w1. | 830 // Press on w1. |
831 ui::TouchEvent press( | 831 ui::TouchEvent press1( |
832 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); | 832 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
833 DispatchEventUsingWindowDispatcher(&press); | 833 DispatchEventUsingWindowDispatcher(&press1); |
834 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 834 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
835 EXPECT_EQ(2, delegate1.gesture_event_count()); | 835 EXPECT_EQ(2, delegate1.gesture_event_count()); |
836 delegate1.ResetCounts(); | 836 delegate1.ResetCounts(); |
837 | 837 |
838 // Capturing to w2 should cause the touch to be canceled. | 838 // Capturing to w2 should cause the touch to be canceled. |
839 w2->SetCapture(); | 839 w2->SetCapture(); |
840 EXPECT_EQ(1, delegate1.touch_event_count()); | 840 EXPECT_EQ(1, delegate1.touch_event_count()); |
841 EXPECT_EQ(0, delegate2.touch_event_count()); | 841 EXPECT_EQ(0, delegate2.touch_event_count()); |
842 delegate1.ResetCounts(); | 842 delegate1.ResetCounts(); |
843 delegate2.ResetCounts(); | 843 delegate2.ResetCounts(); |
844 | 844 |
845 // Events now go to w2. | 845 // Events are ignored by w2, as it's receiving a partial touch stream. |
846 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 0, getTime()); | 846 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 0, getTime()); |
847 DispatchEventUsingWindowDispatcher(&move); | 847 DispatchEventUsingWindowDispatcher(&move); |
848 EXPECT_EQ(0, delegate1.gesture_event_count()); | 848 EXPECT_EQ(0, delegate1.gesture_event_count()); |
849 EXPECT_EQ(0, delegate1.touch_event_count()); | 849 EXPECT_EQ(0, delegate1.touch_event_count()); |
850 EXPECT_EQ(0, delegate2.gesture_event_count()); | 850 EXPECT_EQ(0, delegate2.gesture_event_count()); |
851 EXPECT_EQ(1, delegate2.touch_event_count()); | 851 EXPECT_EQ(0, delegate2.touch_event_count()); |
852 | 852 |
853 ui::TouchEvent release( | 853 ui::TouchEvent release( |
854 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0, getTime()); | 854 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0, getTime()); |
855 DispatchEventUsingWindowDispatcher(&release); | 855 DispatchEventUsingWindowDispatcher(&release); |
856 EXPECT_EQ(0, delegate1.gesture_event_count()); | 856 EXPECT_EQ(0, delegate1.gesture_event_count()); |
857 EXPECT_EQ(0, delegate2.gesture_event_count()); | 857 EXPECT_EQ(0, delegate2.gesture_event_count()); |
858 | 858 |
859 // A new press is captured by w2. | 859 // A new press is captured by w2. |
860 ui::TouchEvent press2( | 860 ui::TouchEvent press2( |
861 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); | 861 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3438 | 3438 |
3439 EXPECT_TRUE(animator); | 3439 EXPECT_TRUE(animator); |
3440 EXPECT_FALSE(animator->is_animating()); | 3440 EXPECT_FALSE(animator->is_animating()); |
3441 EXPECT_TRUE(observer.animation_completed()); | 3441 EXPECT_TRUE(observer.animation_completed()); |
3442 EXPECT_FALSE(observer.animation_aborted()); | 3442 EXPECT_FALSE(observer.animation_aborted()); |
3443 animator->RemoveObserver(&observer); | 3443 animator->RemoveObserver(&observer); |
3444 } | 3444 } |
3445 | 3445 |
3446 } // namespace test | 3446 } // namespace test |
3447 } // namespace aura | 3447 } // namespace aura |
OLD | NEW |