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

Unified Diff: components/mus/public/cpp/tests/test_window_tree_connection_setup.cc

Issue 1983243002: Creates mus test helper class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override Created 4 years, 7 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
Index: components/mus/public/cpp/tests/test_window_tree_connection_setup.cc
diff --git a/components/mus/public/cpp/tests/test_window_tree_connection_setup.cc b/components/mus/public/cpp/tests/test_window_tree_connection_setup.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e1c28350748b1a23bc8bb5fe79383f31fdf6e48f
--- /dev/null
+++ b/components/mus/public/cpp/tests/test_window_tree_connection_setup.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 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 "components/mus/public/cpp/tests/test_window_tree_connection_setup.h"
+
+#include "components/mus/public/cpp/lib/window_tree_client_impl.h"
+#include "components/mus/public/cpp/tests/test_window_tree.h"
+#include "components/mus/public/cpp/tests/window_tree_client_impl_private.h"
+
+namespace mus {
+
+TestWindowTreeConnectionSetup::TestWindowTreeConnectionSetup() {}
+
+TestWindowTreeConnectionSetup::~TestWindowTreeConnectionSetup() {
+ std::unique_ptr<WindowTreeConnection> window_tree_client =
+ std::move(window_tree_client_);
+ if (window_tree_client)
+ window_tree_client->RemoveObserver(this);
+}
+
+void TestWindowTreeConnectionSetup::Init(
+ WindowTreeDelegate* window_tree_delegate,
+ WindowManagerDelegate* window_manager_delegate) {
+ window_tree_.reset(new TestWindowTree);
+ window_tree_client_.reset(new WindowTreeClientImpl(
+ window_tree_delegate, window_manager_delegate, nullptr));
+ static_cast<WindowTreeConnection*>(window_tree_client_.get())
+ ->AddObserver(this);
+ WindowTreeClientImplPrivate(window_tree_client_.get())
+ .OnEmbed(window_tree_.get());
+}
+
+WindowTreeConnection* TestWindowTreeConnectionSetup::window_tree_connection() {
+ return window_tree_client_.get();
+}
+
+void TestWindowTreeConnectionSetup::OnWillDestroyConnection(
+ mus::WindowTreeConnection* connection) {
+ // See comment in header as to why we do this.
+ window_tree_client_.release();
+}
+
+} // namespace mus

Powered by Google App Engine
This is Rietveld 408576698