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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "services/shell/public/cpp/service_test.h" | 9 #include "services/shell/public/cpp/service_test.h" |
10 #include "services/ui/public/cpp/window.h" | 10 #include "services/ui/public/cpp/window.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); | 40 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
41 }; | 41 }; |
42 | 42 |
43 void OnEmbed(bool success) { | 43 void OnEmbed(bool success) { |
44 ASSERT_TRUE(success); | 44 ASSERT_TRUE(success); |
45 } | 45 } |
46 | 46 |
47 TEST_F(WindowManagerTest, OpenWindow) { | 47 TEST_F(WindowManagerTest, OpenWindow) { |
48 WindowTreeClientDelegate window_tree_delegate; | 48 WindowTreeClientDelegate window_tree_delegate; |
49 | 49 |
50 connector()->Connect("mojo:ash"); | 50 connector()->Connect("service:ash"); |
51 | 51 |
52 // Connect to mus and create a new top level window. The request goes to | 52 // Connect to mus and create a new top level window. The request goes to |
53 // |ash|, but is async. | 53 // |ash|, but is async. |
54 std::unique_ptr<ui::WindowTreeClient> client( | 54 std::unique_ptr<ui::WindowTreeClient> client( |
55 new ui::WindowTreeClient(&window_tree_delegate)); | 55 new ui::WindowTreeClient(&window_tree_delegate)); |
56 client->ConnectViaWindowTreeFactory(connector()); | 56 client->ConnectViaWindowTreeFactory(connector()); |
57 ui::Window* top_level_window = client->NewTopLevelWindow(nullptr); | 57 ui::Window* top_level_window = client->NewTopLevelWindow(nullptr); |
58 ASSERT_TRUE(top_level_window); | 58 ASSERT_TRUE(top_level_window); |
59 ui::Window* child_window = client->NewWindow(); | 59 ui::Window* child_window = client->NewWindow(); |
60 ASSERT_TRUE(child_window); | 60 ASSERT_TRUE(child_window); |
61 top_level_window->AddChild(child_window); | 61 top_level_window->AddChild(child_window); |
62 | 62 |
63 // Create another WindowTreeClient by way of embedding in | 63 // Create another WindowTreeClient by way of embedding in |
64 // |child_window|. This blocks until it succeeds. | 64 // |child_window|. This blocks until it succeeds. |
65 ui::mojom::WindowTreeClientPtr tree_client; | 65 ui::mojom::WindowTreeClientPtr tree_client; |
66 auto tree_client_request = GetProxy(&tree_client); | 66 auto tree_client_request = GetProxy(&tree_client); |
67 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed)); | 67 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed)); |
68 std::unique_ptr<ui::WindowTreeClient> child_client(new ui::WindowTreeClient( | 68 std::unique_ptr<ui::WindowTreeClient> child_client(new ui::WindowTreeClient( |
69 &window_tree_delegate, nullptr, std::move(tree_client_request))); | 69 &window_tree_delegate, nullptr, std::move(tree_client_request))); |
70 child_client->WaitForEmbed(); | 70 child_client->WaitForEmbed(); |
71 ASSERT_TRUE(!child_client->GetRoots().empty()); | 71 ASSERT_TRUE(!child_client->GetRoots().empty()); |
72 } | 72 } |
73 | 73 |
74 } // namespace mus | 74 } // namespace mus |
75 } // namespace ash | 75 } // namespace ash |
OLD | NEW |