OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 5 |
6 #include "base/sys_info.h" | 6 #include "base/sys_info.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
| 9 #include "ui/aura/window.h" |
9 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
10 #include "ui/aura/window_tree_host_delegate.h" | |
11 #include "ui/aura/window_tree_host_x11.h" | 11 #include "ui/aura/window_tree_host_x11.h" |
12 #include "ui/events/event_processor.h" | 12 #include "ui/events/event_processor.h" |
13 #include "ui/events/event_target.h" | 13 #include "ui/events/event_target.h" |
14 #include "ui/events/event_target_iterator.h" | 14 #include "ui/events/event_target_iterator.h" |
15 #include "ui/events/test/events_test_utils_x11.h" | 15 #include "ui/events/test/events_test_utils_x11.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 class TestWindowTreeHostDelegate : public aura::WindowTreeHostDelegate, | 18 |
19 public ui::EventProcessor, | 19 class RootWindowEventHandler : public ui::EventHandler { |
20 public ui::EventTarget { | |
21 public: | 20 public: |
22 TestWindowTreeHostDelegate() : last_touch_type_(ui::ET_UNKNOWN), | 21 RootWindowEventHandler() : last_touch_type_(ui::ET_UNKNOWN), |
23 last_touch_id_(-1), | 22 last_touch_id_(-1), |
24 last_touch_location_(0, 0) { | 23 last_touch_location_(0, 0) { |
25 } | 24 } |
26 virtual ~TestWindowTreeHostDelegate() {} | 25 virtual ~RootWindowEventHandler () {} |
27 | |
28 // aura::WindowTreeHostDelegate: | |
29 virtual void OnHostCancelMode() OVERRIDE {} | |
30 virtual void OnHostActivated() OVERRIDE {} | |
31 virtual void OnHostLostWindowCapture() OVERRIDE {} | |
32 virtual void OnHostLostMouseGrab() OVERRIDE {} | |
33 virtual void OnHostResized(const gfx::Size& size) OVERRIDE {} | |
34 virtual void OnCursorMovedToRootLocation( | |
35 const gfx::Point& root_location) OVERRIDE {} | |
36 virtual aura::WindowEventDispatcher* AsDispatcher() OVERRIDE { return NULL; } | |
37 virtual const aura::WindowEventDispatcher* AsDispatcher() const OVERRIDE { | |
38 return NULL; | |
39 } | |
40 virtual ui::EventProcessor* GetEventProcessor() OVERRIDE { | |
41 return this; | |
42 } | |
43 | |
44 // ui::EventProcessor: | |
45 virtual ui::EventTarget* GetRootTarget() OVERRIDE { return this; } | |
46 virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE { | |
47 return true; | |
48 } | |
49 | 26 |
50 // ui::EventHandler: | 27 // ui::EventHandler: |
51 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 28 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
52 last_touch_id_ = event->touch_id(); | 29 last_touch_id_ = event->touch_id(); |
53 last_touch_type_ = event->type(); | 30 last_touch_type_ = event->type(); |
54 last_touch_location_ = event->location(); | 31 last_touch_location_ = event->location(); |
55 } | 32 } |
56 | 33 |
57 // ui::EventTarget: | |
58 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE { | |
59 return true; | |
60 } | |
61 virtual ui::EventTarget* GetParentTarget() OVERRIDE { return NULL; } | |
62 virtual scoped_ptr<ui::EventTargetIterator> | |
63 GetChildIterator() const OVERRIDE { | |
64 return scoped_ptr<ui::EventTargetIterator>(); | |
65 } | |
66 virtual ui::EventTargeter* GetEventTargeter() OVERRIDE { return &targeter_; } | |
67 | |
68 ui::EventType last_touch_type() { | 34 ui::EventType last_touch_type() { |
69 return last_touch_type_; | 35 return last_touch_type_; |
70 } | 36 } |
71 | 37 |
72 int last_touch_id() { | 38 int last_touch_id() { |
73 return last_touch_id_; | 39 return last_touch_id_; |
74 } | 40 } |
75 | 41 |
76 gfx::Point last_touch_location() { | 42 gfx::Point last_touch_location() { |
77 return last_touch_location_; | 43 return last_touch_location_; |
78 } | 44 } |
79 | 45 |
80 private: | 46 private: |
81 ui::EventType last_touch_type_; | 47 ui::EventType last_touch_type_; |
82 int last_touch_id_; | 48 int last_touch_id_; |
83 gfx::Point last_touch_location_; | 49 gfx::Point last_touch_location_; |
84 ui::EventTargeter targeter_; | |
85 | 50 |
86 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeHostDelegate); | 51 DISALLOW_COPY_AND_ASSIGN(RootWindowEventHandler); |
87 }; | 52 }; |
88 | 53 |
89 } // namespace | 54 } // namespace |
90 | 55 |
91 namespace aura { | 56 namespace aura { |
92 | 57 |
93 typedef test::AuraTestBase WindowTreeHostX11Test; | 58 typedef test::AuraTestBase WindowTreeHostX11Test; |
94 | 59 |
95 // Send X touch events to one WindowTreeHost. The WindowTreeHost's | 60 // Send X touch events to one WindowTreeHost. The WindowTreeHost's |
96 // delegate will get corresponding ui::TouchEvent if the touch events | 61 // delegate will get corresponding ui::TouchEvent if the touch events |
97 // are winthin the bound of the WindowTreeHost. | 62 // are winthin the bound of the WindowTreeHost. |
98 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { | 63 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { |
99 #if defined(OS_CHROMEOS) | 64 #if defined(OS_CHROMEOS) |
100 // Fake a ChromeOS running env. | 65 // Fake a ChromeOS running env. |
101 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | 66 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
102 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 67 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
103 #endif // defined(OS_CHROMEOS) | 68 #endif // defined(OS_CHROMEOS) |
104 | 69 |
105 scoped_ptr<WindowTreeHostX11> window_tree_host( | 70 scoped_ptr<WindowTreeHostX11> window_tree_host( |
106 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); | 71 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); |
107 scoped_ptr<TestWindowTreeHostDelegate> delegate( | 72 window_tree_host->InitHost(); |
108 new TestWindowTreeHostDelegate()); | 73 scoped_ptr<RootWindowEventHandler> handler(new RootWindowEventHandler()); |
109 window_tree_host->set_delegate(delegate.get()); | 74 window_tree_host->window()->AddPreTargetHandler(handler.get()); |
110 | 75 |
111 std::vector<unsigned int> devices; | 76 std::vector<unsigned int> devices; |
112 devices.push_back(0); | 77 devices.push_back(0); |
113 ui::SetUpTouchDevicesForTest(devices); | 78 ui::SetUpTouchDevicesForTest(devices); |
114 std::vector<ui::Valuator> valuators; | 79 std::vector<ui::Valuator> valuators; |
115 | 80 |
116 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); | 81 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); |
117 EXPECT_EQ(-1, delegate->last_touch_id()); | 82 EXPECT_EQ(-1, handler->last_touch_id()); |
118 | 83 |
119 ui::ScopedXI2Event scoped_xevent; | 84 ui::ScopedXI2Event scoped_xevent; |
120 #if defined(OS_CHROMEOS) | 85 #if defined(OS_CHROMEOS) |
121 // This touch is out of bounds. | 86 // This touch is out of bounds. |
122 scoped_xevent.InitTouchEvent( | 87 scoped_xevent.InitTouchEvent( |
123 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); | 88 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); |
124 window_tree_host->Dispatch(scoped_xevent); | 89 window_tree_host->Dispatch(scoped_xevent); |
125 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); | 90 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); |
126 EXPECT_EQ(-1, delegate->last_touch_id()); | 91 EXPECT_EQ(-1, handler->last_touch_id()); |
127 EXPECT_EQ(gfx::Point(0, 0), delegate->last_touch_location()); | 92 EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location()); |
128 #endif // defined(OS_CHROMEOS) | 93 #endif // defined(OS_CHROMEOS) |
129 | 94 |
130 // Following touchs are within bounds and are passed to delegate. | 95 // Following touchs are within bounds and are passed to delegate. |
131 scoped_xevent.InitTouchEvent( | 96 scoped_xevent.InitTouchEvent( |
132 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); | 97 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); |
133 window_tree_host->Dispatch(scoped_xevent); | 98 window_tree_host->Dispatch(scoped_xevent); |
134 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate->last_touch_type()); | 99 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type()); |
135 EXPECT_EQ(0, delegate->last_touch_id()); | 100 EXPECT_EQ(0, handler->last_touch_id()); |
136 EXPECT_EQ(gfx::Point(1500, 1500), delegate->last_touch_location()); | 101 EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location()); |
137 | 102 |
138 scoped_xevent.InitTouchEvent( | 103 scoped_xevent.InitTouchEvent( |
139 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); | 104 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); |
140 window_tree_host->Dispatch(scoped_xevent); | 105 window_tree_host->Dispatch(scoped_xevent); |
141 EXPECT_EQ(ui::ET_TOUCH_MOVED, delegate->last_touch_type()); | 106 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type()); |
142 EXPECT_EQ(0, delegate->last_touch_id()); | 107 EXPECT_EQ(0, handler->last_touch_id()); |
143 EXPECT_EQ(gfx::Point(1500, 1600), delegate->last_touch_location()); | 108 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); |
144 | 109 |
145 scoped_xevent.InitTouchEvent( | 110 scoped_xevent.InitTouchEvent( |
146 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); | 111 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); |
147 window_tree_host->Dispatch(scoped_xevent); | 112 window_tree_host->Dispatch(scoped_xevent); |
148 EXPECT_EQ(ui::ET_TOUCH_RELEASED, delegate->last_touch_type()); | 113 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); |
149 EXPECT_EQ(0, delegate->last_touch_id()); | 114 EXPECT_EQ(0, handler->last_touch_id()); |
150 EXPECT_EQ(gfx::Point(1500, 1600), delegate->last_touch_location()); | 115 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); |
151 | 116 |
152 // Revert the CrOS testing env otherwise the following non-CrOS aura | 117 // Revert the CrOS testing env otherwise the following non-CrOS aura |
153 // tests will fail. | 118 // tests will fail. |
154 #if defined(OS_CHROMEOS) | 119 #if defined(OS_CHROMEOS) |
155 // Fake a ChromeOS running env. | 120 // Fake a ChromeOS running env. |
156 kLsbRelease = ""; | 121 kLsbRelease = ""; |
157 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 122 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
158 #endif // defined(OS_CHROMEOS) | 123 #endif // defined(OS_CHROMEOS) |
159 } | 124 } |
160 | 125 |
161 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is | 126 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is |
162 // the event target of the X touch events should generate the corresponding | 127 // the event target of the X touch events should generate the corresponding |
163 // ui::TouchEvent for its delegate. | 128 // ui::TouchEvent for its delegate. |
164 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
165 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { | 130 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { |
166 // Fake a ChromeOS running env. | 131 // Fake a ChromeOS running env. |
167 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | 132 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
168 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 133 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
169 | 134 |
170 scoped_ptr<WindowTreeHostX11> window_tree_host1( | 135 scoped_ptr<WindowTreeHostX11> window_tree_host1( |
171 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); | 136 new WindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); |
172 scoped_ptr<TestWindowTreeHostDelegate> delegate1( | 137 window_tree_host1->InitHost(); |
173 new TestWindowTreeHostDelegate()); | 138 scoped_ptr<RootWindowEventHandler> handler1(new RootWindowEventHandler()); |
174 window_tree_host1->set_delegate(delegate1.get()); | 139 window_tree_host1->window()->AddPreTargetHandler(handler1.get()); |
175 | 140 |
176 int host2_y_offset = 1700; | 141 int host2_y_offset = 1700; |
177 scoped_ptr<WindowTreeHostX11> window_tree_host2( | 142 scoped_ptr<WindowTreeHostX11> window_tree_host2( |
178 new WindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); | 143 new WindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); |
179 scoped_ptr<TestWindowTreeHostDelegate> delegate2( | 144 window_tree_host2->InitHost(); |
180 new TestWindowTreeHostDelegate()); | 145 scoped_ptr<RootWindowEventHandler> handler2(new RootWindowEventHandler()); |
181 window_tree_host2->set_delegate(delegate2.get()); | 146 window_tree_host2->window()->AddPreTargetHandler(handler2.get()); |
182 | 147 |
183 std::vector<unsigned int> devices; | 148 std::vector<unsigned int> devices; |
184 devices.push_back(0); | 149 devices.push_back(0); |
185 ui::SetUpTouchDevicesForTest(devices); | 150 ui::SetUpTouchDevicesForTest(devices); |
186 std::vector<ui::Valuator> valuators; | 151 std::vector<ui::Valuator> valuators; |
187 | 152 |
188 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 153 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
189 EXPECT_EQ(-1, delegate1->last_touch_id()); | 154 EXPECT_EQ(-1, handler1->last_touch_id()); |
190 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type()); | 155 EXPECT_EQ(ui::ET_UNKNOWN, handler2->last_touch_type()); |
191 EXPECT_EQ(-1, delegate2->last_touch_id()); | 156 EXPECT_EQ(-1, handler2->last_touch_id()); |
192 | 157 |
193 // 2 Touch events are targeted at the second WindowTreeHost. | 158 // 2 Touch events are targeted at the second WindowTreeHost. |
194 ui::ScopedXI2Event scoped_xevent; | 159 ui::ScopedXI2Event scoped_xevent; |
195 scoped_xevent.InitTouchEvent( | 160 scoped_xevent.InitTouchEvent( |
196 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); | 161 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); |
197 window_tree_host1->Dispatch(scoped_xevent); | 162 window_tree_host1->Dispatch(scoped_xevent); |
198 window_tree_host2->Dispatch(scoped_xevent); | 163 window_tree_host2->Dispatch(scoped_xevent); |
199 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 164 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
200 EXPECT_EQ(-1, delegate1->last_touch_id()); | 165 EXPECT_EQ(-1, handler1->last_touch_id()); |
201 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 166 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
202 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); | 167 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); |
203 EXPECT_EQ(0, delegate2->last_touch_id()); | 168 EXPECT_EQ(0, handler2->last_touch_id()); |
204 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), | 169 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), |
205 delegate2->last_touch_location()); | 170 handler2->last_touch_location()); |
206 | 171 |
207 scoped_xevent.InitTouchEvent( | 172 scoped_xevent.InitTouchEvent( |
208 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); | 173 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); |
209 window_tree_host1->Dispatch(scoped_xevent); | 174 window_tree_host1->Dispatch(scoped_xevent); |
210 window_tree_host2->Dispatch(scoped_xevent); | 175 window_tree_host2->Dispatch(scoped_xevent); |
211 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 176 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
212 EXPECT_EQ(-1, delegate1->last_touch_id()); | 177 EXPECT_EQ(-1, handler1->last_touch_id()); |
213 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 178 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
214 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); | 179 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); |
215 EXPECT_EQ(1, delegate2->last_touch_id()); | 180 EXPECT_EQ(1, handler2->last_touch_id()); |
216 EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset), | 181 EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset), |
217 delegate2->last_touch_location()); | 182 handler2->last_touch_location()); |
218 | 183 |
219 scoped_xevent.InitTouchEvent( | 184 scoped_xevent.InitTouchEvent( |
220 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); | 185 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); |
221 window_tree_host1->Dispatch(scoped_xevent); | 186 window_tree_host1->Dispatch(scoped_xevent); |
222 window_tree_host2->Dispatch(scoped_xevent); | 187 window_tree_host2->Dispatch(scoped_xevent); |
223 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 188 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
224 EXPECT_EQ(-1, delegate1->last_touch_id()); | 189 EXPECT_EQ(-1, handler1->last_touch_id()); |
225 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 190 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
226 EXPECT_EQ(ui::ET_TOUCH_MOVED, delegate2->last_touch_type()); | 191 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); |
227 EXPECT_EQ(0, delegate2->last_touch_id()); | 192 EXPECT_EQ(0, handler2->last_touch_id()); |
228 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), | 193 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), |
229 delegate2->last_touch_location()); | 194 handler2->last_touch_location()); |
230 | 195 |
231 scoped_xevent.InitTouchEvent( | 196 scoped_xevent.InitTouchEvent( |
232 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); | 197 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); |
233 window_tree_host1->Dispatch(scoped_xevent); | 198 window_tree_host1->Dispatch(scoped_xevent); |
234 window_tree_host2->Dispatch(scoped_xevent); | 199 window_tree_host2->Dispatch(scoped_xevent); |
235 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 200 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
236 EXPECT_EQ(-1, delegate1->last_touch_id()); | 201 EXPECT_EQ(-1, handler1->last_touch_id()); |
237 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 202 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
238 EXPECT_EQ(ui::ET_TOUCH_MOVED, delegate2->last_touch_type()); | 203 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); |
239 EXPECT_EQ(1, delegate2->last_touch_id()); | 204 EXPECT_EQ(1, handler2->last_touch_id()); |
240 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), | 205 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), |
241 delegate2->last_touch_location()); | 206 handler2->last_touch_location()); |
242 | 207 |
243 scoped_xevent.InitTouchEvent( | 208 scoped_xevent.InitTouchEvent( |
244 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); | 209 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); |
245 window_tree_host1->Dispatch(scoped_xevent); | 210 window_tree_host1->Dispatch(scoped_xevent); |
246 window_tree_host2->Dispatch(scoped_xevent); | 211 window_tree_host2->Dispatch(scoped_xevent); |
247 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 212 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
248 EXPECT_EQ(-1, delegate1->last_touch_id()); | 213 EXPECT_EQ(-1, handler1->last_touch_id()); |
249 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 214 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
250 EXPECT_EQ(ui::ET_TOUCH_RELEASED, delegate2->last_touch_type()); | 215 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); |
251 EXPECT_EQ(0, delegate2->last_touch_id()); | 216 EXPECT_EQ(0, handler2->last_touch_id()); |
252 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), | 217 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), |
253 delegate2->last_touch_location()); | 218 handler2->last_touch_location()); |
254 | 219 |
255 scoped_xevent.InitTouchEvent( | 220 scoped_xevent.InitTouchEvent( |
256 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); | 221 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); |
257 window_tree_host1->Dispatch(scoped_xevent); | 222 window_tree_host1->Dispatch(scoped_xevent); |
258 window_tree_host2->Dispatch(scoped_xevent); | 223 window_tree_host2->Dispatch(scoped_xevent); |
259 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 224 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
260 EXPECT_EQ(-1, delegate1->last_touch_id()); | 225 EXPECT_EQ(-1, handler1->last_touch_id()); |
261 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 226 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
262 EXPECT_EQ(ui::ET_TOUCH_RELEASED, delegate2->last_touch_type()); | 227 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); |
263 EXPECT_EQ(1, delegate2->last_touch_id()); | 228 EXPECT_EQ(1, handler2->last_touch_id()); |
264 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), | 229 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), |
265 delegate2->last_touch_location()); | 230 handler2->last_touch_location()); |
266 | 231 |
267 // Revert the CrOS testing env otherwise the following non-CrOS aura | 232 // Revert the CrOS testing env otherwise the following non-CrOS aura |
268 // tests will fail. | 233 // tests will fail. |
269 // Fake a ChromeOS running env. | 234 // Fake a ChromeOS running env. |
270 kLsbRelease = ""; | 235 kLsbRelease = ""; |
271 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 236 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
272 } | 237 } |
273 #endif // defined(OS_CHROMEOS) | 238 #endif // defined(OS_CHROMEOS) |
274 | 239 |
275 } // namespace aura | 240 } // namespace aura |
OLD | NEW |