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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/aura/client/capture_client.h" | 13 #include "ui/aura/client/capture_client.h" |
14 #include "ui/aura/client/stacking_client.h" | 14 #include "ui/aura/client/stacking_client.h" |
15 #include "ui/aura/client/visibility_client.h" | 15 #include "ui/aura/client/visibility_client.h" |
16 #include "ui/aura/event.h" | |
17 #include "ui/aura/layout_manager.h" | 16 #include "ui/aura/layout_manager.h" |
18 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
19 #include "ui/aura/root_window_host.h" | 18 #include "ui/aura/root_window_host.h" |
20 #include "ui/aura/root_window_observer.h" | 19 #include "ui/aura/root_window_observer.h" |
21 #include "ui/aura/test/aura_test_base.h" | 20 #include "ui/aura/test/aura_test_base.h" |
22 #include "ui/aura/test/event_generator.h" | 21 #include "ui/aura/test/event_generator.h" |
23 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
24 #include "ui/aura/test/test_windows.h" | 23 #include "ui/aura/test/test_windows.h" |
25 #include "ui/aura/window_delegate.h" | 24 #include "ui/aura/window_delegate.h" |
26 #include "ui/aura/window_observer.h" | 25 #include "ui/aura/window_observer.h" |
27 #include "ui/aura/window_property.h" | 26 #include "ui/aura/window_property.h" |
| 27 #include "ui/base/event.h" |
28 #include "ui/base/gestures/gesture_configuration.h" | 28 #include "ui/base/gestures/gesture_configuration.h" |
29 #include "ui/base/hit_test.h" | 29 #include "ui/base/hit_test.h" |
30 #include "ui/base/keycodes/keyboard_codes.h" | 30 #include "ui/base/keycodes/keyboard_codes.h" |
31 #include "ui/compositor/layer.h" | 31 #include "ui/compositor/layer.h" |
32 #include "ui/compositor/scoped_layer_animation_settings.h" | 32 #include "ui/compositor/scoped_layer_animation_settings.h" |
33 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
34 #include "ui/gfx/screen.h" | 34 #include "ui/gfx/screen.h" |
35 | 35 |
36 DECLARE_WINDOW_PROPERTY_TYPE(const char*) | 36 DECLARE_WINDOW_PROPERTY_TYPE(const char*) |
37 DECLARE_WINDOW_PROPERTY_TYPE(int) | 37 DECLARE_WINDOW_PROPERTY_TYPE(int) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 int capture_changed_event_count() const { | 159 int capture_changed_event_count() const { |
160 return capture_changed_event_count_; | 160 return capture_changed_event_count_; |
161 } | 161 } |
162 int capture_lost_count() const { return capture_lost_count_; } | 162 int capture_lost_count() const { return capture_lost_count_; } |
163 int mouse_event_count() const { return mouse_event_count_; } | 163 int mouse_event_count() const { return mouse_event_count_; } |
164 int touch_event_count() const { return touch_event_count_; } | 164 int touch_event_count() const { return touch_event_count_; } |
165 int gesture_event_count() const { return gesture_event_count_; } | 165 int gesture_event_count() const { return gesture_event_count_; } |
166 | 166 |
167 virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE { | 167 virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
168 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) | 168 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) |
169 capture_changed_event_count_++; | 169 capture_changed_event_count_++; |
170 mouse_event_count_++; | 170 mouse_event_count_++; |
171 return false; | 171 return false; |
172 } | 172 } |
173 virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) OVERRIDE { | 173 virtual ui::TouchStatus OnTouchEvent(ui::TouchEventImpl* event) OVERRIDE { |
174 touch_event_count_++; | 174 touch_event_count_++; |
175 return ui::TOUCH_STATUS_UNKNOWN; | 175 return ui::TOUCH_STATUS_UNKNOWN; |
176 } | 176 } |
177 virtual ui::GestureStatus OnGestureEvent(GestureEvent* event) OVERRIDE { | 177 virtual ui::GestureStatus OnGestureEvent( |
| 178 ui::GestureEventImpl* event) OVERRIDE { |
178 gesture_event_count_++; | 179 gesture_event_count_++; |
179 return ui::GESTURE_STATUS_UNKNOWN; | 180 return ui::GESTURE_STATUS_UNKNOWN; |
180 } | 181 } |
181 virtual void OnCaptureLost() OVERRIDE { | 182 virtual void OnCaptureLost() OVERRIDE { |
182 capture_lost_count_++; | 183 capture_lost_count_++; |
183 } | 184 } |
184 | 185 |
185 private: | 186 private: |
186 int capture_changed_event_count_; | 187 int capture_changed_event_count_; |
187 int capture_lost_count_; | 188 int capture_lost_count_; |
(...skipping 21 matching lines...) Expand all Loading... |
209 | 210 |
210 private: | 211 private: |
211 aura::Window* previous_focused_window_; | 212 aura::Window* previous_focused_window_; |
212 }; | 213 }; |
213 | 214 |
214 // Keeps track of the location of the gesture. | 215 // Keeps track of the location of the gesture. |
215 class GestureTrackPositionDelegate : public TestWindowDelegate { | 216 class GestureTrackPositionDelegate : public TestWindowDelegate { |
216 public: | 217 public: |
217 GestureTrackPositionDelegate() {} | 218 GestureTrackPositionDelegate() {} |
218 | 219 |
219 virtual ui::GestureStatus OnGestureEvent(GestureEvent* event) OVERRIDE { | 220 virtual ui::GestureStatus OnGestureEvent( |
| 221 ui::GestureEventImpl* event) OVERRIDE { |
220 position_ = event->location(); | 222 position_ = event->location(); |
221 return ui::GESTURE_STATUS_CONSUMED; | 223 return ui::GESTURE_STATUS_CONSUMED; |
222 } | 224 } |
223 | 225 |
224 const gfx::Point& position() const { return position_; } | 226 const gfx::Point& position() const { return position_; } |
225 | 227 |
226 private: | 228 private: |
227 gfx::Point position_; | 229 gfx::Point position_; |
228 | 230 |
229 DISALLOW_COPY_AND_ASSIGN(GestureTrackPositionDelegate); | 231 DISALLOW_COPY_AND_ASSIGN(GestureTrackPositionDelegate); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 EXPECT_FALSE(w->ContainsPoint(gfx::Point(10, 10))); | 289 EXPECT_FALSE(w->ContainsPoint(gfx::Point(10, 10))); |
288 } | 290 } |
289 | 291 |
290 TEST_F(WindowTest, ConvertPointToWindow) { | 292 TEST_F(WindowTest, ConvertPointToWindow) { |
291 // Window::ConvertPointToWindow is mostly identical to | 293 // Window::ConvertPointToWindow is mostly identical to |
292 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, | 294 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, |
293 // in which case the function just returns. | 295 // in which case the function just returns. |
294 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); | 296 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); |
295 gfx::Point reference_point(100, 100); | 297 gfx::Point reference_point(100, 100); |
296 gfx::Point test_point = reference_point; | 298 gfx::Point test_point = reference_point; |
297 Window::ConvertPointToWindow(NULL, w1.get(), &test_point); | 299 Window::ConvertPointToTarget(NULL, w1.get(), &test_point); |
298 EXPECT_EQ(reference_point, test_point); | 300 EXPECT_EQ(reference_point, test_point); |
299 } | 301 } |
300 | 302 |
301 TEST_F(WindowTest, MoveCursorTo) { | 303 TEST_F(WindowTest, MoveCursorTo) { |
302 scoped_ptr<Window> w1( | 304 scoped_ptr<Window> w1( |
303 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); | 305 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); |
304 scoped_ptr<Window> w11( | 306 scoped_ptr<Window> w11( |
305 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); | 307 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); |
306 scoped_ptr<Window> w111( | 308 scoped_ptr<Window> w111( |
307 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); | 309 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 EXPECT_EQ(0, delegate.capture_lost_count()); | 748 EXPECT_EQ(0, delegate.capture_lost_count()); |
747 EXPECT_EQ(0, delegate.capture_changed_event_count()); | 749 EXPECT_EQ(0, delegate.capture_changed_event_count()); |
748 EventGenerator generator(root_window(), gfx::Point(50, 50)); | 750 EventGenerator generator(root_window(), gfx::Point(50, 50)); |
749 generator.PressLeftButton(); | 751 generator.PressLeftButton(); |
750 EXPECT_EQ(1, delegate.mouse_event_count()); | 752 EXPECT_EQ(1, delegate.mouse_event_count()); |
751 generator.ReleaseLeftButton(); | 753 generator.ReleaseLeftButton(); |
752 | 754 |
753 EXPECT_EQ(2, delegate.mouse_event_count()); | 755 EXPECT_EQ(2, delegate.mouse_event_count()); |
754 delegate.ResetCounts(); | 756 delegate.ResetCounts(); |
755 | 757 |
756 TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime()); | 758 ui::TouchEventImpl touchev( |
| 759 ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime()); |
757 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); | 760 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); |
758 EXPECT_EQ(1, delegate.touch_event_count()); | 761 EXPECT_EQ(1, delegate.touch_event_count()); |
759 delegate.ResetCounts(); | 762 delegate.ResetCounts(); |
760 | 763 |
761 window->ReleaseCapture(); | 764 window->ReleaseCapture(); |
762 EXPECT_FALSE(window->HasCapture()); | 765 EXPECT_FALSE(window->HasCapture()); |
763 EXPECT_EQ(1, delegate.capture_lost_count()); | 766 EXPECT_EQ(1, delegate.capture_lost_count()); |
764 EXPECT_EQ(1, delegate.capture_changed_event_count()); | 767 EXPECT_EQ(1, delegate.capture_changed_event_count()); |
765 EXPECT_EQ(1, delegate.mouse_event_count()); | 768 EXPECT_EQ(1, delegate.mouse_event_count()); |
766 EXPECT_EQ(1, delegate.touch_event_count()); | 769 EXPECT_EQ(1, delegate.touch_event_count()); |
767 | 770 |
768 generator.PressLeftButton(); | 771 generator.PressLeftButton(); |
769 EXPECT_EQ(1, delegate.mouse_event_count()); | 772 EXPECT_EQ(1, delegate.mouse_event_count()); |
770 | 773 |
771 TouchEvent touchev2(ui::ET_TOUCH_PRESSED, gfx::Point(250, 250), 1, getTime()); | 774 ui::TouchEventImpl touchev2( |
| 775 ui::ET_TOUCH_PRESSED, gfx::Point(250, 250), 1, getTime()); |
772 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); | 776 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); |
773 EXPECT_EQ(1, delegate.touch_event_count()); | 777 EXPECT_EQ(1, delegate.touch_event_count()); |
774 | 778 |
775 // Removing the capture window from parent should reset the capture window | 779 // Removing the capture window from parent should reset the capture window |
776 // in the root window. | 780 // in the root window. |
777 window->SetCapture(); | 781 window->SetCapture(); |
778 EXPECT_EQ(window.get(), aura::client::GetCaptureWindow(root_window())); | 782 EXPECT_EQ(window.get(), aura::client::GetCaptureWindow(root_window())); |
779 window->parent()->RemoveChild(window.get()); | 783 window->parent()->RemoveChild(window.get()); |
780 EXPECT_FALSE(window->HasCapture()); | 784 EXPECT_FALSE(window->HasCapture()); |
781 EXPECT_EQ(NULL, aura::client::GetCaptureWindow(root_window())); | 785 EXPECT_EQ(NULL, aura::client::GetCaptureWindow(root_window())); |
782 } | 786 } |
783 | 787 |
784 TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { | 788 TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { |
785 CaptureWindowDelegateImpl delegate1; | 789 CaptureWindowDelegateImpl delegate1; |
786 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( | 790 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( |
787 &delegate1, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 791 &delegate1, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
788 CaptureWindowDelegateImpl delegate2; | 792 CaptureWindowDelegateImpl delegate2; |
789 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( | 793 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( |
790 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); | 794 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); |
791 | 795 |
792 // Press on w1. | 796 // Press on w1. |
793 TouchEvent press(ui::ET_TOUCH_PRESSED, | 797 ui::TouchEventImpl press( |
794 gfx::Point(10, 10), 0, getTime()); | 798 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
795 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 799 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
796 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 800 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
797 EXPECT_EQ(2, delegate1.gesture_event_count()); | 801 EXPECT_EQ(2, delegate1.gesture_event_count()); |
798 delegate1.ResetCounts(); | 802 delegate1.ResetCounts(); |
799 w2->SetCapture(); | 803 w2->SetCapture(); |
800 | 804 |
801 // The touch was cancelled when the other window | 805 // The touch was cancelled when the other window |
802 // attained a touch lock. | 806 // attained a touch lock. |
803 EXPECT_EQ(1, delegate1.touch_event_count()); | 807 EXPECT_EQ(1, delegate1.touch_event_count()); |
804 EXPECT_EQ(0, delegate2.touch_event_count()); | 808 EXPECT_EQ(0, delegate2.touch_event_count()); |
805 | 809 |
806 delegate1.ResetCounts(); | 810 delegate1.ResetCounts(); |
807 delegate2.ResetCounts(); | 811 delegate2.ResetCounts(); |
808 | 812 |
809 TouchEvent move(ui::ET_TOUCH_MOVED, | 813 ui::TouchEventImpl move(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, getTime()); |
810 gfx::Point(10, 10), 0, getTime()); | |
811 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); | 814 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move); |
812 | 815 |
813 // This touch id is now ignored, no scroll fired. | 816 // This touch id is now ignored, no scroll fired. |
814 EXPECT_EQ(0, delegate1.gesture_event_count()); | 817 EXPECT_EQ(0, delegate1.gesture_event_count()); |
815 EXPECT_EQ(0, delegate2.gesture_event_count()); | 818 EXPECT_EQ(0, delegate2.gesture_event_count()); |
816 | 819 |
817 TouchEvent release(ui::ET_TOUCH_RELEASED, | 820 ui::TouchEventImpl release( |
818 gfx::Point(10, 10), 0, getTime()); | 821 ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), 0, getTime()); |
819 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 822 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
820 EXPECT_EQ(0, delegate1.gesture_event_count()); | 823 EXPECT_EQ(0, delegate1.gesture_event_count()); |
821 EXPECT_EQ(0, delegate2.gesture_event_count()); | 824 EXPECT_EQ(0, delegate2.gesture_event_count()); |
822 | 825 |
823 // A new press is captured by w2. | 826 // A new press is captured by w2. |
824 | 827 |
825 TouchEvent press2(ui::ET_TOUCH_PRESSED, | 828 ui::TouchEventImpl press2( |
826 gfx::Point(10, 10), 0, getTime()); | 829 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
827 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); | 830 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2); |
828 EXPECT_EQ(0, delegate1.gesture_event_count()); | 831 EXPECT_EQ(0, delegate1.gesture_event_count()); |
829 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 832 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
830 EXPECT_EQ(2, delegate2.gesture_event_count()); | 833 EXPECT_EQ(2, delegate2.gesture_event_count()); |
831 } | 834 } |
832 | 835 |
833 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { | 836 TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { |
834 CaptureWindowDelegateImpl delegate; | 837 CaptureWindowDelegateImpl delegate; |
835 scoped_ptr<Window> window(CreateTestWindowWithDelegate( | 838 scoped_ptr<Window> window(CreateTestWindowWithDelegate( |
836 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 839 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
837 | 840 |
838 TouchEvent press(ui::ET_TOUCH_PRESSED, | 841 ui::TouchEventImpl press( |
839 gfx::Point(10, 10), 0, getTime()); | 842 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
840 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 843 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
841 | 844 |
842 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 845 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
843 EXPECT_EQ(2, delegate.gesture_event_count()); | 846 EXPECT_EQ(2, delegate.gesture_event_count()); |
844 delegate.ResetCounts(); | 847 delegate.ResetCounts(); |
845 | 848 |
846 window->SetCapture(); | 849 window->SetCapture(); |
847 EXPECT_EQ(0, delegate.gesture_event_count()); | 850 EXPECT_EQ(0, delegate.gesture_event_count()); |
848 delegate.ResetCounts(); | 851 delegate.ResetCounts(); |
849 | 852 |
850 // The move event should still create a gesture, as this touch was | 853 // The move event should still create a gesture, as this touch was |
851 // on the window which was captured. | 854 // on the window which was captured. |
852 TouchEvent release(ui::ET_TOUCH_RELEASED, | 855 ui::TouchEventImpl release(ui::ET_TOUCH_RELEASED, |
853 gfx::Point(10, 10), 0, getTime() + | 856 gfx::Point(10, 10), 0, getTime() + |
854 base::TimeDelta::FromMilliseconds(50)); | 857 base::TimeDelta::FromMilliseconds(50)); |
855 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 858 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
856 EXPECT_EQ(2, delegate.gesture_event_count()); | 859 EXPECT_EQ(2, delegate.gesture_event_count()); |
857 } | 860 } |
858 | 861 |
859 // Assertions around SetCapture() and touch/gestures. | 862 // Assertions around SetCapture() and touch/gestures. |
860 TEST_F(WindowTest, TransferCaptureTouchEvents) { | 863 TEST_F(WindowTest, TransferCaptureTouchEvents) { |
861 // Touch on |w1|. | 864 // Touch on |w1|. |
862 CaptureWindowDelegateImpl d1; | 865 CaptureWindowDelegateImpl d1; |
863 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( | 866 scoped_ptr<Window> w1(CreateTestWindowWithDelegate( |
864 &d1, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 867 &d1, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
865 TouchEvent p1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); | 868 ui::TouchEventImpl p1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, getTime()); |
866 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p1); | 869 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p1); |
867 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. | 870 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN. |
868 EXPECT_EQ(2, d1.gesture_event_count()); | 871 EXPECT_EQ(2, d1.gesture_event_count()); |
869 d1.ResetCounts(); | 872 d1.ResetCounts(); |
870 | 873 |
871 // Touch on |w2| with a different id. | 874 // Touch on |w2| with a different id. |
872 CaptureWindowDelegateImpl d2; | 875 CaptureWindowDelegateImpl d2; |
873 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( | 876 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( |
874 &d2, 0, gfx::Rect(40, 0, 40, 20), NULL)); | 877 &d2, 0, gfx::Rect(40, 0, 40, 20), NULL)); |
875 TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), 1, getTime()); | 878 ui::TouchEventImpl p2(ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), 1, getTime()); |
876 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p2); | 879 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p2); |
877 EXPECT_EQ(0, d1.gesture_event_count()); | 880 EXPECT_EQ(0, d1.gesture_event_count()); |
878 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN for new target window. | 881 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN for new target window. |
879 EXPECT_EQ(2, d2.gesture_event_count()); | 882 EXPECT_EQ(2, d2.gesture_event_count()); |
880 d1.ResetCounts(); | 883 d1.ResetCounts(); |
881 d2.ResetCounts(); | 884 d2.ResetCounts(); |
882 | 885 |
883 // Set capture on |w2|, this should send a cancel to |w1| but not |w2|. | 886 // Set capture on |w2|, this should send a cancel to |w1| but not |w2|. |
884 w2->SetCapture(); | 887 w2->SetCapture(); |
885 EXPECT_EQ(1, d1.gesture_event_count()); | 888 EXPECT_EQ(1, d1.gesture_event_count()); |
886 EXPECT_EQ(0, d2.gesture_event_count()); | 889 EXPECT_EQ(0, d2.gesture_event_count()); |
887 d1.ResetCounts(); | 890 d1.ResetCounts(); |
888 d2.ResetCounts(); | 891 d2.ResetCounts(); |
889 | 892 |
890 CaptureWindowDelegateImpl d3; | 893 CaptureWindowDelegateImpl d3; |
891 scoped_ptr<Window> w3(CreateTestWindowWithDelegate( | 894 scoped_ptr<Window> w3(CreateTestWindowWithDelegate( |
892 &d3, 0, gfx::Rect(0, 0, 100, 101), NULL)); | 895 &d3, 0, gfx::Rect(0, 0, 100, 101), NULL)); |
893 // Set capture on w3. No new events should be received. | 896 // Set capture on w3. No new events should be received. |
894 w3->SetCapture(); | 897 w3->SetCapture(); |
895 EXPECT_EQ(0, d1.gesture_event_count()); | 898 EXPECT_EQ(0, d1.gesture_event_count()); |
896 EXPECT_EQ(0, d2.gesture_event_count()); | 899 EXPECT_EQ(0, d2.gesture_event_count()); |
897 EXPECT_EQ(0, d3.gesture_event_count()); | 900 EXPECT_EQ(0, d3.gesture_event_count()); |
898 | 901 |
899 // Move touch id originally associated with |w2|. Since capture was transfered | 902 // Move touch id originally associated with |w2|. Since capture was transfered |
900 // from 2 to 3 only |w3| should get the event. | 903 // from 2 to 3 only |w3| should get the event. |
901 TouchEvent m3(ui::ET_TOUCH_MOVED, gfx::Point(110, 105), 1, getTime()); | 904 ui::TouchEventImpl m3(ui::ET_TOUCH_MOVED, gfx::Point(110, 105), 1, getTime()); |
902 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&m3); | 905 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&m3); |
903 EXPECT_EQ(0, d1.gesture_event_count()); | 906 EXPECT_EQ(0, d1.gesture_event_count()); |
904 EXPECT_EQ(0, d2.gesture_event_count()); | 907 EXPECT_EQ(0, d2.gesture_event_count()); |
905 // |w3| gets two events, both scroll related. | 908 // |w3| gets two events, both scroll related. |
906 EXPECT_EQ(2, d3.gesture_event_count()); | 909 EXPECT_EQ(2, d3.gesture_event_count()); |
907 } | 910 } |
908 | 911 |
909 // Changes capture while capture is already ongoing. | 912 // Changes capture while capture is already ongoing. |
910 TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { | 913 TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { |
911 CaptureWindowDelegateImpl delegate; | 914 CaptureWindowDelegateImpl delegate; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 // The |child| window is moved to the 0,0 in screen coordinates. | 982 // The |child| window is moved to the 0,0 in screen coordinates. |
980 // |GetBoundsInRootWindow()| should return 0,0. | 983 // |GetBoundsInRootWindow()| should return 0,0. |
981 child->SetBounds(gfx::Rect(100, 100, 100, 100)); | 984 child->SetBounds(gfx::Rect(100, 100, 100, 100)); |
982 EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); | 985 EXPECT_EQ("0,0 100x100", child->GetBoundsInRootWindow().ToString()); |
983 } | 986 } |
984 | 987 |
985 class MouseEnterExitWindowDelegate : public TestWindowDelegate { | 988 class MouseEnterExitWindowDelegate : public TestWindowDelegate { |
986 public: | 989 public: |
987 MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {} | 990 MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {} |
988 | 991 |
989 virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE { | 992 virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
990 switch (event->type()) { | 993 switch (event->type()) { |
991 case ui::ET_MOUSE_ENTERED: | 994 case ui::ET_MOUSE_ENTERED: |
992 entered_ = true; | 995 entered_ = true; |
993 break; | 996 break; |
994 case ui::ET_MOUSE_EXITED: | 997 case ui::ET_MOUSE_EXITED: |
995 exited_ = true; | 998 exited_ = true; |
996 break; | 999 break; |
997 default: | 1000 default: |
998 break; | 1001 break; |
999 } | 1002 } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 new GestureTrackPositionDelegate); | 1306 new GestureTrackPositionDelegate); |
1304 scoped_ptr<Window> window(CreateTestWindowWithDelegate(delegate.get(), -1234, | 1307 scoped_ptr<Window> window(CreateTestWindowWithDelegate(delegate.get(), -1234, |
1305 gfx::Rect(0, 0, 20, 20), NULL)); | 1308 gfx::Rect(0, 0, 20, 20), NULL)); |
1306 | 1309 |
1307 // Rotate the root-window clock-wise 90 degrees. | 1310 // Rotate the root-window clock-wise 90 degrees. |
1308 ui::Transform transform; | 1311 ui::Transform transform; |
1309 transform.SetRotate(90.0f); | 1312 transform.SetRotate(90.0f); |
1310 transform.ConcatTranslate(size.height(), 0); | 1313 transform.ConcatTranslate(size.height(), 0); |
1311 root_window()->SetTransform(transform); | 1314 root_window()->SetTransform(transform); |
1312 | 1315 |
1313 TouchEvent press(ui::ET_TOUCH_PRESSED, | 1316 ui::TouchEventImpl press( |
1314 gfx::Point(size.height() - 10, 10), 0, getTime()); | 1317 ui::ET_TOUCH_PRESSED, gfx::Point(size.height() - 10, 10), 0, getTime()); |
1315 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 1318 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
1316 EXPECT_EQ(gfx::Point(10, 10).ToString(), delegate->position().ToString()); | 1319 EXPECT_EQ(gfx::Point(10, 10).ToString(), delegate->position().ToString()); |
1317 } | 1320 } |
1318 | 1321 |
1319 // Various assertions for transient children. | 1322 // Various assertions for transient children. |
1320 TEST_F(WindowTest, TransientChildren) { | 1323 TEST_F(WindowTest, TransientChildren) { |
1321 scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL)); | 1324 scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL)); |
1322 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); | 1325 scoped_ptr<Window> w1(CreateTestWindowWithId(1, parent.get())); |
1323 scoped_ptr<Window> w3(CreateTestWindowWithId(3, parent.get())); | 1326 scoped_ptr<Window> w3(CreateTestWindowWithId(3, parent.get())); |
1324 Window* w2 = CreateTestWindowWithId(2, parent.get()); | 1327 Window* w2 = CreateTestWindowWithId(2, parent.get()); |
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); | 2445 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); |
2443 | 2446 |
2444 // No bounds changed notification at the end of animation since layer | 2447 // No bounds changed notification at the end of animation since layer |
2445 // delegate is NULL. | 2448 // delegate is NULL. |
2446 EXPECT_FALSE(delegate.bounds_changed()); | 2449 EXPECT_FALSE(delegate.bounds_changed()); |
2447 EXPECT_NE("0,0 100x100", window->bounds().ToString()); | 2450 EXPECT_NE("0,0 100x100", window->bounds().ToString()); |
2448 } | 2451 } |
2449 | 2452 |
2450 } // namespace test | 2453 } // namespace test |
2451 } // namespace aura | 2454 } // namespace aura |
OLD | NEW |