| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <stdint.h> | |
| 6 #include <utility> | |
| 7 | |
| 8 #include "base/bind.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "components/mus/public/cpp/window.h" | |
| 11 #include "components/mus/public/cpp/window_tree_connection.h" | |
| 12 #include "components/mus/public/cpp/window_tree_delegate.h" | |
| 13 #include "components/mus/public/interfaces/window_tree.mojom.h" | |
| 14 #include "mojo/shell/public/cpp/application_test_base.h" | |
| 15 | |
| 16 namespace mash { | |
| 17 namespace wm { | |
| 18 | |
| 19 class WindowTreeDelegateImpl : public mus::WindowTreeDelegate { | |
| 20 public: | |
| 21 WindowTreeDelegateImpl() {} | |
| 22 ~WindowTreeDelegateImpl() override {} | |
| 23 | |
| 24 private: | |
| 25 // mus::WindowTreeDelegate: | |
| 26 void OnEmbed(mus::Window* root) override {} | |
| 27 void OnConnectionLost(mus::WindowTreeConnection* connection) override {} | |
| 28 | |
| 29 DISALLOW_COPY_AND_ASSIGN(WindowTreeDelegateImpl); | |
| 30 }; | |
| 31 | |
| 32 using WindowManagerAppTest = mojo::test::ApplicationTestBase; | |
| 33 | |
| 34 void OnEmbed(bool success) { | |
| 35 ASSERT_TRUE(success); | |
| 36 } | |
| 37 | |
| 38 TEST_F(WindowManagerAppTest, OpenWindow) { | |
| 39 WindowTreeDelegateImpl window_tree_delegate; | |
| 40 | |
| 41 // Bring up the the desktop_wm. | |
| 42 connector()->Connect("mojo:desktop_wm"); | |
| 43 | |
| 44 // Connect to mus and create a new top level window. The request goes to | |
| 45 // the |desktop_wm|, but is async. | |
| 46 scoped_ptr<mus::WindowTreeConnection> connection( | |
| 47 mus::WindowTreeConnection::Create(&window_tree_delegate, connector())); | |
| 48 mus::Window* top_level_window = connection->NewTopLevelWindow(nullptr); | |
| 49 ASSERT_TRUE(top_level_window); | |
| 50 mus::Window* child_window = connection->NewWindow(); | |
| 51 ASSERT_TRUE(child_window); | |
| 52 top_level_window->AddChild(child_window); | |
| 53 | |
| 54 // Create another WindowTreeConnection by way of embedding in | |
| 55 // |child_window|. This blocks until it succeeds. | |
| 56 mus::mojom::WindowTreeClientPtr tree_client; | |
| 57 auto tree_client_request = GetProxy(&tree_client); | |
| 58 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed)); | |
| 59 scoped_ptr<mus::WindowTreeConnection> child_connection( | |
| 60 mus::WindowTreeConnection::Create( | |
| 61 &window_tree_delegate, std::move(tree_client_request), | |
| 62 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED)); | |
| 63 ASSERT_TRUE(!child_connection->GetRoots().empty()); | |
| 64 } | |
| 65 | |
| 66 } // namespace wm | |
| 67 } // namespace mash | |
| OLD | NEW |