| OLD | NEW |
| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "components/mus/public/cpp/event_matcher.h" | 10 #include "components/mus/public/cpp/event_matcher.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarTest); | 83 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarTest); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 TEST_F(AcceleratorRegistrarTest, AcceleratorRegistrarBasic) { | 86 TEST_F(AcceleratorRegistrarTest, AcceleratorRegistrarBasic) { |
| 87 AcceleratorRegistrarPtr registrar_first; | 87 AcceleratorRegistrarPtr registrar_first; |
| 88 ConnectToRegistrar(®istrar_first); | 88 ConnectToRegistrar(®istrar_first); |
| 89 TestAcceleratorHandler handler_first(std::move(registrar_first)); | 89 TestAcceleratorHandler handler_first(std::move(registrar_first)); |
| 90 EXPECT_TRUE(handler_first.AttemptToInstallAccelerator( | 90 EXPECT_TRUE(handler_first.AttemptToInstallAccelerator( |
| 91 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, | 91 1, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::T, |
| 92 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); | 92 mus::mojom::kEventFlagShiftDown))); |
| 93 // Attempting to add an accelerator with the same accelerator id from the same | 93 // Attempting to add an accelerator with the same accelerator id from the same |
| 94 // registrar should fail. | 94 // registrar should fail. |
| 95 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( | 95 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( |
| 96 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, | 96 1, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 97 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); | 97 mus::mojom::kEventFlagShiftDown))); |
| 98 | 98 |
| 99 // Attempting to add an accelerator with the same id from a different | 99 // Attempting to add an accelerator with the same id from a different |
| 100 // registrar should be OK. | 100 // registrar should be OK. |
| 101 AcceleratorRegistrarPtr registrar_second; | 101 AcceleratorRegistrarPtr registrar_second; |
| 102 ConnectToRegistrar(®istrar_second); | 102 ConnectToRegistrar(®istrar_second); |
| 103 TestAcceleratorHandler handler_second(std::move(registrar_second)); | 103 TestAcceleratorHandler handler_second(std::move(registrar_second)); |
| 104 EXPECT_TRUE(handler_second.AttemptToInstallAccelerator( | 104 EXPECT_TRUE(handler_second.AttemptToInstallAccelerator( |
| 105 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, | 105 1, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 106 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); | 106 mus::mojom::kEventFlagShiftDown))); |
| 107 | 107 |
| 108 // But attempting to add an accelerator with the same matcher should fail. | 108 // But attempting to add an accelerator with the same matcher should fail. |
| 109 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( | 109 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( |
| 110 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, | 110 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 111 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); | 111 mus::mojom::kEventFlagShiftDown))); |
| 112 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( | 112 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( |
| 113 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, | 113 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 114 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); | 114 mus::mojom::kEventFlagShiftDown))); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace wm | 117 } // namespace wm |
| 118 } // namespace mash | 118 } // namespace mash |
| OLD | NEW |