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