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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 delegate2.ResetCounts(); | 867 delegate2.ResetCounts(); |
868 | 868 |
869 // And releasing capture changes nothing. | 869 // And releasing capture changes nothing. |
870 w2->ReleaseCapture(); | 870 w2->ReleaseCapture(); |
871 EXPECT_EQ(0, delegate1.gesture_event_count()); | 871 EXPECT_EQ(0, delegate1.gesture_event_count()); |
872 EXPECT_EQ(0, delegate1.touch_event_count()); | 872 EXPECT_EQ(0, delegate1.touch_event_count()); |
873 EXPECT_EQ(0, delegate2.gesture_event_count()); | 873 EXPECT_EQ(0, delegate2.gesture_event_count()); |
874 EXPECT_EQ(0, delegate2.touch_event_count()); | 874 EXPECT_EQ(0, delegate2.touch_event_count()); |
875 } | 875 } |
876 | 876 |
877 #if defined(OS_WIN) | 877 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { |
878 // http://crbug.com/396387 | |
879 #define MAYBE_TouchCaptureDoesntCancelCapturedTouches DISABLED_TouchCaptureDoesn
tCancelCapturedTouches | |
880 #else | |
881 #define MAYBE_TouchCaptureDoesntCancelCapturedTouches TouchCaptureDoesntCancelCa
pturedTouches | |
882 #endif | |
883 TEST_F(WindowTest, MAYBE_TouchCaptureDoesntCancelCapturedTouches) { | |
884 CaptureWindowDelegateImpl delegate; | 878 CaptureWindowDelegateImpl delegate; |
885 scoped_ptr<Window> window(CreateTestWindowWithDelegate( | 879 scoped_ptr<Window> window(CreateTestWindowWithDelegate( |
886 &delegate, 0, gfx::Rect(0, 0, 50, 50), root_window())); | 880 &delegate, 0, gfx::Rect(0, 0, 50, 50), root_window())); |
| 881 base::TimeDelta time = getTime(); |
| 882 const int kTimeDelta = 100; |
887 | 883 |
888 ui::TouchEvent press( | 884 ui::TouchEvent press( |
889 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); | 885 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, time); |
890 DispatchEventUsingWindowDispatcher(&press); | 886 DispatchEventUsingWindowDispatcher(&press); |
891 | 887 |
892 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 888 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
893 EXPECT_EQ(2, delegate.gesture_event_count()); | 889 EXPECT_EQ(2, delegate.gesture_event_count()); |
894 EXPECT_EQ(1, delegate.touch_event_count()); | 890 EXPECT_EQ(1, delegate.touch_event_count()); |
895 delegate.ResetCounts(); | 891 delegate.ResetCounts(); |
896 | 892 |
897 window->SetCapture(); | 893 window->SetCapture(); |
898 EXPECT_EQ(0, delegate.gesture_event_count()); | 894 EXPECT_EQ(0, delegate.gesture_event_count()); |
899 EXPECT_EQ(0, delegate.touch_event_count()); | 895 EXPECT_EQ(0, delegate.touch_event_count()); |
900 delegate.ResetCounts(); | 896 delegate.ResetCounts(); |
901 | 897 |
902 // On move We will get TOUCH_MOVED, GESTURE_TAP_CANCEL, | 898 // On move We will get TOUCH_MOVED, GESTURE_TAP_CANCEL, |
903 // GESTURE_SCROLL_START and GESTURE_SCROLL_UPDATE. | 899 // GESTURE_SCROLL_START and GESTURE_SCROLL_UPDATE. |
904 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 0, getTime()); | 900 time += base::TimeDelta::FromMilliseconds(kTimeDelta); |
| 901 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 0, time); |
905 DispatchEventUsingWindowDispatcher(&move); | 902 DispatchEventUsingWindowDispatcher(&move); |
906 EXPECT_EQ(1, delegate.touch_event_count()); | 903 EXPECT_EQ(1, delegate.touch_event_count()); |
907 EXPECT_EQ(3, delegate.gesture_event_count()); | 904 EXPECT_EQ(3, delegate.gesture_event_count()); |
908 delegate.ResetCounts(); | 905 delegate.ResetCounts(); |
909 | 906 |
910 // Release capture shouldn't change anything. | 907 // Release capture shouldn't change anything. |
911 window->ReleaseCapture(); | 908 window->ReleaseCapture(); |
912 EXPECT_EQ(0, delegate.touch_event_count()); | 909 EXPECT_EQ(0, delegate.touch_event_count()); |
913 EXPECT_EQ(0, delegate.gesture_event_count()); | 910 EXPECT_EQ(0, delegate.gesture_event_count()); |
914 delegate.ResetCounts(); | 911 delegate.ResetCounts(); |
915 | 912 |
916 // On move we still get TOUCH_MOVED and GESTURE_SCROLL_UPDATE. | 913 // On move we still get TOUCH_MOVED and GESTURE_SCROLL_UPDATE. |
917 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 30), 0, getTime()); | 914 time += base::TimeDelta::FromMilliseconds(kTimeDelta); |
| 915 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 30), 0, time); |
918 DispatchEventUsingWindowDispatcher(&move2); | 916 DispatchEventUsingWindowDispatcher(&move2); |
919 EXPECT_EQ(1, delegate.touch_event_count()); | 917 EXPECT_EQ(1, delegate.touch_event_count()); |
920 EXPECT_EQ(1, delegate.gesture_event_count()); | 918 EXPECT_EQ(1, delegate.gesture_event_count()); |
921 delegate.ResetCounts(); | 919 delegate.ResetCounts(); |
922 | 920 |
923 // And on release we get TOUCH_RELEASED, GESTURE_SCROLL_END, GESTURE_END | 921 // And on release we get TOUCH_RELEASED, GESTURE_SCROLL_END, GESTURE_END |
| 922 time += base::TimeDelta::FromMilliseconds(kTimeDelta); |
924 ui::TouchEvent release( | 923 ui::TouchEvent release( |
925 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0, getTime()); | 924 ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 0, time); |
926 DispatchEventUsingWindowDispatcher(&release); | 925 DispatchEventUsingWindowDispatcher(&release); |
927 EXPECT_EQ(1, delegate.touch_event_count()); | 926 EXPECT_EQ(1, delegate.touch_event_count()); |
928 EXPECT_EQ(2, delegate.gesture_event_count()); | 927 EXPECT_EQ(2, delegate.gesture_event_count()); |
929 } | 928 } |
930 | 929 |
931 | 930 |
932 // Assertions around SetCapture() and touch/gestures. | 931 // Assertions around SetCapture() and touch/gestures. |
933 TEST_F(WindowTest, TransferCaptureTouchEvents) { | 932 TEST_F(WindowTest, TransferCaptureTouchEvents) { |
934 // Touch on |w1|. | 933 // Touch on |w1|. |
935 CaptureWindowDelegateImpl d1; | 934 CaptureWindowDelegateImpl d1; |
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3439 | 3438 |
3440 EXPECT_TRUE(animator); | 3439 EXPECT_TRUE(animator); |
3441 EXPECT_FALSE(animator->is_animating()); | 3440 EXPECT_FALSE(animator->is_animating()); |
3442 EXPECT_TRUE(observer.animation_completed()); | 3441 EXPECT_TRUE(observer.animation_completed()); |
3443 EXPECT_FALSE(observer.animation_aborted()); | 3442 EXPECT_FALSE(observer.animation_aborted()); |
3444 animator->RemoveObserver(&observer); | 3443 animator->RemoveObserver(&observer); |
3445 } | 3444 } |
3446 | 3445 |
3447 } // namespace test | 3446 } // namespace test |
3448 } // namespace aura | 3447 } // namespace aura |
OLD | NEW |