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

Side by Side Diff: components/mus/ws/event_dispatcher_unittest.cc

Issue 1759273002: Add AcceleratorType to EventMatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/mus/ws/event_dispatcher.h" 5 #include "components/mus/ws/event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 dispatcher->AddAccelerator(accelerator_2, std::move(matcher)); 348 dispatcher->AddAccelerator(accelerator_2, std::move(matcher));
349 dispatcher->ProcessEvent(key); 349 dispatcher->ProcessEvent(key);
350 EXPECT_EQ(accelerator_2, 350 EXPECT_EQ(accelerator_2,
351 event_dispatcher_delegate->GetAndClearLastAccelerator()); 351 event_dispatcher_delegate->GetAndClearLastAccelerator());
352 352
353 dispatcher->RemoveAccelerator(accelerator_2); 353 dispatcher->RemoveAccelerator(accelerator_2);
354 dispatcher->ProcessEvent(key); 354 dispatcher->ProcessEvent(key);
355 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator()); 355 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator());
356 } 356 }
357 357
358 // Tests that a post-target accelerator is not triggered by ProcessEvent.
359 TEST_F(EventDispatcherTest, PostTargetAccelerator) {
360 TestEventDispatcherDelegate* event_dispatcher_delegate =
361 test_event_dispatcher_delegate();
362 EventDispatcher* dispatcher = event_dispatcher();
363
364 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher(
365 mus::mojom::KeyboardCode::W, mus::mojom::kEventFlagControlDown);
366 matcher->accelerator_matcher->accelerator_phase =
367 mojom::AcceleratorPhase::POST_TARGET;
368 uint32_t accelerator_1 = 1;
369 dispatcher->AddAccelerator(accelerator_1, std::move(matcher));
370
371 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
372 dispatcher->ProcessEvent(key);
373 EXPECT_EQ(0u, event_dispatcher_delegate->GetAndClearLastAccelerator());
374
375 // TODO(jonross): Update this test to include actual invokation of PostTarget
376 // acceleratos once events acking includes consuming.
377 }
378
358 TEST_F(EventDispatcherTest, Capture) { 379 TEST_F(EventDispatcherTest, Capture) {
359 ServerWindow* root = root_window(); 380 ServerWindow* root = root_window();
360 scoped_ptr<ServerWindow> child(CreateChildWindow(WindowId(1, 3))); 381 scoped_ptr<ServerWindow> child(CreateChildWindow(WindowId(1, 3)));
361 382
362 root->SetBounds(gfx::Rect(0, 0, 100, 100)); 383 root->SetBounds(gfx::Rect(0, 0, 100, 100));
363 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 384 child->SetBounds(gfx::Rect(10, 10, 20, 20));
364 385
365 MouseEventTest tests[] = { 386 MouseEventTest tests[] = {
366 // Send a mouse down event over child. 387 // Send a mouse down event over child.
367 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), 388 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25),
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1084
1064 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); 1085 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent();
1065 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); 1086 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location());
1066 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); 1087 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location());
1067 EXPECT_EQ(touch_id, dispatched_event->pointer_id()); 1088 EXPECT_EQ(touch_id, dispatched_event->pointer_id());
1068 } 1089 }
1069 } 1090 }
1070 1091
1071 } // namespace ws 1092 } // namespace ws
1072 } // namespace mus 1093 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698