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

Unified Diff: ash/mus/accelerators/accelerator_registrar_unittest.cc

Issue 2452783002: mash: remove AcceleratorRegistrar. (Closed)
Patch Set: Rebase to tot Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/mus/accelerators/accelerator_registrar_impl.cc ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/accelerators/accelerator_registrar_unittest.cc
diff --git a/ash/mus/accelerators/accelerator_registrar_unittest.cc b/ash/mus/accelerators/accelerator_registrar_unittest.cc
deleted file mode 100644
index 2f8d74e4a0392cdba5ca42ff9e0e627edadc1b10..0000000000000000000000000000000000000000
--- a/ash/mus/accelerators/accelerator_registrar_unittest.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <stdint.h>
-
-#include <memory>
-
-#include "base/bind.h"
-#include "base/macros.h"
-#include "base/run_loop.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "services/service_manager/public/cpp/service_test.h"
-#include "services/ui/common/event_matcher_util.h"
-#include "services/ui/public/cpp/window.h"
-#include "services/ui/public/interfaces/accelerator_registrar.mojom.h"
-
-using ui::mojom::AcceleratorHandler;
-using ui::mojom::AcceleratorHandlerPtr;
-using ui::mojom::AcceleratorRegistrar;
-using ui::mojom::AcceleratorRegistrarPtr;
-
-namespace ash {
-namespace mus {
-
-class TestAcceleratorHandler : public AcceleratorHandler {
- public:
- explicit TestAcceleratorHandler(AcceleratorRegistrarPtr registrar)
- : binding_(this),
- registrar_(std::move(registrar)),
- add_accelerator_result_(false) {
- registrar_->SetHandler(binding_.CreateInterfacePtrAndBind());
- }
- ~TestAcceleratorHandler() override {}
-
- // Attempts to install an accelerator with the specified id and event matcher.
- // Returns whether the accelerator could be successfully added or not.
- bool AttemptToInstallAccelerator(uint32_t accelerator_id,
- ui::mojom::EventMatcherPtr matcher) {
- DCHECK(!run_loop_);
- registrar_->AddAccelerator(
- accelerator_id, std::move(matcher),
- base::Bind(&TestAcceleratorHandler::AddAcceleratorCallback,
- base::Unretained(this)));
- run_loop_.reset(new base::RunLoop);
- run_loop_->Run();
- run_loop_.reset();
- return add_accelerator_result_;
- }
-
- private:
- void AddAcceleratorCallback(bool success) {
- DCHECK(run_loop_ && run_loop_->running());
- add_accelerator_result_ = success;
- run_loop_->Quit();
- }
-
- // AcceleratorHandler:
- void OnAccelerator(uint32_t id, std::unique_ptr<ui::Event> event) override {}
-
- std::set<uint32_t> installed_accelerators_;
- std::unique_ptr<base::RunLoop> run_loop_;
- mojo::Binding<AcceleratorHandler> binding_;
- AcceleratorRegistrarPtr registrar_;
- bool add_accelerator_result_;
-
- DISALLOW_COPY_AND_ASSIGN(TestAcceleratorHandler);
-};
-
-class AcceleratorRegistrarTest : public service_manager::test::ServiceTest {
- public:
- AcceleratorRegistrarTest()
- : service_manager::test::ServiceTest("exe:mash_unittests") {}
- ~AcceleratorRegistrarTest() override {}
-
- protected:
- void ConnectToRegistrar(AcceleratorRegistrarPtr* registrar) {
- connector()->ConnectToInterface("service:ash", registrar);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarTest);
-};
-
-TEST_F(AcceleratorRegistrarTest, AcceleratorRegistrarBasic) {
- AcceleratorRegistrarPtr registrar_first;
- ConnectToRegistrar(&registrar_first);
- TestAcceleratorHandler handler_first(std::move(registrar_first));
- EXPECT_TRUE(handler_first.AttemptToInstallAccelerator(
- 1, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::T,
- ui::mojom::kEventFlagShiftDown)));
- // Attempting to add an accelerator with the same accelerator id from the same
- // registrar should fail.
- EXPECT_FALSE(handler_first.AttemptToInstallAccelerator(
- 1, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
- ui::mojom::kEventFlagShiftDown)));
-
- // Attempting to add an accelerator with the same id from a different
- // registrar should be OK.
- AcceleratorRegistrarPtr registrar_second;
- ConnectToRegistrar(&registrar_second);
- TestAcceleratorHandler handler_second(std::move(registrar_second));
- EXPECT_TRUE(handler_second.AttemptToInstallAccelerator(
- 1, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
- ui::mojom::kEventFlagShiftDown)));
-
- // But attempting to add an accelerator with the same matcher should fail.
- // Temporarily commented out until we sort out http://crbug.com/631836.
- /*
- EXPECT_FALSE(handler_first.AttemptToInstallAccelerator(
- 3, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
- ui::mojom::kEventFlagShiftDown)));
- EXPECT_FALSE(handler_second.AttemptToInstallAccelerator(
- 3, ui::CreateKeyMatcher(ui::mojom::KeyboardCode::N,
- ui::mojom::kEventFlagShiftDown)));
- */
-}
-
-} // namespace mus
-} // namespace ash
« no previous file with comments | « ash/mus/accelerators/accelerator_registrar_impl.cc ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698