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

Side by Side Diff: content/browser/renderer_host/input/touch_emulator_unittest.cc

Issue 474213002: DevTools: control touch emulation from the browser side only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment addressed. Created 6 years, 4 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // testing::Test 47 // testing::Test
48 virtual void SetUp() OVERRIDE { 48 virtual void SetUp() OVERRIDE {
49 #if defined(USE_AURA) 49 #if defined(USE_AURA)
50 aura::Env::CreateInstance(true); 50 aura::Env::CreateInstance(true);
51 screen_.reset(aura::TestScreen::Create(gfx::Size())); 51 screen_.reset(aura::TestScreen::Create(gfx::Size()));
52 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); 52 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
53 #endif 53 #endif
54 54
55 emulator_.reset(new TouchEmulator(this)); 55 emulator_.reset(new TouchEmulator(this));
56 emulator_->Enable(true /* allow_pinch */); 56 emulator_->Enable();
57 } 57 }
58 58
59 virtual void TearDown() OVERRIDE { 59 virtual void TearDown() OVERRIDE {
60 emulator_->Disable(); 60 emulator_->Disable();
61 EXPECT_EQ("", ExpectedEvents()); 61 EXPECT_EQ("", ExpectedEvents());
62 62
63 #if defined(USE_AURA) 63 #if defined(USE_AURA)
64 aura::Env::DeleteInstance(); 64 aura::Env::DeleteInstance();
65 screen_.reset(); 65 screen_.reset();
66 #endif 66 #endif
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 EXPECT_EQ("TouchMove GesturePinchBegin", ExpectedEvents()); 339 EXPECT_EQ("TouchMove GesturePinchBegin", ExpectedEvents());
340 340
341 // Disable while pinch is in progress. 341 // Disable while pinch is in progress.
342 emulator()->Disable(); 342 emulator()->Disable();
343 EXPECT_EQ("TouchCancel GesturePinchEnd GestureScrollEnd", ExpectedEvents()); 343 EXPECT_EQ("TouchCancel GesturePinchEnd GestureScrollEnd", ExpectedEvents());
344 MouseUp(300, 200); 344 MouseUp(300, 200);
345 ReleaseShift(); 345 ReleaseShift();
346 MouseMove(300, 300); 346 MouseMove(300, 300);
347 EXPECT_EQ("", ExpectedEvents()); 347 EXPECT_EQ("", ExpectedEvents());
348 348
349 emulator()->Enable(true /* allow_pinch */); 349 emulator()->Enable();
350 MouseDown(300, 300); 350 MouseDown(300, 300);
351 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents()); 351 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents());
352 MouseDrag(300, 400); 352 MouseDrag(300, 400);
353 EXPECT_EQ( 353 EXPECT_EQ(
354 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate", 354 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate",
355 ExpectedEvents()); 355 ExpectedEvents());
356 356
357 // Disable while scroll is in progress. 357 // Disable while scroll is in progress.
358 emulator()->Disable(); 358 emulator()->Disable();
359 EXPECT_EQ("TouchCancel GestureScrollEnd", ExpectedEvents()); 359 EXPECT_EQ("TouchCancel GestureScrollEnd", ExpectedEvents());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 EXPECT_FALSE(SendMouseWheelEvent()); 399 EXPECT_FALSE(SendMouseWheelEvent());
400 MouseUp(100, 200); 400 MouseUp(100, 200);
401 EXPECT_EQ("TouchEnd GestureShowPress GestureTap", ExpectedEvents()); 401 EXPECT_EQ("TouchEnd GestureShowPress GestureTap", ExpectedEvents());
402 EXPECT_TRUE(SendMouseWheelEvent()); 402 EXPECT_TRUE(SendMouseWheelEvent());
403 MouseDown(300, 200); 403 MouseDown(300, 200);
404 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents()); 404 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents());
405 EXPECT_FALSE(SendMouseWheelEvent()); 405 EXPECT_FALSE(SendMouseWheelEvent());
406 emulator()->Disable(); 406 emulator()->Disable();
407 EXPECT_EQ("TouchCancel GestureTapCancel", ExpectedEvents()); 407 EXPECT_EQ("TouchCancel GestureTapCancel", ExpectedEvents());
408 EXPECT_TRUE(SendMouseWheelEvent()); 408 EXPECT_TRUE(SendMouseWheelEvent());
409 emulator()->Enable(true /* allow_pinch */); 409 emulator()->Enable();
410 EXPECT_TRUE(SendMouseWheelEvent()); 410 EXPECT_TRUE(SendMouseWheelEvent());
411 } 411 }
412 412
413 TEST_F(TouchEmulatorTest, MultipleTouchStreams) { 413 TEST_F(TouchEmulatorTest, MultipleTouchStreams) {
414 // Native stream should be blocked while emulated is active. 414 // Native stream should be blocked while emulated is active.
415 MouseMove(100, 200); 415 MouseMove(100, 200);
416 EXPECT_EQ("", ExpectedEvents()); 416 EXPECT_EQ("", ExpectedEvents());
417 MouseDown(100, 200); 417 MouseDown(100, 200);
418 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents()); 418 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents());
419 EXPECT_FALSE(TouchStart(10, 10, true)); 419 EXPECT_FALSE(TouchStart(10, 10, true));
420 EXPECT_FALSE(TouchMove(20, 20, true)); 420 EXPECT_FALSE(TouchMove(20, 20, true));
421 MouseUp(200, 200); 421 MouseUp(200, 200);
422 EXPECT_EQ( 422 EXPECT_EQ(
423 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate" 423 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate"
424 " TouchEnd GestureScrollEnd", 424 " TouchEnd GestureScrollEnd",
425 ExpectedEvents()); 425 ExpectedEvents());
426 EXPECT_FALSE(TouchEnd(20, 20, true)); 426 EXPECT_FALSE(TouchEnd(20, 20, true));
427 427
428 // Emulated stream should be blocked while native is active. 428 // Emulated stream should be blocked while native is active.
429 EXPECT_TRUE(TouchStart(10, 10, true)); 429 EXPECT_TRUE(TouchStart(10, 10, true));
430 EXPECT_TRUE(TouchMove(20, 20, true)); 430 EXPECT_TRUE(TouchMove(20, 20, true));
431 MouseDown(300, 200); 431 MouseDown(300, 200);
432 EXPECT_EQ("", ExpectedEvents()); 432 EXPECT_EQ("", ExpectedEvents());
433 // Re-enabling in the middle of a touch sequence should not affect this. 433 // Re-enabling in the middle of a touch sequence should not affect this.
434 emulator()->Disable(); 434 emulator()->Disable();
435 emulator()->Enable(true); 435 emulator()->Enable();
436 MouseDrag(300, 300); 436 MouseDrag(300, 300);
437 EXPECT_EQ("", ExpectedEvents()); 437 EXPECT_EQ("", ExpectedEvents());
438 MouseUp(300, 300); 438 MouseUp(300, 300);
439 EXPECT_EQ("", ExpectedEvents()); 439 EXPECT_EQ("", ExpectedEvents());
440 EXPECT_TRUE(TouchEnd(20, 20, true)); 440 EXPECT_TRUE(TouchEnd(20, 20, true));
441 EXPECT_EQ("", ExpectedEvents()); 441 EXPECT_EQ("", ExpectedEvents());
442 442
443 // Late ack for TouchEnd should not mess things up. 443 // Late ack for TouchEnd should not mess things up.
444 EXPECT_TRUE(TouchStart(10, 10, false)); 444 EXPECT_TRUE(TouchStart(10, 10, false));
445 EXPECT_TRUE(TouchMove(20, 20, false)); 445 EXPECT_TRUE(TouchMove(20, 20, false));
446 emulator()->Disable(); 446 emulator()->Disable();
447 EXPECT_TRUE(TouchEnd(20, 20, false)); 447 EXPECT_TRUE(TouchEnd(20, 20, false));
448 EXPECT_TRUE(TouchStart(30, 30, false)); 448 EXPECT_TRUE(TouchStart(30, 30, false));
449 AckOldestTouchEvent(); // TouchStart. 449 AckOldestTouchEvent(); // TouchStart.
450 emulator()->Enable(true); 450 emulator()->Enable();
451 AckOldestTouchEvent(); // TouchMove. 451 AckOldestTouchEvent(); // TouchMove.
452 AckOldestTouchEvent(); // TouchEnd. 452 AckOldestTouchEvent(); // TouchEnd.
453 MouseDown(300, 200); 453 MouseDown(300, 200);
454 EXPECT_EQ("", ExpectedEvents()); 454 EXPECT_EQ("", ExpectedEvents());
455 MouseDrag(300, 300); 455 MouseDrag(300, 300);
456 EXPECT_EQ("", ExpectedEvents()); 456 EXPECT_EQ("", ExpectedEvents());
457 MouseUp(300, 300); 457 MouseUp(300, 300);
458 EXPECT_EQ("", ExpectedEvents()); 458 EXPECT_EQ("", ExpectedEvents());
459 AckOldestTouchEvent(); // TouchStart. 459 AckOldestTouchEvent(); // TouchStart.
460 MouseDown(300, 200); 460 MouseDown(300, 200);
(...skipping 25 matching lines...) Expand all
486 MouseDown(100, 200); 486 MouseDown(100, 200);
487 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents()); 487 EXPECT_EQ("TouchStart GestureTapDown", ExpectedEvents());
488 MouseUp(200, 200); 488 MouseUp(200, 200);
489 EXPECT_EQ( 489 EXPECT_EQ(
490 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate" 490 "TouchMove GestureTapCancel GestureScrollBegin GestureScrollUpdate"
491 " TouchEnd GestureScrollEnd", 491 " TouchEnd GestureScrollEnd",
492 ExpectedEvents()); 492 ExpectedEvents());
493 } 493 }
494 494
495 } // namespace content 495 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_emulator.cc ('k') | content/browser/renderer_host/render_widget_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698