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

Side by Side Diff: ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc

Issue 1017473002: [Merge] Make mouse buttons 8 - 11 navigate forward and back in history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 9 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 event = dispatched_mouse_event(0); 392 event = dispatched_mouse_event(0);
393 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type()); 393 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
394 EXPECT_EQ(true, event->IsLeftMouseButton()); 394 EXPECT_EQ(true, event->IsLeftMouseButton());
395 395
396 event = dispatched_mouse_event(1); 396 event = dispatched_mouse_event(1);
397 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type()); 397 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
398 EXPECT_EQ(true, event->IsLeftMouseButton()); 398 EXPECT_EQ(true, event->IsLeftMouseButton());
399 } 399 }
400 400
401 // Test that BTN_BACK and BTN_SIDE are treated as the same button.
402 TEST_F(EventConverterEvdevImplTest, MouseBackButton) {
403 ui::MockEventConverterEvdevImpl* dev = device();
404
405 struct input_event mock_kernel_queue[] = {
406 {{0, 0}, EV_KEY, BTN_SIDE, 1},
407 {{0, 0}, EV_SYN, SYN_REPORT, 0},
408
409 {{0, 0}, EV_KEY, BTN_BACK, 1},
410 {{0, 0}, EV_SYN, SYN_REPORT, 0},
411
412 {{0, 0}, EV_KEY, BTN_SIDE, 0},
413 {{0, 0}, EV_SYN, SYN_REPORT, 0},
414
415 {{0, 0}, EV_KEY, BTN_BACK, 0},
416 {{0, 0}, EV_SYN, SYN_REPORT, 0}
417 };
418
419 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
420 EXPECT_EQ(2u, size());
421
422 ui::MouseEvent* event = nullptr;
423
424 event = dispatched_mouse_event(0);
425 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
426 EXPECT_EQ(ui::EF_BACK_MOUSE_BUTTON, event->changed_button_flags());
427
428 event = dispatched_mouse_event(1);
429 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
430 EXPECT_EQ(ui::EF_BACK_MOUSE_BUTTON, event->changed_button_flags());
431 }
432
433 // Test that BTN_FORWARD and BTN_EXTRA are treated as the same button.
434 TEST_F(EventConverterEvdevImplTest, MouseForwardButton) {
435 ui::MockEventConverterEvdevImpl* dev = device();
436
437 struct input_event mock_kernel_queue[] = {
438 {{0, 0}, EV_KEY, BTN_FORWARD, 1},
439 {{0, 0}, EV_SYN, SYN_REPORT, 0},
440
441 {{0, 0}, EV_KEY, BTN_EXTRA, 1},
442 {{0, 0}, EV_SYN, SYN_REPORT, 0},
443
444 {{0, 0}, EV_KEY, BTN_EXTRA, 0},
445 {{0, 0}, EV_SYN, SYN_REPORT, 0},
446
447 {{0, 0}, EV_KEY, BTN_FORWARD, 0},
448 {{0, 0}, EV_SYN, SYN_REPORT, 0}
449 };
450
451 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
452 EXPECT_EQ(2u, size());
453
454 ui::MouseEvent* event = nullptr;
455
456 event = dispatched_mouse_event(0);
457 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
458 EXPECT_EQ(ui::EF_FORWARD_MOUSE_BUTTON, event->changed_button_flags());
459
460 event = dispatched_mouse_event(1);
461 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
462 EXPECT_EQ(ui::EF_FORWARD_MOUSE_BUTTON, event->changed_button_flags());
463 }
464
401 TEST_F(EventConverterEvdevImplTest, MouseMove) { 465 TEST_F(EventConverterEvdevImplTest, MouseMove) {
402 ui::MockEventConverterEvdevImpl* dev = device(); 466 ui::MockEventConverterEvdevImpl* dev = device();
403 467
404 struct input_event mock_kernel_queue[] = { 468 struct input_event mock_kernel_queue[] = {
405 {{0, 0}, EV_REL, REL_X, 4}, 469 {{0, 0}, EV_REL, REL_X, 4},
406 {{0, 0}, EV_REL, REL_Y, 2}, 470 {{0, 0}, EV_REL, REL_Y, 2},
407 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 471 {{0, 0}, EV_SYN, SYN_REPORT, 0},
408 }; 472 };
409 473
410 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 474 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 dev->SetAllowedKeys(allowed_keys.Pass()); 632 dev->SetAllowedKeys(allowed_keys.Pass());
569 ASSERT_EQ(1u, size()); 633 ASSERT_EQ(1u, size());
570 event = dispatched_event(0); 634 event = dispatched_event(0);
571 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type()); 635 EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
572 636
573 // The real key release should be dropped, whenever it comes. 637 // The real key release should be dropped, whenever it comes.
574 ClearDispatchedEvents(); 638 ClearDispatchedEvents();
575 dev->ProcessEvents(key_release, arraysize(key_release)); 639 dev->ProcessEvents(key_release, arraysize(key_release));
576 ASSERT_EQ(0u, size()); 640 ASSERT_EQ(0u, size());
577 } 641 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_converter_evdev_impl.cc ('k') | ui/events/ozone/evdev/event_factory_evdev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698