Chromium Code Reviews| 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 ui::TouchEvent press2( | |
| 839 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, getTime()); | |
| 840 DispatchEventUsingWindowDispatcher(&press2); | |
|
sadrul
2014/08/01 21:00:06
This seems odd. Why is it necessary to dispatch a
tdresser
2014/08/05 14:40:14
No longer doing this.
| |
| 841 delegate1.ResetCounts(); | |
| 842 | |
| 838 // Capturing to w2 should cause the touch to be canceled. | 843 // Capturing to w2 should cause the touch to be canceled. |
| 839 w2->SetCapture(); | 844 w2->SetCapture(); |
| 840 EXPECT_EQ(1, delegate1.touch_event_count()); | 845 EXPECT_EQ(2, delegate1.touch_event_count()); |
| 841 EXPECT_EQ(0, delegate2.touch_event_count()); | 846 EXPECT_EQ(0, delegate2.touch_event_count()); |
| 842 delegate1.ResetCounts(); | 847 delegate1.ResetCounts(); |
| 843 delegate2.ResetCounts(); | 848 delegate2.ResetCounts(); |
| 844 | 849 |
| 845 // Events now go to w2. | 850 // 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()); | 851 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 0, getTime()); |
| 847 DispatchEventUsingWindowDispatcher(&move); | 852 DispatchEventUsingWindowDispatcher(&move); |
| 848 EXPECT_EQ(0, delegate1.gesture_event_count()); | 853 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 849 EXPECT_EQ(0, delegate1.touch_event_count()); | 854 EXPECT_EQ(0, delegate1.touch_event_count()); |
| 850 EXPECT_EQ(0, delegate2.gesture_event_count()); | 855 EXPECT_EQ(0, delegate2.gesture_event_count()); |
| 851 EXPECT_EQ(1, delegate2.touch_event_count()); | 856 EXPECT_EQ(0, delegate2.touch_event_count()); |
| 852 | 857 |
| 853 ui::TouchEvent release( | 858 ui::TouchEvent release( |
| 854 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0, getTime()); | 859 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0, getTime()); |
| 855 DispatchEventUsingWindowDispatcher(&release); | 860 DispatchEventUsingWindowDispatcher(&release); |
| 856 EXPECT_EQ(0, delegate1.gesture_event_count()); | 861 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 857 EXPECT_EQ(0, delegate2.gesture_event_count()); | 862 EXPECT_EQ(0, delegate2.gesture_event_count()); |
| 858 | 863 |
| 859 // A new press is captured by w2. | 864 // A new press is captured by w2. |
| 860 ui::TouchEvent press2( | 865 ui::TouchEvent press3( |
| 861 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); | 866 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
| 862 DispatchEventUsingWindowDispatcher(&press2); | 867 DispatchEventUsingWindowDispatcher(&press3); |
| 863 EXPECT_EQ(0, delegate1.gesture_event_count()); | 868 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 864 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 869 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
| 865 EXPECT_EQ(2, delegate2.gesture_event_count()); | 870 EXPECT_EQ(2, delegate2.gesture_event_count()); |
| 866 delegate1.ResetCounts(); | 871 delegate1.ResetCounts(); |
| 867 delegate2.ResetCounts(); | 872 delegate2.ResetCounts(); |
| 868 | 873 |
| 869 // And releasing capture changes nothing. | 874 // And releasing capture changes nothing. |
| 870 w2->ReleaseCapture(); | 875 w2->ReleaseCapture(); |
| 871 EXPECT_EQ(0, delegate1.gesture_event_count()); | 876 EXPECT_EQ(0, delegate1.gesture_event_count()); |
| 872 EXPECT_EQ(0, delegate1.touch_event_count()); | 877 EXPECT_EQ(0, delegate1.touch_event_count()); |
| (...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3438 | 3443 |
| 3439 EXPECT_TRUE(animator); | 3444 EXPECT_TRUE(animator); |
| 3440 EXPECT_FALSE(animator->is_animating()); | 3445 EXPECT_FALSE(animator->is_animating()); |
| 3441 EXPECT_TRUE(observer.animation_completed()); | 3446 EXPECT_TRUE(observer.animation_completed()); |
| 3442 EXPECT_FALSE(observer.animation_aborted()); | 3447 EXPECT_FALSE(observer.animation_aborted()); |
| 3443 animator->RemoveObserver(&observer); | 3448 animator->RemoveObserver(&observer); |
| 3444 } | 3449 } |
| 3445 | 3450 |
| 3446 } // namespace test | 3451 } // namespace test |
| 3447 } // namespace aura | 3452 } // namespace aura |
| OLD | NEW |