Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: ui/aura/window_tree_host_x11_unittest.cc

Issue 219743002: x11: Move X event handling out of the message-pump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-r261267 Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h"
10 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 std::vector<ui::Valuator> valuators; 79 std::vector<ui::Valuator> valuators;
80 80
81 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); 81 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type());
82 EXPECT_EQ(-1, handler->last_touch_id()); 82 EXPECT_EQ(-1, handler->last_touch_id());
83 83
84 ui::ScopedXI2Event scoped_xevent; 84 ui::ScopedXI2Event scoped_xevent;
85 #if defined(OS_CHROMEOS) 85 #if defined(OS_CHROMEOS)
86 // This touch is out of bounds. 86 // This touch is out of bounds.
87 scoped_xevent.InitTouchEvent( 87 scoped_xevent.InitTouchEvent(
88 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); 88 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators);
89 window_tree_host->Dispatch(scoped_xevent); 89 window_tree_host->DispatchEvent(scoped_xevent);
90 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); 90 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type());
91 EXPECT_EQ(-1, handler->last_touch_id()); 91 EXPECT_EQ(-1, handler->last_touch_id());
92 EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location()); 92 EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location());
93 #endif // defined(OS_CHROMEOS) 93 #endif // defined(OS_CHROMEOS)
94 94
95 // Following touchs are within bounds and are passed to delegate. 95 // Following touchs are within bounds and are passed to delegate.
96 scoped_xevent.InitTouchEvent( 96 scoped_xevent.InitTouchEvent(
97 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); 97 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators);
98 window_tree_host->Dispatch(scoped_xevent); 98 window_tree_host->DispatchEvent(scoped_xevent);
99 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type()); 99 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type());
100 EXPECT_EQ(0, handler->last_touch_id()); 100 EXPECT_EQ(0, handler->last_touch_id());
101 EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location()); 101 EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location());
102 102
103 scoped_xevent.InitTouchEvent( 103 scoped_xevent.InitTouchEvent(
104 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); 104 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators);
105 window_tree_host->Dispatch(scoped_xevent); 105 window_tree_host->DispatchEvent(scoped_xevent);
106 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type()); 106 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type());
107 EXPECT_EQ(0, handler->last_touch_id()); 107 EXPECT_EQ(0, handler->last_touch_id());
108 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); 108 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());
109 109
110 scoped_xevent.InitTouchEvent( 110 scoped_xevent.InitTouchEvent(
111 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); 111 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators);
112 window_tree_host->Dispatch(scoped_xevent); 112 window_tree_host->DispatchEvent(scoped_xevent);
113 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); 113 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type());
114 EXPECT_EQ(0, handler->last_touch_id()); 114 EXPECT_EQ(0, handler->last_touch_id());
115 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); 115 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());
116 116
117 // Revert the CrOS testing env otherwise the following non-CrOS aura 117 // Revert the CrOS testing env otherwise the following non-CrOS aura
118 // tests will fail. 118 // tests will fail.
119 #if defined(OS_CHROMEOS) 119 #if defined(OS_CHROMEOS)
120 // Fake a ChromeOS running env. 120 // Fake a ChromeOS running env.
121 kLsbRelease = ""; 121 kLsbRelease = "";
122 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 122 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
(...skipping 29 matching lines...) Expand all
152 152
153 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 153 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
154 EXPECT_EQ(-1, handler1->last_touch_id()); 154 EXPECT_EQ(-1, handler1->last_touch_id());
155 EXPECT_EQ(ui::ET_UNKNOWN, handler2->last_touch_type()); 155 EXPECT_EQ(ui::ET_UNKNOWN, handler2->last_touch_type());
156 EXPECT_EQ(-1, handler2->last_touch_id()); 156 EXPECT_EQ(-1, handler2->last_touch_id());
157 157
158 // 2 Touch events are targeted at the second WindowTreeHost. 158 // 2 Touch events are targeted at the second WindowTreeHost.
159 ui::ScopedXI2Event scoped_xevent; 159 ui::ScopedXI2Event scoped_xevent;
160 scoped_xevent.InitTouchEvent( 160 scoped_xevent.InitTouchEvent(
161 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); 161 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators);
162 window_tree_host1->Dispatch(scoped_xevent); 162 window_tree_host1->DispatchEvent(scoped_xevent);
163 window_tree_host2->Dispatch(scoped_xevent); 163 window_tree_host2->DispatchEvent(scoped_xevent);
164 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 164 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
165 EXPECT_EQ(-1, handler1->last_touch_id()); 165 EXPECT_EQ(-1, handler1->last_touch_id());
166 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 166 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
167 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); 167 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type());
168 EXPECT_EQ(0, handler2->last_touch_id()); 168 EXPECT_EQ(0, handler2->last_touch_id());
169 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset), 169 EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset),
170 handler2->last_touch_location()); 170 handler2->last_touch_location());
171 171
172 scoped_xevent.InitTouchEvent( 172 scoped_xevent.InitTouchEvent(
173 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); 173 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators);
174 window_tree_host1->Dispatch(scoped_xevent); 174 window_tree_host1->DispatchEvent(scoped_xevent);
175 window_tree_host2->Dispatch(scoped_xevent); 175 window_tree_host2->DispatchEvent(scoped_xevent);
176 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 176 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
177 EXPECT_EQ(-1, handler1->last_touch_id()); 177 EXPECT_EQ(-1, handler1->last_touch_id());
178 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 178 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
179 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); 179 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type());
180 EXPECT_EQ(1, handler2->last_touch_id()); 180 EXPECT_EQ(1, handler2->last_touch_id());
181 EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset), 181 EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset),
182 handler2->last_touch_location()); 182 handler2->last_touch_location());
183 183
184 scoped_xevent.InitTouchEvent( 184 scoped_xevent.InitTouchEvent(
185 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); 185 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators);
186 window_tree_host1->Dispatch(scoped_xevent); 186 window_tree_host1->DispatchEvent(scoped_xevent);
187 window_tree_host2->Dispatch(scoped_xevent); 187 window_tree_host2->DispatchEvent(scoped_xevent);
188 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 188 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
189 EXPECT_EQ(-1, handler1->last_touch_id()); 189 EXPECT_EQ(-1, handler1->last_touch_id());
190 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 190 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
191 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); 191 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type());
192 EXPECT_EQ(0, handler2->last_touch_id()); 192 EXPECT_EQ(0, handler2->last_touch_id());
193 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), 193 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset),
194 handler2->last_touch_location()); 194 handler2->last_touch_location());
195 195
196 scoped_xevent.InitTouchEvent( 196 scoped_xevent.InitTouchEvent(
197 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); 197 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators);
198 window_tree_host1->Dispatch(scoped_xevent); 198 window_tree_host1->DispatchEvent(scoped_xevent);
199 window_tree_host2->Dispatch(scoped_xevent); 199 window_tree_host2->DispatchEvent(scoped_xevent);
200 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 200 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
201 EXPECT_EQ(-1, handler1->last_touch_id()); 201 EXPECT_EQ(-1, handler1->last_touch_id());
202 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 202 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
203 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); 203 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type());
204 EXPECT_EQ(1, handler2->last_touch_id()); 204 EXPECT_EQ(1, handler2->last_touch_id());
205 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), 205 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset),
206 handler2->last_touch_location()); 206 handler2->last_touch_location());
207 207
208 scoped_xevent.InitTouchEvent( 208 scoped_xevent.InitTouchEvent(
209 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); 209 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators);
210 window_tree_host1->Dispatch(scoped_xevent); 210 window_tree_host1->DispatchEvent(scoped_xevent);
211 window_tree_host2->Dispatch(scoped_xevent); 211 window_tree_host2->DispatchEvent(scoped_xevent);
212 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 212 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
213 EXPECT_EQ(-1, handler1->last_touch_id()); 213 EXPECT_EQ(-1, handler1->last_touch_id());
214 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 214 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
215 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); 215 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type());
216 EXPECT_EQ(0, handler2->last_touch_id()); 216 EXPECT_EQ(0, handler2->last_touch_id());
217 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset), 217 EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset),
218 handler2->last_touch_location()); 218 handler2->last_touch_location());
219 219
220 scoped_xevent.InitTouchEvent( 220 scoped_xevent.InitTouchEvent(
221 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); 221 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators);
222 window_tree_host1->Dispatch(scoped_xevent); 222 window_tree_host1->DispatchEvent(scoped_xevent);
223 window_tree_host2->Dispatch(scoped_xevent); 223 window_tree_host2->DispatchEvent(scoped_xevent);
224 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 224 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
225 EXPECT_EQ(-1, handler1->last_touch_id()); 225 EXPECT_EQ(-1, handler1->last_touch_id());
226 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 226 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
227 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); 227 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type());
228 EXPECT_EQ(1, handler2->last_touch_id()); 228 EXPECT_EQ(1, handler2->last_touch_id());
229 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), 229 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset),
230 handler2->last_touch_location()); 230 handler2->last_touch_location());
231 231
232 // Revert the CrOS testing env otherwise the following non-CrOS aura 232 // Revert the CrOS testing env otherwise the following non-CrOS aura
233 // tests will fail. 233 // tests will fail.
234 // Fake a ChromeOS running env. 234 // Fake a ChromeOS running env.
235 kLsbRelease = ""; 235 kLsbRelease = "";
236 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 236 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
237 } 237 }
238 #endif // defined(OS_CHROMEOS) 238 #endif // defined(OS_CHROMEOS)
239 239
240 } // namespace aura 240 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/base/clipboard/clipboard_aurax11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698