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

Side by Side Diff: ash/host/ash_window_tree_host_x11_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « ash/host/ash_window_tree_host_x11.cc ('k') | ash/host/transformer_helper.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/host/ash_window_tree_host_x11.h" 5 #include "ash/host/ash_window_tree_host_x11.h"
6 6
7 #undef None 7 #undef None
8 #undef Bool 8 #undef Bool
9 9
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // tests will fail. 77 // tests will fail.
78 // Fake a ChromeOS running env. 78 // Fake a ChromeOS running env.
79 const char* kLsbRelease = ""; 79 const char* kLsbRelease = "";
80 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 80 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
81 #endif 81 #endif
82 } 82 }
83 }; 83 };
84 84
85 // Fails on ChromeOS valgrind bot. http://crbug.com/499997 85 // Fails on ChromeOS valgrind bot. http://crbug.com/499997
86 #if defined(OS_CHROMEOS) 86 #if defined(OS_CHROMEOS)
87 #define MAYBE_DispatchTouchEventToOneRootWindow DISABLED_DispatchTouchEventToOne RootWindow 87 #define MAYBE_DispatchTouchEventToOneRootWindow \
88 DISABLED_DispatchTouchEventToOneRootWindow
88 #else 89 #else
89 #define MAYBE_DispatchTouchEventToOneRootWindow DispatchTouchEventToOneRootWindo w 90 #define MAYBE_DispatchTouchEventToOneRootWindow \
91 DispatchTouchEventToOneRootWindow
90 #endif 92 #endif
91 93
92 // Send X touch events to one WindowTreeHost. The WindowTreeHost's 94 // Send X touch events to one WindowTreeHost. The WindowTreeHost's
93 // delegate will get corresponding ui::TouchEvent if the touch events 95 // delegate will get corresponding ui::TouchEvent if the touch events
94 // are targeting this WindowTreeHost. 96 // are targeting this WindowTreeHost.
95 TEST_F(AshWindowTreeHostX11Test, MAYBE_DispatchTouchEventToOneRootWindow) { 97 TEST_F(AshWindowTreeHostX11Test, MAYBE_DispatchTouchEventToOneRootWindow) {
96 std::unique_ptr<aura::WindowTreeHostX11> window_tree_host( 98 std::unique_ptr<aura::WindowTreeHostX11> window_tree_host(
97 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); 99 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
98 window_tree_host->InitHost(); 100 window_tree_host->InitHost();
99 std::unique_ptr<RootWindowEventHandler> handler( 101 std::unique_ptr<RootWindowEventHandler> handler(
100 new RootWindowEventHandler(window_tree_host.get())); 102 new RootWindowEventHandler(window_tree_host.get()));
101 103
102 std::vector<int> devices; 104 std::vector<int> devices;
103 devices.push_back(0); 105 devices.push_back(0);
104 ui::SetUpTouchDevicesForTest(devices); 106 ui::SetUpTouchDevicesForTest(devices);
105 std::vector<ui::Valuator> valuators; 107 std::vector<ui::Valuator> valuators;
106 108
107 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); 109 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type());
108 EXPECT_EQ(-1, handler->last_touch_id()); 110 EXPECT_EQ(-1, handler->last_touch_id());
109 111
110 ui::ScopedXI2Event scoped_xevent; 112 ui::ScopedXI2Event scoped_xevent;
111 // This touch is out of bounds. 113 // This touch is out of bounds.
112 scoped_xevent.InitTouchEvent( 114 scoped_xevent.InitTouchEvent(0, XI_TouchBegin, 5, gfx::Point(1500, 2500),
113 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); 115 valuators);
114 if (window_tree_host->CanDispatchEvent(scoped_xevent)) 116 if (window_tree_host->CanDispatchEvent(scoped_xevent))
115 window_tree_host->DispatchEvent(scoped_xevent); 117 window_tree_host->DispatchEvent(scoped_xevent);
116 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type()); 118 EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type());
117 EXPECT_EQ(-1, handler->last_touch_id()); 119 EXPECT_EQ(-1, handler->last_touch_id());
118 EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location()); 120 EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location());
119 121
120 // Following touchs are within bounds and are passed to delegate. 122 // Following touchs are within bounds and are passed to delegate.
121 scoped_xevent.InitTouchEvent( 123 scoped_xevent.InitTouchEvent(0, XI_TouchBegin, 5, gfx::Point(1500, 1500),
122 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); 124 valuators);
123 if (window_tree_host->CanDispatchEvent(scoped_xevent)) 125 if (window_tree_host->CanDispatchEvent(scoped_xevent))
124 window_tree_host->DispatchEvent(scoped_xevent); 126 window_tree_host->DispatchEvent(scoped_xevent);
125 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type()); 127 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type());
126 EXPECT_EQ(0, handler->last_touch_id()); 128 EXPECT_EQ(0, handler->last_touch_id());
127 EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location()); 129 EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location());
128 130
129 scoped_xevent.InitTouchEvent( 131 scoped_xevent.InitTouchEvent(0, XI_TouchUpdate, 5, gfx::Point(1500, 1600),
130 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); 132 valuators);
131 if (window_tree_host->CanDispatchEvent(scoped_xevent)) 133 if (window_tree_host->CanDispatchEvent(scoped_xevent))
132 window_tree_host->DispatchEvent(scoped_xevent); 134 window_tree_host->DispatchEvent(scoped_xevent);
133 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type()); 135 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type());
134 EXPECT_EQ(0, handler->last_touch_id()); 136 EXPECT_EQ(0, handler->last_touch_id());
135 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); 137 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());
136 138
137 scoped_xevent.InitTouchEvent( 139 scoped_xevent.InitTouchEvent(0, XI_TouchEnd, 5, gfx::Point(1500, 1600),
138 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); 140 valuators);
139 if (window_tree_host->CanDispatchEvent(scoped_xevent)) 141 if (window_tree_host->CanDispatchEvent(scoped_xevent))
140 window_tree_host->DispatchEvent(scoped_xevent); 142 window_tree_host->DispatchEvent(scoped_xevent);
141 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); 143 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type());
142 EXPECT_EQ(0, handler->last_touch_id()); 144 EXPECT_EQ(0, handler->last_touch_id());
143 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); 145 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());
144 146
145 handler.reset(); 147 handler.reset();
146 } 148 }
147 149
148 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is 150 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is
(...skipping 18 matching lines...) Expand all
167 ui::SetUpTouchDevicesForTest(devices); 169 ui::SetUpTouchDevicesForTest(devices);
168 std::vector<ui::Valuator> valuators; 170 std::vector<ui::Valuator> valuators;
169 171
170 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 172 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
171 EXPECT_EQ(-1, handler1->last_touch_id()); 173 EXPECT_EQ(-1, handler1->last_touch_id());
172 EXPECT_EQ(ui::ET_UNKNOWN, handler2->last_touch_type()); 174 EXPECT_EQ(ui::ET_UNKNOWN, handler2->last_touch_type());
173 EXPECT_EQ(-1, handler2->last_touch_id()); 175 EXPECT_EQ(-1, handler2->last_touch_id());
174 176
175 // 2 Touch events are targeted at the second WindowTreeHost. 177 // 2 Touch events are targeted at the second WindowTreeHost.
176 ui::ScopedXI2Event scoped_xevent; 178 ui::ScopedXI2Event scoped_xevent;
177 scoped_xevent.InitTouchEvent( 179 scoped_xevent.InitTouchEvent(0, XI_TouchBegin, 5, gfx::Point(1500, 2500),
178 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); 180 valuators);
179 if (window_tree_host1->CanDispatchEvent(scoped_xevent)) 181 if (window_tree_host1->CanDispatchEvent(scoped_xevent))
180 window_tree_host1->DispatchEvent(scoped_xevent); 182 window_tree_host1->DispatchEvent(scoped_xevent);
181 if (window_tree_host2->CanDispatchEvent(scoped_xevent)) 183 if (window_tree_host2->CanDispatchEvent(scoped_xevent))
182 window_tree_host2->DispatchEvent(scoped_xevent); 184 window_tree_host2->DispatchEvent(scoped_xevent);
183 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 185 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
184 EXPECT_EQ(-1, handler1->last_touch_id()); 186 EXPECT_EQ(-1, handler1->last_touch_id());
185 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 187 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
186 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); 188 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type());
187 EXPECT_EQ(0, handler2->last_touch_id()); 189 EXPECT_EQ(0, handler2->last_touch_id());
188 EXPECT_EQ(gfx::Point(1500, 2500), handler2->last_touch_location()); 190 EXPECT_EQ(gfx::Point(1500, 2500), handler2->last_touch_location());
189 191
190 scoped_xevent.InitTouchEvent( 192 scoped_xevent.InitTouchEvent(0, XI_TouchBegin, 6, gfx::Point(1600, 2600),
191 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators); 193 valuators);
192 if (window_tree_host1->CanDispatchEvent(scoped_xevent)) 194 if (window_tree_host1->CanDispatchEvent(scoped_xevent))
193 window_tree_host1->DispatchEvent(scoped_xevent); 195 window_tree_host1->DispatchEvent(scoped_xevent);
194 if (window_tree_host2->CanDispatchEvent(scoped_xevent)) 196 if (window_tree_host2->CanDispatchEvent(scoped_xevent))
195 window_tree_host2->DispatchEvent(scoped_xevent); 197 window_tree_host2->DispatchEvent(scoped_xevent);
196 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 198 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
197 EXPECT_EQ(-1, handler1->last_touch_id()); 199 EXPECT_EQ(-1, handler1->last_touch_id());
198 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 200 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
199 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type()); 201 EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type());
200 EXPECT_EQ(1, handler2->last_touch_id()); 202 EXPECT_EQ(1, handler2->last_touch_id());
201 EXPECT_EQ(gfx::Point(1600, 2600), handler2->last_touch_location()); 203 EXPECT_EQ(gfx::Point(1600, 2600), handler2->last_touch_location());
202 204
203 scoped_xevent.InitTouchEvent( 205 scoped_xevent.InitTouchEvent(0, XI_TouchUpdate, 5, gfx::Point(1500, 2550),
204 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators); 206 valuators);
205 if (window_tree_host1->CanDispatchEvent(scoped_xevent)) 207 if (window_tree_host1->CanDispatchEvent(scoped_xevent))
206 window_tree_host1->DispatchEvent(scoped_xevent); 208 window_tree_host1->DispatchEvent(scoped_xevent);
207 if (window_tree_host2->CanDispatchEvent(scoped_xevent)) 209 if (window_tree_host2->CanDispatchEvent(scoped_xevent))
208 window_tree_host2->DispatchEvent(scoped_xevent); 210 window_tree_host2->DispatchEvent(scoped_xevent);
209 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 211 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
210 EXPECT_EQ(-1, handler1->last_touch_id()); 212 EXPECT_EQ(-1, handler1->last_touch_id());
211 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 213 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
212 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); 214 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type());
213 EXPECT_EQ(0, handler2->last_touch_id()); 215 EXPECT_EQ(0, handler2->last_touch_id());
214 EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location()); 216 EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location());
215 217
216 scoped_xevent.InitTouchEvent( 218 scoped_xevent.InitTouchEvent(0, XI_TouchUpdate, 6, gfx::Point(1600, 2650),
217 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators); 219 valuators);
218 if (window_tree_host1->CanDispatchEvent(scoped_xevent)) 220 if (window_tree_host1->CanDispatchEvent(scoped_xevent))
219 window_tree_host1->DispatchEvent(scoped_xevent); 221 window_tree_host1->DispatchEvent(scoped_xevent);
220 if (window_tree_host2->CanDispatchEvent(scoped_xevent)) 222 if (window_tree_host2->CanDispatchEvent(scoped_xevent))
221 window_tree_host2->DispatchEvent(scoped_xevent); 223 window_tree_host2->DispatchEvent(scoped_xevent);
222 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 224 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
223 EXPECT_EQ(-1, handler1->last_touch_id()); 225 EXPECT_EQ(-1, handler1->last_touch_id());
224 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 226 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
225 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type()); 227 EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type());
226 EXPECT_EQ(1, handler2->last_touch_id()); 228 EXPECT_EQ(1, handler2->last_touch_id());
227 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); 229 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location());
228 230
229 scoped_xevent.InitTouchEvent( 231 scoped_xevent.InitTouchEvent(0, XI_TouchEnd, 5, gfx::Point(1500, 2550),
230 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators); 232 valuators);
231 if (window_tree_host1->CanDispatchEvent(scoped_xevent)) 233 if (window_tree_host1->CanDispatchEvent(scoped_xevent))
232 window_tree_host1->DispatchEvent(scoped_xevent); 234 window_tree_host1->DispatchEvent(scoped_xevent);
233 if (window_tree_host2->CanDispatchEvent(scoped_xevent)) 235 if (window_tree_host2->CanDispatchEvent(scoped_xevent))
234 window_tree_host2->DispatchEvent(scoped_xevent); 236 window_tree_host2->DispatchEvent(scoped_xevent);
235 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 237 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
236 EXPECT_EQ(-1, handler1->last_touch_id()); 238 EXPECT_EQ(-1, handler1->last_touch_id());
237 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 239 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
238 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); 240 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type());
239 EXPECT_EQ(0, handler2->last_touch_id()); 241 EXPECT_EQ(0, handler2->last_touch_id());
240 EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location()); 242 EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location());
241 243
242 scoped_xevent.InitTouchEvent( 244 scoped_xevent.InitTouchEvent(0, XI_TouchEnd, 6, gfx::Point(1600, 2650),
243 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators); 245 valuators);
244 if (window_tree_host1->CanDispatchEvent(scoped_xevent)) 246 if (window_tree_host1->CanDispatchEvent(scoped_xevent))
245 window_tree_host1->DispatchEvent(scoped_xevent); 247 window_tree_host1->DispatchEvent(scoped_xevent);
246 if (window_tree_host2->CanDispatchEvent(scoped_xevent)) 248 if (window_tree_host2->CanDispatchEvent(scoped_xevent))
247 window_tree_host2->DispatchEvent(scoped_xevent); 249 window_tree_host2->DispatchEvent(scoped_xevent);
248 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); 250 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
249 EXPECT_EQ(-1, handler1->last_touch_id()); 251 EXPECT_EQ(-1, handler1->last_touch_id());
250 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); 252 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
251 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); 253 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type());
252 EXPECT_EQ(1, handler2->last_touch_id()); 254 EXPECT_EQ(1, handler2->last_touch_id());
253 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location()); 255 EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location());
254 256
255 handler1.reset(); 257 handler1.reset();
256 handler2.reset(); 258 handler2.reset();
257 } 259 }
258 260
259 } // namespace aura 261 } // namespace aura
OLDNEW
« no previous file with comments | « ash/host/ash_window_tree_host_x11.cc ('k') | ash/host/transformer_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698