OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "components/mus/public/cpp/window.h" | 6 #include "components/mus/public/cpp/window.h" |
7 #include "components/mus/public/cpp/window_tree_connection.h" | 7 #include "components/mus/public/cpp/window_tree_connection.h" |
8 #include "components/mus/public/cpp/window_tree_delegate.h" | 8 #include "components/mus/public/cpp/window_tree_delegate.h" |
9 #include "components/mus/public/interfaces/window_manager.mojom.h" | 9 #include "components/mus/public/interfaces/window_manager.mojom.h" |
10 #include "components/mus/public/interfaces/window_tree.mojom.h" | 10 #include "components/mus/public/interfaces/window_tree.mojom.h" |
11 #include "mojo/application/public/cpp/application_impl.h" | 11 #include "mojo/application/public/cpp/application_impl.h" |
12 #include "mojo/application/public/cpp/application_test_base.h" | 12 #include "mojo/application/public/cpp/application_test_base.h" |
13 | 13 |
14 namespace mash { | 14 namespace mash { |
15 namespace wm { | 15 namespace wm { |
16 | 16 |
17 class WindowManagerAppTest : public mojo::test::ApplicationTestBase, | 17 class WindowManagerAppTest : public mojo::test::ApplicationTestBase, |
18 public mus::WindowTreeDelegate { | 18 public mus::WindowTreeDelegate { |
19 public: | 19 public: |
20 WindowManagerAppTest() {} | 20 WindowManagerAppTest() {} |
21 ~WindowManagerAppTest() override {} | 21 ~WindowManagerAppTest() override {} |
22 | 22 |
23 protected: | 23 protected: |
24 void ConnectToWindowManager(mus::mojom::WindowManagerPtr* window_manager) { | 24 void ConnectToWindowManager(mus::mojom::WindowManagerPtr* window_manager) { |
25 application_impl()->ConnectToService("mojo:example_wm", window_manager); | 25 application_impl()->ConnectToService("mojo:mash_wm", window_manager); |
26 } | 26 } |
27 | 27 |
28 mus::Window* OpenWindow(mus::mojom::WindowManager* window_manager) { | 28 mus::Window* OpenWindow(mus::mojom::WindowManager* window_manager) { |
29 mus::mojom::WindowTreeClientPtr window_tree_client; | 29 mus::mojom::WindowTreeClientPtr window_tree_client; |
30 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> | 30 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> |
31 window_tree_client_request = GetProxy(&window_tree_client); | 31 window_tree_client_request = GetProxy(&window_tree_client); |
32 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties; | 32 mojo::Map<mojo::String, mojo::Array<uint8_t>> properties; |
| 33 properties.mark_non_null(); |
33 window_manager->OpenWindow(window_tree_client.Pass(), properties.Pass()); | 34 window_manager->OpenWindow(window_tree_client.Pass(), properties.Pass()); |
34 mus::WindowTreeConnection* connection = mus::WindowTreeConnection::Create( | 35 mus::WindowTreeConnection* connection = mus::WindowTreeConnection::Create( |
35 this, window_tree_client_request.Pass(), | 36 this, window_tree_client_request.Pass(), |
36 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED); | 37 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED); |
37 return connection->GetRoot(); | 38 return connection->GetRoot(); |
38 } | 39 } |
39 | 40 |
40 private: | 41 private: |
41 // mus::WindowTreeDelegate: | 42 // mus::WindowTreeDelegate: |
42 void OnEmbed(mus::Window* root) override {} | 43 void OnEmbed(mus::Window* root) override {} |
43 void OnConnectionLost(mus::WindowTreeConnection* connection) override {} | 44 void OnConnectionLost(mus::WindowTreeConnection* connection) override {} |
44 | 45 |
45 DISALLOW_COPY_AND_ASSIGN(WindowManagerAppTest); | 46 DISALLOW_COPY_AND_ASSIGN(WindowManagerAppTest); |
46 }; | 47 }; |
47 | 48 |
48 TEST_F(WindowManagerAppTest, OpenWindow) { | 49 TEST_F(WindowManagerAppTest, OpenWindow) { |
49 mus::mojom::WindowManagerPtr connection; | 50 mus::mojom::WindowManagerPtr connection; |
50 ConnectToWindowManager(&connection); | 51 ConnectToWindowManager(&connection); |
51 | 52 |
52 ASSERT_TRUE(OpenWindow(connection.get())); | 53 ASSERT_TRUE(OpenWindow(connection.get())); |
53 } | 54 } |
54 | 55 |
55 } // namespace wm | 56 } // namespace wm |
56 } // namespace mash | 57 } // namespace mash |
OLD | NEW |