diff options
author | fsamuel <fsamuel@chromium.org> | 2015-10-15 17:12:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-16 00:13:20 +0000 |
commit | 68afcf453d29c8f311b34a0aa210e042d4adc132 (patch) | |
tree | 5d7e25e02abe745aec485ecb4450f37d24b080c8 /components/mus/public/cpp/tests/window_server_test_base.h | |
parent | da33ab883a2046613836487d852d5fd36f1dc4c3 (diff) | |
download | chromium_src-68afcf453d29c8f311b34a0aa210e042d4adc132.zip chromium_src-68afcf453d29c8f311b34a0aa210e042d4adc132.tar.gz chromium_src-68afcf453d29c8f311b34a0aa210e042d4adc132.tar.bz2 |
View => Window in components/mus/public/cpp
This CL updates the client lib to refer to mus::Windows and
mus::WindowServer instead of View and View Manager.
I hope I caught everything. I'll clean things up in
subsequent CLs, and start renaming the interfaces and
implementation.
BUG=542848
Review URL: https://codereview.chromium.org/1402223003
Cr-Commit-Position: refs/heads/master@{#354411}
Diffstat (limited to 'components/mus/public/cpp/tests/window_server_test_base.h')
-rw-r--r-- | components/mus/public/cpp/tests/window_server_test_base.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/components/mus/public/cpp/tests/window_server_test_base.h b/components/mus/public/cpp/tests/window_server_test_base.h new file mode 100644 index 0000000..b46c871 --- /dev/null +++ b/components/mus/public/cpp/tests/window_server_test_base.h @@ -0,0 +1,89 @@ +// 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. + +#ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ +#define COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ + +#include "base/memory/scoped_ptr.h" +#include "components/mus/public/cpp/window_tree_delegate.h" +#include "components/mus/public/interfaces/view_tree.mojom.h" +#include "components/mus/public/interfaces/view_tree_host.mojom.h" +#include "mojo/application/public/cpp/application_delegate.h" +#include "mojo/application/public/cpp/application_test_base.h" +#include "mojo/application/public/cpp/interface_factory.h" + +namespace mus { + +// WindowServerTestBase is a base class for use with app tests that use +// WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() +// has been invoked. window_manager() can be used to access the WindowServer +// established as part of SetUp(). +class WindowServerTestBase + : public mojo::test::ApplicationTestBase, + public mojo::ApplicationDelegate, + public WindowTreeDelegate, + public mojo::InterfaceFactory<mojo::ViewTreeClient> { + public: + WindowServerTestBase(); + ~WindowServerTestBase() override; + + // True if WindowTreeDelegate::OnConnectionLost() was called. + bool window_tree_connection_destroyed() const { + return window_tree_connection_destroyed_; + } + + // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. + // Returns true on success. Generally prefer running a RunLoop and + // explicitly quiting that, but use this for times when that is not possible. + static bool DoRunLoopWithTimeout() WARN_UNUSED_RESULT; + + // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on + // success, false if a RunLoop isn't running. + static bool QuitRunLoop() WARN_UNUSED_RESULT; + + WindowTreeConnection* window_manager() { return window_manager_; } + + protected: + WindowTreeConnection* most_recent_connection() { + return most_recent_connection_; + } + + // testing::Test: + void SetUp() override; + void TearDown() override; + + // test::ApplicationTestBase: + mojo::ApplicationDelegate* GetApplicationDelegate() override; + + // ApplicationDelegate: + bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) override; + + // WindowTreeDelegate: + void OnEmbed(Window* root) override; + void OnConnectionLost(WindowTreeConnection* connection) override; + + // InterfaceFactory<ViewTreeClient>: + void Create(mojo::ApplicationConnection* connection, + mojo::InterfaceRequest<mojo::ViewTreeClient> request) override; + + // Used to receive the most recent view tree connection loaded by an embed + // action. + WindowTreeConnection* most_recent_connection_; + + private: + mojo::ViewTreeHostPtr host_; + + // The View Manager connection held by the window manager (app running at the + // root view). + WindowTreeConnection* window_manager_; + + bool window_tree_connection_destroyed_; + + MOJO_DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); +}; + +} // namespace mus + +#endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |