diff options
author | mek <mek@chromium.org> | 2015-12-10 12:11:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-10 20:13:13 +0000 |
commit | 0c84dc769b19597974bb6cc881fcb6aa42b67e4d (patch) | |
tree | 0926c5335b46739fb4ff773a47d2bf2fc9eea16f | |
parent | e4f571c0cac6d178651112484cc16935f86055aa (diff) | |
download | chromium_src-0c84dc769b19597974bb6cc881fcb6aa42b67e4d.zip chromium_src-0c84dc769b19597974bb6cc881fcb6aa42b67e4d.tar.gz chromium_src-0c84dc769b19597974bb6cc881fcb6aa42b67e4d.tar.bz2 |
Revert of mash: Add a couple of apptests for AcceleratorRegistrar. (patchset #2 id:20001 of https://codereview.chromium.org/1510713002/ )
Reason for revert:
AcceleratorRegistrarTest.AcceleratorsRemovedOnHandlerDestroy is flaky on both trybots and the main waterfall (see https://build.chromium.org/p/chromium.linux/builders/Linux%20Tests/builds/35418 for one random example where it failed).
BUG=568634
Original issue's description:
> mash: Add a couple of apptests for AcceleratorRegistrar.
>
> . Test that different AcceleratorRegistrars get different namespaces, and so can
> install accelerators with the same id.
> . Test that differentl registrars do not allow registering accelerators with the
> same event matcher.
> . Test that destroying an AcceleratorHandler removes associated accelerators.
>
> BUG=548363
>
> Committed: https://crrev.com/8aac81dc92c8eaaec476b0c6c5ccf3e114590b68
> Cr-Commit-Position: refs/heads/master@{#363719}
TBR=ben@chromium.org,sadrul@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=548363
Review URL: https://codereview.chromium.org/1516013002
Cr-Commit-Position: refs/heads/master@{#364450}
-rw-r--r-- | mash/wm/BUILD.gn | 1 | ||||
-rw-r--r-- | mash/wm/accelerator_registrar_apptest.cc | 143 |
2 files changed, 0 insertions, 144 deletions
diff --git a/mash/wm/BUILD.gn b/mash/wm/BUILD.gn index 882d3ac..c0ae807 100644 --- a/mash/wm/BUILD.gn +++ b/mash/wm/BUILD.gn @@ -126,7 +126,6 @@ mojo_native_application("apptests") { testonly = true sources = [ - "accelerator_registrar_apptest.cc", "window_manager_apptest.cc", ] diff --git a/mash/wm/accelerator_registrar_apptest.cc b/mash/wm/accelerator_registrar_apptest.cc deleted file mode 100644 index fb3c561..0000000 --- a/mash/wm/accelerator_registrar_apptest.cc +++ /dev/null @@ -1,143 +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 "base/bind.h" -#include "base/run_loop.h" -#include "components/mus/public/cpp/event_matcher.h" -#include "components/mus/public/cpp/window.h" -#include "components/mus/public/interfaces/accelerator_registrar.mojom.h" -#include "components/mus/public/interfaces/window_manager.mojom.h" -#include "mojo/application/public/cpp/application_impl.h" -#include "mojo/application/public/cpp/application_test_base.h" -#include "mojo/public/cpp/bindings/binding.h" - -using mus::mojom::AcceleratorHandler; -using mus::mojom::AcceleratorHandlerPtr; -using mus::mojom::AcceleratorRegistrar; -using mus::mojom::AcceleratorRegistrarPtr; - -namespace mash { -namespace wm { - -class TestAcceleratorHandler : public AcceleratorHandler { - public: - explicit TestAcceleratorHandler(AcceleratorRegistrarPtr registrar) - : binding_(this), - registrar_(std::move(registrar)), - add_accelerator_result_(false) { - AcceleratorHandlerPtr handler; - binding_.Bind(GetProxy(&handler)); - registrar_->SetHandler(std::move(handler)); - } - ~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, - mus::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, mus::mojom::EventPtr event) override {} - - std::set<uint32_t> installed_accelerators_; - scoped_ptr<base::RunLoop> run_loop_; - mojo::Binding<AcceleratorHandler> binding_; - AcceleratorRegistrarPtr registrar_; - bool add_accelerator_result_; - - DISALLOW_COPY_AND_ASSIGN(TestAcceleratorHandler); -}; - -class AcceleratorRegistrarTest : public mojo::test::ApplicationTestBase { - public: - AcceleratorRegistrarTest() {} - ~AcceleratorRegistrarTest() override {} - - protected: - void ConnectToRegistrar(AcceleratorRegistrarPtr* registrar) { - application_impl()->ConnectToService("mojo:desktop_wm", registrar); - } - - private: - DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarTest); -}; - -TEST_F(AcceleratorRegistrarTest, AcceleratorRegistrarBasic) { - AcceleratorRegistrarPtr registrar_first; - ConnectToRegistrar(®istrar_first); - TestAcceleratorHandler handler_first(std::move(registrar_first)); - EXPECT_TRUE(handler_first.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); - // Attempting to add an accelerator with the same accelerator id from the same - // registrar should fail. - EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); - - // Attempting to add an accelerator with the same id from a different - // registrar should be OK. - AcceleratorRegistrarPtr registrar_second; - ConnectToRegistrar(®istrar_second); - TestAcceleratorHandler handler_second(std::move(registrar_second)); - EXPECT_TRUE(handler_second.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); - - // But attempting to add an accelerator with the same matcher should fail. - EXPECT_FALSE(handler_first.AttemptToInstallAccelerator( - 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); - EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( - 3, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_N, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); -} - -// Tests that accelerators installed for a handler are automatically removed -// when the handler is destroyed. -TEST_F(AcceleratorRegistrarTest, AcceleratorsRemovedOnHandlerDestroy) { - AcceleratorRegistrarPtr registrar_first; - ConnectToRegistrar(®istrar_first); - scoped_ptr<TestAcceleratorHandler> handler_first( - new TestAcceleratorHandler(std::move(registrar_first))); - EXPECT_TRUE(handler_first->AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); - - AcceleratorRegistrarPtr registrar_second; - ConnectToRegistrar(®istrar_second); - TestAcceleratorHandler handler_second(std::move(registrar_second)); - // The attempt to install an accelerator with the same matcher will now fail. - EXPECT_FALSE(handler_second.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); - - handler_first.reset(); - // Now that the first handler is destroyed, that should unregister the - // accelerator. So another attempt to install the accelerator with the same - // matcher should now pass. - EXPECT_TRUE(handler_second.AttemptToInstallAccelerator( - 1, mus::CreateKeyMatcher(mus::mojom::KEYBOARD_CODE_T, - mus::mojom::EVENT_FLAGS_SHIFT_DOWN))); -} - -} // namespace wm -} // namespace mash |