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

Side by Side Diff: ash/mus/window_manager_unittest.cc

Issue 2089183003: mus: Introduce API for embedder to dispatch event to the embeded client. Base URL: https://chromium.googlesource.com/chromium/src.git@mus-parent-window-receives-child-event
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/mus/public/cpp/lib/window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/public/interfaces/user_window_controller.mojom.h" 10 #include "ash/public/interfaces/user_window_controller.mojom.h"
(...skipping 26 matching lines...) Expand all
37 37
38 class WindowManagerTest : public shell::test::ShellTest { 38 class WindowManagerTest : public shell::test::ShellTest {
39 public: 39 public:
40 WindowManagerTest() : shell::test::ShellTest("exe:mash_unittests") {} 40 WindowManagerTest() : shell::test::ShellTest("exe:mash_unittests") {}
41 ~WindowManagerTest() override {} 41 ~WindowManagerTest() override {}
42 42
43 private: 43 private:
44 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); 44 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest);
45 }; 45 };
46 46
47 void OnEmbed(bool success) { 47 void OnEmbed(bool success, ::mus::mojom::InputEventHandlerPtr handler) {
48 ASSERT_TRUE(success); 48 ASSERT_TRUE(success);
49 } 49 }
50 50
51 class TestUserWindowObserver : public mojom::UserWindowObserver { 51 class TestUserWindowObserver : public mojom::UserWindowObserver {
52 public: 52 public:
53 explicit TestUserWindowObserver(shell::Connector* connector) 53 explicit TestUserWindowObserver(shell::Connector* connector)
54 : binding_(this), window_count_(0u), expected_window_count_(0u) { 54 : binding_(this), window_count_(0u), expected_window_count_(0u) {
55 connector->ConnectToInterface("mojo:ash", &user_window_controller_); 55 connector->ConnectToInterface("mojo:ash", &user_window_controller_);
56 user_window_controller_->AddUserWindowObserver( 56 user_window_controller_->AddUserWindowObserver(
57 binding_.CreateInterfacePtrAndBind()); 57 binding_.CreateInterfacePtrAndBind());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ::mus::Window* top_level_window = client->NewTopLevelWindow(nullptr); 124 ::mus::Window* top_level_window = client->NewTopLevelWindow(nullptr);
125 ASSERT_TRUE(top_level_window); 125 ASSERT_TRUE(top_level_window);
126 ::mus::Window* child_window = client->NewWindow(); 126 ::mus::Window* child_window = client->NewWindow();
127 ASSERT_TRUE(child_window); 127 ASSERT_TRUE(child_window);
128 top_level_window->AddChild(child_window); 128 top_level_window->AddChild(child_window);
129 129
130 // Create another WindowTreeClient by way of embedding in 130 // Create another WindowTreeClient by way of embedding in
131 // |child_window|. This blocks until it succeeds. 131 // |child_window|. This blocks until it succeeds.
132 ::mus::mojom::WindowTreeClientPtr tree_client; 132 ::mus::mojom::WindowTreeClientPtr tree_client;
133 auto tree_client_request = GetProxy(&tree_client); 133 auto tree_client_request = GetProxy(&tree_client);
134 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed)); 134 child_window->Embed(std::move(tree_client));
135 std::unique_ptr<::mus::WindowTreeClient> child_client( 135 std::unique_ptr<::mus::WindowTreeClient> child_client(
136 new ::mus::WindowTreeClient(&window_tree_delegate, nullptr, 136 new ::mus::WindowTreeClient(&window_tree_delegate, nullptr,
137 std::move(tree_client_request))); 137 std::move(tree_client_request)));
138 child_client->WaitForEmbed(); 138 child_client->WaitForEmbed();
139 ASSERT_TRUE(!child_client->GetRoots().empty()); 139 ASSERT_TRUE(!child_client->GetRoots().empty());
140 } 140 }
141 141
142 TEST_F(WindowManagerTest, OpenWindowAndClose) { 142 TEST_F(WindowManagerTest, OpenWindowAndClose) {
143 connector()->Connect("mojo:ash"); 143 connector()->Connect("mojo:ash");
144 144
145 TestUserWindowObserver observer(connector()); 145 TestUserWindowObserver observer(connector());
146 146
147 // Connect to mus and create a new top level window. 147 // Connect to mus and create a new top level window.
148 WindowTreeClientDelegate window_tree_delegate; 148 WindowTreeClientDelegate window_tree_delegate;
149 std::unique_ptr<::mus::WindowTreeClient> client( 149 std::unique_ptr<::mus::WindowTreeClient> client(
150 new ::mus::WindowTreeClient(&window_tree_delegate, nullptr, nullptr)); 150 new ::mus::WindowTreeClient(&window_tree_delegate, nullptr, nullptr));
151 client->ConnectViaWindowTreeFactory(connector()); 151 client->ConnectViaWindowTreeFactory(connector());
152 ::mus::Window* top_level_window = client->NewTopLevelWindow(nullptr); 152 ::mus::Window* top_level_window = client->NewTopLevelWindow(nullptr);
153 ASSERT_TRUE(top_level_window); 153 ASSERT_TRUE(top_level_window);
154 154
155 observer.WaitUntilWindowCountReaches(1u); 155 observer.WaitUntilWindowCountReaches(1u);
156 client.reset(); 156 client.reset();
157 observer.WaitUntilWindowCountReaches(0u); 157 observer.WaitUntilWindowCountReaches(0u);
158 } 158 }
159 159
160 } // namespace mus 160 } // namespace mus
161 } // namespace ash 161 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | components/mus/public/cpp/lib/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698