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

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

Issue 1559163002: Clean up event flags a bit: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 4 years, 11 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 "base/macros.h" 10 #include "base/macros.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher( 216 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher(
217 mus::mojom::KEYBOARD_CODE_W, mus::mojom::EVENT_FLAGS_CONTROL_DOWN); 217 mus::mojom::KEYBOARD_CODE_W, mus::mojom::EVENT_FLAGS_CONTROL_DOWN);
218 uint32_t accelerator_1 = 1; 218 uint32_t accelerator_1 = 1;
219 dispatcher.AddAccelerator(accelerator_1, std::move(matcher)); 219 dispatcher.AddAccelerator(accelerator_1, std::move(matcher));
220 220
221 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 221 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
222 dispatcher.OnEvent(mojom::Event::From(key)); 222 dispatcher.OnEvent(mojom::Event::From(key));
223 EXPECT_EQ(accelerator_1, 223 EXPECT_EQ(accelerator_1,
224 event_dispatcher_delegate.GetAndClearLastAccelerator()); 224 event_dispatcher_delegate.GetAndClearLastAccelerator());
225 225
226 // EF_NUM_LOCK_DOWN should be ignored since CreateKeyMatcher defaults to 226 // EF_NUM_LOCK_ON should be ignored since CreateKeyMatcher defaults to
227 // ignoring. 227 // ignoring.
228 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, 228 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W,
229 ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_DOWN); 229 ui::EF_CONTROL_DOWN | ui::EF_NUM_LOCK_ON);
230 dispatcher.OnEvent(mojom::Event::From(key)); 230 dispatcher.OnEvent(mojom::Event::From(key));
231 EXPECT_EQ(accelerator_1, 231 EXPECT_EQ(accelerator_1,
232 event_dispatcher_delegate.GetAndClearLastAccelerator()); 232 event_dispatcher_delegate.GetAndClearLastAccelerator());
233 233
234 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE); 234 key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_NONE);
235 dispatcher.OnEvent(mojom::Event::From(key)); 235 dispatcher.OnEvent(mojom::Event::From(key));
236 EXPECT_EQ(0u, event_dispatcher_delegate.GetAndClearLastAccelerator()); 236 EXPECT_EQ(0u, event_dispatcher_delegate.GetAndClearLastAccelerator());
237 237
238 uint32_t accelerator_2 = 2; 238 uint32_t accelerator_2 = 2;
239 matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_W, 239 matcher = mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_W,
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 dispatched_event_mojo.To<scoped_ptr<ui::Event>>()); 645 dispatched_event_mojo.To<scoped_ptr<ui::Event>>());
646 ASSERT_TRUE(dispatched_event.get()); 646 ASSERT_TRUE(dispatched_event.get());
647 ASSERT_TRUE(dispatched_event->IsMouseEvent()); 647 ASSERT_TRUE(dispatched_event->IsMouseEvent());
648 ui::MouseEvent* dispatched_mouse_event = 648 ui::MouseEvent* dispatched_mouse_event =
649 static_cast<ui::MouseEvent*>(dispatched_event.get()); 649 static_cast<ui::MouseEvent*>(dispatched_event.get());
650 EXPECT_EQ(gfx::Point(-2, -1), dispatched_mouse_event->location()); 650 EXPECT_EQ(gfx::Point(-2, -1), dispatched_mouse_event->location());
651 } 651 }
652 652
653 } // namespace ws 653 } // namespace ws
654 } // namespace mus 654 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698