| 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 <memory> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 10 #include "components/mus/public/cpp/event_matcher.h" | 12 #include "components/mus/public/cpp/event_matcher.h" |
| 11 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
| 12 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" | 14 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "mojo/shell/public/cpp/shell_test.h" | 16 #include "mojo/shell/public/cpp/shell_test.h" |
| 15 | 17 |
| 16 using mus::mojom::AcceleratorHandler; | 18 using mus::mojom::AcceleratorHandler; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void AddAcceleratorCallback(bool success) { | 52 void AddAcceleratorCallback(bool success) { |
| 51 DCHECK(run_loop_ && run_loop_->running()); | 53 DCHECK(run_loop_ && run_loop_->running()); |
| 52 add_accelerator_result_ = success; | 54 add_accelerator_result_ = success; |
| 53 run_loop_->Quit(); | 55 run_loop_->Quit(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 // AcceleratorHandler: | 58 // AcceleratorHandler: |
| 57 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override {} | 59 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override {} |
| 58 | 60 |
| 59 std::set<uint32_t> installed_accelerators_; | 61 std::set<uint32_t> installed_accelerators_; |
| 60 scoped_ptr<base::RunLoop> run_loop_; | 62 std::unique_ptr<base::RunLoop> run_loop_; |
| 61 mojo::Binding<AcceleratorHandler> binding_; | 63 mojo::Binding<AcceleratorHandler> binding_; |
| 62 AcceleratorRegistrarPtr registrar_; | 64 AcceleratorRegistrarPtr registrar_; |
| 63 bool add_accelerator_result_; | 65 bool add_accelerator_result_; |
| 64 | 66 |
| 65 DISALLOW_COPY_AND_ASSIGN(TestAcceleratorHandler); | 67 DISALLOW_COPY_AND_ASSIGN(TestAcceleratorHandler); |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 class AcceleratorRegistrarTest : public mojo::test::ShellTest { | 70 class AcceleratorRegistrarTest : public mojo::test::ShellTest { |
| 69 public: | 71 public: |
| 70 AcceleratorRegistrarTest() : mojo::test::ShellTest("exe:mash_unittests") {} | 72 AcceleratorRegistrarTest() : mojo::test::ShellTest("exe:mash_unittests") {} |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( | 107 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( |
| 106 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, | 108 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 107 mus::mojom::kEventFlagShiftDown))); | 109 mus::mojom::kEventFlagShiftDown))); |
| 108 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( | 110 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( |
| 109 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, | 111 3, mus::CreateKeyMatcher(mus::mojom::KeyboardCode::N, |
| 110 mus::mojom::kEventFlagShiftDown))); | 112 mus::mojom::kEventFlagShiftDown))); |
| 111 } | 113 } |
| 112 | 114 |
| 113 } // namespace wm | 115 } // namespace wm |
| 114 } // namespace mash | 116 } // namespace mash |
| OLD | NEW |