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

Side by Side Diff: ui/views/widget/root_view_unittest.cc

Issue 565583005: Clean up GestureEventDetails constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Upload to the most recent patch Created 6 years, 3 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 | « ui/views/view_targeter_unittest.cc ('k') | ui/views/widget/widget_interactive_uitest.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 #include "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include "ui/views/context_menu_controller.h" 7 #include "ui/views/context_menu_controller.h"
8 #include "ui/views/test/views_test_base.h" 8 #include "ui/views/test/views_test_base.h"
9 #include "ui/views/view_targeter.h" 9 #include "ui/views/view_targeter.h"
10 #include "ui/views/widget/root_view.h" 10 #include "ui/views/widget/root_view.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10)); 199 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10));
200 parent_view->AddChildView(other_child_view); 200 parent_view->AddChildView(other_child_view);
201 201
202 // |parent_view| should not show a context menu as a result of a long press on 202 // |parent_view| should not show a context menu as a result of a long press on
203 // |gesture_handling_child_view|. 203 // |gesture_handling_child_view|.
204 ui::GestureEvent long_press1( 204 ui::GestureEvent long_press1(
205 5, 205 5,
206 5, 206 5,
207 0, 207 0,
208 base::TimeDelta(), 208 base::TimeDelta(),
209 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 209 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
210 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); 210 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
211 211
212 ui::GestureEvent end1(5, 212 ui::GestureEvent end1(
213 5, 213 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
214 0,
215 base::TimeDelta(),
216 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
217 details = root_view->OnEventFromSource(&end1); 214 details = root_view->OnEventFromSource(&end1);
218 215
219 EXPECT_FALSE(details.target_destroyed); 216 EXPECT_FALSE(details.target_destroyed);
220 EXPECT_FALSE(details.dispatcher_destroyed); 217 EXPECT_FALSE(details.dispatcher_destroyed);
221 EXPECT_EQ(0, controller.show_context_menu_calls()); 218 EXPECT_EQ(0, controller.show_context_menu_calls());
222 controller.Reset(); 219 controller.Reset();
223 220
224 // |parent_view| should show a context menu as a result of a long press on 221 // |parent_view| should show a context menu as a result of a long press on
225 // |other_child_view|. 222 // |other_child_view|.
226 ui::GestureEvent long_press2( 223 ui::GestureEvent long_press2(
227 25, 224 25,
228 5, 225 5,
229 0, 226 0,
230 base::TimeDelta(), 227 base::TimeDelta(),
231 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 228 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
232 details = root_view->OnEventFromSource(&long_press2); 229 details = root_view->OnEventFromSource(&long_press2);
233 230
234 ui::GestureEvent end2(25, 231 ui::GestureEvent end2(
235 5, 232 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
236 0,
237 base::TimeDelta(),
238 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
239 details = root_view->OnEventFromSource(&end2); 233 details = root_view->OnEventFromSource(&end2);
240 234
241 EXPECT_FALSE(details.target_destroyed); 235 EXPECT_FALSE(details.target_destroyed);
242 EXPECT_FALSE(details.dispatcher_destroyed); 236 EXPECT_FALSE(details.dispatcher_destroyed);
243 EXPECT_EQ(1, controller.show_context_menu_calls()); 237 EXPECT_EQ(1, controller.show_context_menu_calls());
244 controller.Reset(); 238 controller.Reset();
245 239
246 // |parent_view| should show a context menu as a result of a long press on 240 // |parent_view| should show a context menu as a result of a long press on
247 // itself. 241 // itself.
248 ui::GestureEvent long_press3( 242 ui::GestureEvent long_press3(
249 50, 243 50,
250 50, 244 50,
251 0, 245 0,
252 base::TimeDelta(), 246 base::TimeDelta(),
253 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 247 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
254 details = root_view->OnEventFromSource(&long_press3); 248 details = root_view->OnEventFromSource(&long_press3);
255 249
256 ui::GestureEvent end3(25, 250 ui::GestureEvent end3(
257 5, 251 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
258 0,
259 base::TimeDelta(),
260 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
261 details = root_view->OnEventFromSource(&end3); 252 details = root_view->OnEventFromSource(&end3);
262 253
263 EXPECT_FALSE(details.target_destroyed); 254 EXPECT_FALSE(details.target_destroyed);
264 EXPECT_FALSE(details.dispatcher_destroyed); 255 EXPECT_FALSE(details.dispatcher_destroyed);
265 EXPECT_EQ(1, controller.show_context_menu_calls()); 256 EXPECT_EQ(1, controller.show_context_menu_calls());
266 } 257 }
267 258
268 // Tests that context menus are not shown for disabled views on a long press. 259 // Tests that context menus are not shown for disabled views on a long press.
269 TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) { 260 TEST_F(RootViewTest, ContextMenuFromLongPressOnDisabledView) {
270 Widget widget; 261 Widget widget;
(...skipping 22 matching lines...) Expand all
293 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10)); 284 other_child_view->SetBoundsRect(gfx::Rect(20, 0, 10, 10));
294 parent_view->AddChildView(other_child_view); 285 parent_view->AddChildView(other_child_view);
295 286
296 // |parent_view| should not show a context menu as a result of a long press on 287 // |parent_view| should not show a context menu as a result of a long press on
297 // |gesture_handling_child_view|. 288 // |gesture_handling_child_view|.
298 ui::GestureEvent long_press1( 289 ui::GestureEvent long_press1(
299 5, 290 5,
300 5, 291 5,
301 0, 292 0,
302 base::TimeDelta(), 293 base::TimeDelta(),
303 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 294 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
304 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1); 295 ui::EventDispatchDetails details = root_view->OnEventFromSource(&long_press1);
305 296
306 ui::GestureEvent end1(5, 297 ui::GestureEvent end1(
307 5, 298 5, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
308 0,
309 base::TimeDelta(),
310 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
311 details = root_view->OnEventFromSource(&end1); 299 details = root_view->OnEventFromSource(&end1);
312 300
313 EXPECT_FALSE(details.target_destroyed); 301 EXPECT_FALSE(details.target_destroyed);
314 EXPECT_FALSE(details.dispatcher_destroyed); 302 EXPECT_FALSE(details.dispatcher_destroyed);
315 EXPECT_EQ(0, controller.show_context_menu_calls()); 303 EXPECT_EQ(0, controller.show_context_menu_calls());
316 controller.Reset(); 304 controller.Reset();
317 305
318 // |parent_view| should not show a context menu as a result of a long press on 306 // |parent_view| should not show a context menu as a result of a long press on
319 // |other_child_view|. 307 // |other_child_view|.
320 ui::GestureEvent long_press2( 308 ui::GestureEvent long_press2(
321 25, 309 25,
322 5, 310 5,
323 0, 311 0,
324 base::TimeDelta(), 312 base::TimeDelta(),
325 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 313 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
326 details = root_view->OnEventFromSource(&long_press2); 314 details = root_view->OnEventFromSource(&long_press2);
327 315
328 ui::GestureEvent end2(25, 316 ui::GestureEvent end2(
329 5, 317 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
330 0,
331 base::TimeDelta(),
332 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
333 details = root_view->OnEventFromSource(&end2); 318 details = root_view->OnEventFromSource(&end2);
334 319
335 EXPECT_FALSE(details.target_destroyed); 320 EXPECT_FALSE(details.target_destroyed);
336 EXPECT_FALSE(details.dispatcher_destroyed); 321 EXPECT_FALSE(details.dispatcher_destroyed);
337 EXPECT_EQ(0, controller.show_context_menu_calls()); 322 EXPECT_EQ(0, controller.show_context_menu_calls());
338 controller.Reset(); 323 controller.Reset();
339 324
340 // |parent_view| should not show a context menu as a result of a long press on 325 // |parent_view| should not show a context menu as a result of a long press on
341 // itself. 326 // itself.
342 ui::GestureEvent long_press3( 327 ui::GestureEvent long_press3(
343 50, 328 50,
344 50, 329 50,
345 0, 330 0,
346 base::TimeDelta(), 331 base::TimeDelta(),
347 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0)); 332 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
348 details = root_view->OnEventFromSource(&long_press3); 333 details = root_view->OnEventFromSource(&long_press3);
349 334
350 ui::GestureEvent end3(25, 335 ui::GestureEvent end3(
351 5, 336 25, 5, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_END));
352 0,
353 base::TimeDelta(),
354 ui::GestureEventDetails(ui::ET_GESTURE_END, 0, 0));
355 details = root_view->OnEventFromSource(&end3); 337 details = root_view->OnEventFromSource(&end3);
356 338
357 EXPECT_FALSE(details.target_destroyed); 339 EXPECT_FALSE(details.target_destroyed);
358 EXPECT_FALSE(details.dispatcher_destroyed); 340 EXPECT_FALSE(details.dispatcher_destroyed);
359 EXPECT_EQ(0, controller.show_context_menu_calls()); 341 EXPECT_EQ(0, controller.show_context_menu_calls());
360 } 342 }
361 343
362 } // namespace test 344 } // namespace test
363 } // namespace views 345 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view_targeter_unittest.cc ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698