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

Side by Side Diff: mash/wm/accelerator_registrar_apptest.cc

Issue 1614553002: Reduce boilerplate needed to configure mojo::Binding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 <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 11 matching lines...) Expand all
22 22
23 namespace mash { 23 namespace mash {
24 namespace wm { 24 namespace wm {
25 25
26 class TestAcceleratorHandler : public AcceleratorHandler { 26 class TestAcceleratorHandler : public AcceleratorHandler {
27 public: 27 public:
28 explicit TestAcceleratorHandler(AcceleratorRegistrarPtr registrar) 28 explicit TestAcceleratorHandler(AcceleratorRegistrarPtr registrar)
29 : binding_(this), 29 : binding_(this),
30 registrar_(std::move(registrar)), 30 registrar_(std::move(registrar)),
31 add_accelerator_result_(false) { 31 add_accelerator_result_(false) {
32 AcceleratorHandlerPtr handler; 32 registrar_->SetHandler(binding_.CreateInterfacePtrAndBind());
33 binding_.Bind(GetProxy(&handler));
34 registrar_->SetHandler(std::move(handler));
35 } 33 }
36 ~TestAcceleratorHandler() override {} 34 ~TestAcceleratorHandler() override {}
37 35
38 // Attempts to install an accelerator with the specified id and event matcher. 36 // Attempts to install an accelerator with the specified id and event matcher.
39 // Returns whether the accelerator could be successfully added or not. 37 // Returns whether the accelerator could be successfully added or not.
40 bool AttemptToInstallAccelerator(uint32_t accelerator_id, 38 bool AttemptToInstallAccelerator(uint32_t accelerator_id,
41 mus::mojom::EventMatcherPtr matcher) { 39 mus::mojom::EventMatcherPtr matcher) {
42 DCHECK(!run_loop_); 40 DCHECK(!run_loop_);
43 registrar_->AddAccelerator( 41 registrar_->AddAccelerator(
44 accelerator_id, std::move(matcher), 42 accelerator_id, std::move(matcher),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( 107 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator(
110 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, 108 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N,
111 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); 109 mus::mojom::EVENT_FLAGS_SHIFT_DOWN)));
112 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( 110 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator(
113 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, 111 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N,
114 mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); 112 mus::mojom::EVENT_FLAGS_SHIFT_DOWN)));
115 } 113 }
116 114
117 } // namespace wm 115 } // namespace wm
118 } // namespace mash 116 } // namespace mash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698