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

Side by Side Diff: ash/mus/accelerators/accelerator_registrar_unittest.cc

Issue 2182633011: Replaces ::ui:: with ui:: in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « ash/mus/accelerators/accelerator_registrar_impl.cc ('k') | ash/mus/app_launch_unittest.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 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> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "services/shell/public/cpp/service_test.h" 13 #include "services/shell/public/cpp/service_test.h"
14 #include "services/ui/common/event_matcher_util.h" 14 #include "services/ui/common/event_matcher_util.h"
15 #include "services/ui/public/cpp/window.h" 15 #include "services/ui/public/cpp/window.h"
16 #include "services/ui/public/interfaces/accelerator_registrar.mojom.h" 16 #include "services/ui/public/interfaces/accelerator_registrar.mojom.h"
17 17
18 using ::ui::mojom::AcceleratorHandler; 18 using ui::mojom::AcceleratorHandler;
19 using ::ui::mojom::AcceleratorHandlerPtr; 19 using ui::mojom::AcceleratorHandlerPtr;
20 using ::ui::mojom::AcceleratorRegistrar; 20 using ui::mojom::AcceleratorRegistrar;
21 using ::ui::mojom::AcceleratorRegistrarPtr; 21 using ui::mojom::AcceleratorRegistrarPtr;
22 22
23 namespace ash { 23 namespace ash {
24 namespace mus { 24 namespace mus {
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 registrar_->SetHandler(binding_.CreateInterfacePtrAndBind()); 32 registrar_->SetHandler(binding_.CreateInterfacePtrAndBind());
33 } 33 }
34 ~TestAcceleratorHandler() override {} 34 ~TestAcceleratorHandler() override {}
35 35
36 // 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.
37 // Returns whether the accelerator could be successfully added or not. 37 // Returns whether the accelerator could be successfully added or not.
38 bool AttemptToInstallAccelerator(uint32_t accelerator_id, 38 bool AttemptToInstallAccelerator(uint32_t accelerator_id,
39 ::ui::mojom::EventMatcherPtr matcher) { 39 ui::mojom::EventMatcherPtr matcher) {
40 DCHECK(!run_loop_); 40 DCHECK(!run_loop_);
41 registrar_->AddAccelerator( 41 registrar_->AddAccelerator(
42 accelerator_id, std::move(matcher), 42 accelerator_id, std::move(matcher),
43 base::Bind(&TestAcceleratorHandler::AddAcceleratorCallback, 43 base::Bind(&TestAcceleratorHandler::AddAcceleratorCallback,
44 base::Unretained(this))); 44 base::Unretained(this)));
45 run_loop_.reset(new base::RunLoop); 45 run_loop_.reset(new base::RunLoop);
46 run_loop_->Run(); 46 run_loop_->Run();
47 run_loop_.reset(); 47 run_loop_.reset();
48 return add_accelerator_result_; 48 return add_accelerator_result_;
49 } 49 }
(...skipping 29 matching lines...) Expand all
79 79
80 private: 80 private:
81 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarTest); 81 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarTest);
82 }; 82 };
83 83
84 TEST_F(AcceleratorRegistrarTest, AcceleratorRegistrarBasic) { 84 TEST_F(AcceleratorRegistrarTest, AcceleratorRegistrarBasic) {
85 AcceleratorRegistrarPtr registrar_first; 85 AcceleratorRegistrarPtr registrar_first;
86 ConnectToRegistrar(&registrar_first); 86 ConnectToRegistrar(&registrar_first);
87 TestAcceleratorHandler handler_first(std::move(registrar_first)); 87 TestAcceleratorHandler handler_first(std::move(registrar_first));
88 EXPECT_TRUE(handler_first.AttemptToInstallAccelerator( 88 EXPECT_TRUE(handler_first.AttemptToInstallAccelerator(
89 1, ::ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T, 89 1, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T,
90 ui::mojom::kEventFlagShiftDown))); 90 ui::mojom::kEventFlagShiftDown)));
91 // Attempting to add an accelerator with the same accelerator id from the same 91 // Attempting to add an accelerator with the same accelerator id from the same
92 // registrar should fail. 92 // registrar should fail.
93 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( 93 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator(
94 1, ::ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, 94 1, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
95 ui::mojom::kEventFlagShiftDown))); 95 ui::mojom::kEventFlagShiftDown)));
96 96
97 // Attempting to add an accelerator with the same id from a different 97 // Attempting to add an accelerator with the same id from a different
98 // registrar should be OK. 98 // registrar should be OK.
99 AcceleratorRegistrarPtr registrar_second; 99 AcceleratorRegistrarPtr registrar_second;
100 ConnectToRegistrar(&registrar_second); 100 ConnectToRegistrar(&registrar_second);
101 TestAcceleratorHandler handler_second(std::move(registrar_second)); 101 TestAcceleratorHandler handler_second(std::move(registrar_second));
102 EXPECT_TRUE(handler_second.AttemptToInstallAccelerator( 102 EXPECT_TRUE(handler_second.AttemptToInstallAccelerator(
103 1, ::ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, 103 1, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
104 ui::mojom::kEventFlagShiftDown))); 104 ui::mojom::kEventFlagShiftDown)));
105 105
106 // But attempting to add an accelerator with the same matcher should fail. 106 // But attempting to add an accelerator with the same matcher should fail.
107 // Temporarily commented out until we sort out http://crbug.com/631836. 107 // Temporarily commented out until we sort out http://crbug.com/631836.
108 /* 108 /*
109 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( 109 EXPECT_FALSE(handler_first.AttemptToInstallAccelerator(
110 3, ::ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, 110 3, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
111 ui::mojom::kEventFlagShiftDown))); 111 ui::mojom::kEventFlagShiftDown)));
112 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( 112 EXPECT_FALSE(handler_second.AttemptToInstallAccelerator(
113 3, ::ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N, 113 3, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
114 ui::mojom::kEventFlagShiftDown))); 114 ui::mojom::kEventFlagShiftDown)));
115 */ 115 */
116 } 116 }
117 117
118 } // namespace mus 118 } // namespace mus
119 } // namespace ash 119 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/accelerators/accelerator_registrar_impl.cc ('k') | ash/mus/app_launch_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698