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

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

Issue 2057793002: Reorganize event mojom files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typos in comments. Created 4 years, 6 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 | « components/mus/ws/event_matcher.cc ('k') | components/mus/ws/window_manager_state.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_matcher.h" 5 #include "components/mus/ws/event_matcher.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "components/mus/public/interfaces/event_matcher.mojom.h" 8 #include "components/mus/public/interfaces/event_matcher.mojom.h"
9 #include "components/mus/public/interfaces/input_key_codes.mojom.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/events/event.h" 10 #include "ui/events/event.h"
11 #include "ui/events/mojo/event_constants.mojom.h"
12 #include "ui/gfx/geometry/point.h" 12 #include "ui/gfx/geometry/point.h"
13 13
14 namespace mus { 14 namespace mus {
15 namespace ws { 15 namespace ws {
16 16
17 // NOTE: Most of the matching functionality is exercised by tests of Accelerator 17 // NOTE: Most of the matching functionality is exercised by tests of Accelerator
18 // handling in the EventDispatcher and WindowTree tests. These are just basic 18 // handling in the EventDispatcher and WindowTree tests. These are just basic
19 // sanity checks. 19 // sanity checks.
20 20
21 using EventTesterTest = testing::Test; 21 using EventTesterTest = testing::Test;
22 22
23 TEST_F(EventTesterTest, MatchesEventByType) { 23 TEST_F(EventTesterTest, MatchesEventByType) {
24 mojom::EventMatcherPtr matcher = mojom::EventMatcher::New(); 24 mojom::EventMatcherPtr matcher = mojom::EventMatcher::New();
25 matcher->type_matcher = mojom::EventTypeMatcher::New(); 25 matcher->type_matcher = mojom::EventTypeMatcher::New();
26 matcher->type_matcher->type = mojom::EventType::POINTER_DOWN; 26 matcher->type_matcher->type = ui::mojom::EventType::POINTER_DOWN;
27 EventMatcher pointer_down_matcher(*matcher); 27 EventMatcher pointer_down_matcher(*matcher);
28 28
29 ui::PointerEvent pointer_down( 29 ui::PointerEvent pointer_down(
30 ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), 1, base::TimeTicks())); 30 ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), 1, base::TimeTicks()));
31 EXPECT_TRUE(pointer_down_matcher.MatchesEvent(pointer_down)); 31 EXPECT_TRUE(pointer_down_matcher.MatchesEvent(pointer_down));
32 32
33 ui::PointerEvent pointer_up(ui::TouchEvent( 33 ui::PointerEvent pointer_up(ui::TouchEvent(
34 ui::ET_TOUCH_RELEASED, gfx::Point(), 1, base::TimeTicks())); 34 ui::ET_TOUCH_RELEASED, gfx::Point(), 1, base::TimeTicks()));
35 EXPECT_FALSE(pointer_down_matcher.MatchesEvent(pointer_up)); 35 EXPECT_FALSE(pointer_down_matcher.MatchesEvent(pointer_up));
36 } 36 }
37 37
38 TEST_F(EventTesterTest, MatchesEventByKeyCode) { 38 TEST_F(EventTesterTest, MatchesEventByKeyCode) {
39 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New()); 39 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New());
40 matcher->type_matcher = mojom::EventTypeMatcher::New(); 40 matcher->type_matcher = mojom::EventTypeMatcher::New();
41 matcher->type_matcher->type = mojom::EventType::KEY_PRESSED; 41 matcher->type_matcher->type = ui::mojom::EventType::KEY_PRESSED;
42 matcher->key_matcher = mojom::KeyEventMatcher::New(); 42 matcher->key_matcher = mojom::KeyEventMatcher::New();
43 matcher->key_matcher->keyboard_code = mojom::KeyboardCode::Z; 43 matcher->key_matcher->keyboard_code = ui::mojom::KeyboardCode::Z;
44 EventMatcher z_matcher(*matcher); 44 EventMatcher z_matcher(*matcher);
45 45
46 ui::KeyEvent z_key(ui::ET_KEY_PRESSED, ui::VKEY_Z, ui::EF_NONE); 46 ui::KeyEvent z_key(ui::ET_KEY_PRESSED, ui::VKEY_Z, ui::EF_NONE);
47 EXPECT_TRUE(z_matcher.MatchesEvent(z_key)); 47 EXPECT_TRUE(z_matcher.MatchesEvent(z_key));
48 48
49 ui::KeyEvent y_key(ui::ET_KEY_PRESSED, ui::VKEY_Y, ui::EF_NONE); 49 ui::KeyEvent y_key(ui::ET_KEY_PRESSED, ui::VKEY_Y, ui::EF_NONE);
50 EXPECT_FALSE(z_matcher.MatchesEvent(y_key)); 50 EXPECT_FALSE(z_matcher.MatchesEvent(y_key));
51 } 51 }
52 52
53 TEST_F(EventTesterTest, MatchesEventByKeyFlags) { 53 TEST_F(EventTesterTest, MatchesEventByKeyFlags) {
54 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New()); 54 mojom::EventMatcherPtr matcher(mojom::EventMatcher::New());
55 matcher->type_matcher = mojom::EventTypeMatcher::New(); 55 matcher->type_matcher = mojom::EventTypeMatcher::New();
56 matcher->type_matcher->type = mojom::EventType::KEY_PRESSED; 56 matcher->type_matcher->type = ui::mojom::EventType::KEY_PRESSED;
57 matcher->flags_matcher = mojom::EventFlagsMatcher::New(); 57 matcher->flags_matcher = mojom::EventFlagsMatcher::New();
58 matcher->flags_matcher->flags = mojom::kEventFlagControlDown; 58 matcher->flags_matcher->flags = ui::mojom::kEventFlagControlDown;
59 matcher->key_matcher = mojom::KeyEventMatcher::New(); 59 matcher->key_matcher = mojom::KeyEventMatcher::New();
60 matcher->key_matcher->keyboard_code = mojom::KeyboardCode::N; 60 matcher->key_matcher->keyboard_code = ui::mojom::KeyboardCode::N;
61 EventMatcher control_n_matcher(*matcher); 61 EventMatcher control_n_matcher(*matcher);
62 62
63 ui::KeyEvent control_n(ui::ET_KEY_PRESSED, ui::VKEY_N, ui::EF_CONTROL_DOWN); 63 ui::KeyEvent control_n(ui::ET_KEY_PRESSED, ui::VKEY_N, ui::EF_CONTROL_DOWN);
64 EXPECT_TRUE(control_n_matcher.MatchesEvent(control_n)); 64 EXPECT_TRUE(control_n_matcher.MatchesEvent(control_n));
65 65
66 ui::KeyEvent shift_n(ui::ET_KEY_PRESSED, ui::VKEY_N, ui::EF_SHIFT_DOWN); 66 ui::KeyEvent shift_n(ui::ET_KEY_PRESSED, ui::VKEY_N, ui::EF_SHIFT_DOWN);
67 EXPECT_FALSE(control_n_matcher.MatchesEvent(shift_n)); 67 EXPECT_FALSE(control_n_matcher.MatchesEvent(shift_n));
68 } 68 }
69 69
70 } // namespace ws 70 } // namespace ws
71 } // namespace mus 71 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/event_matcher.cc ('k') | components/mus/ws/window_manager_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698