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

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

Issue 2182633011: Replaces ::ui:: with ui:: in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "services/shell/public/cpp/service_test.h" 14 #include "services/shell/public/cpp/service_test.h"
15 #include "services/ui/public/cpp/window.h" 15 #include "services/ui/public/cpp/window.h"
16 #include "services/ui/public/cpp/window_tree_client.h" 16 #include "services/ui/public/cpp/window_tree_client.h"
17 #include "services/ui/public/cpp/window_tree_client_delegate.h" 17 #include "services/ui/public/cpp/window_tree_client_delegate.h"
18 #include "services/ui/public/interfaces/window_tree.mojom.h" 18 #include "services/ui/public/interfaces/window_tree.mojom.h"
19 19
20 namespace ash { 20 namespace ash {
21 namespace mus { 21 namespace mus {
22 22
23 class WindowTreeClientDelegate : public ::ui::WindowTreeClientDelegate { 23 class WindowTreeClientDelegate : public ui::WindowTreeClientDelegate {
24 public: 24 public:
25 WindowTreeClientDelegate() {} 25 WindowTreeClientDelegate() {}
26 ~WindowTreeClientDelegate() override {} 26 ~WindowTreeClientDelegate() override {}
27 27
28 private: 28 private:
29 // ui::WindowTreeClientDelegate: 29 // ui::WindowTreeClientDelegate:
30 void OnEmbed(::ui::Window* root) override {} 30 void OnEmbed(ui::Window* root) override {}
31 void OnDidDestroyClient(::ui::WindowTreeClient* client) override {} 31 void OnDidDestroyClient(ui::WindowTreeClient* client) override {}
32 void OnEventObserved(const ui::Event& event, ::ui::Window* target) override {} 32 void OnEventObserved(const ui::Event& event, ui::Window* target) override {}
33 33
34 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientDelegate); 34 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientDelegate);
35 }; 35 };
36 36
37 class WindowManagerTest : public shell::test::ServiceTest { 37 class WindowManagerTest : public shell::test::ServiceTest {
38 public: 38 public:
39 WindowManagerTest() : shell::test::ServiceTest("exe:mash_unittests") {} 39 WindowManagerTest() : shell::test::ServiceTest("exe:mash_unittests") {}
40 ~WindowManagerTest() override {} 40 ~WindowManagerTest() override {}
41 41
42 private: 42 private:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 DISALLOW_COPY_AND_ASSIGN(TestUserWindowObserver); 110 DISALLOW_COPY_AND_ASSIGN(TestUserWindowObserver);
111 }; 111 };
112 112
113 TEST_F(WindowManagerTest, OpenWindow) { 113 TEST_F(WindowManagerTest, OpenWindow) {
114 WindowTreeClientDelegate window_tree_delegate; 114 WindowTreeClientDelegate window_tree_delegate;
115 115
116 connector()->Connect("mojo:ash"); 116 connector()->Connect("mojo:ash");
117 117
118 // Connect to mus and create a new top level window. The request goes to 118 // Connect to mus and create a new top level window. The request goes to
119 // |ash|, but is async. 119 // |ash|, but is async.
120 std::unique_ptr<::ui::WindowTreeClient> client( 120 std::unique_ptr<ui::WindowTreeClient> client(
121 new ::ui::WindowTreeClient(&window_tree_delegate, nullptr, nullptr)); 121 new ui::WindowTreeClient(&window_tree_delegate, nullptr, nullptr));
122 client->ConnectViaWindowTreeFactory(connector()); 122 client->ConnectViaWindowTreeFactory(connector());
123 ::ui::Window* top_level_window = client->NewTopLevelWindow(nullptr); 123 ui::Window* top_level_window = client->NewTopLevelWindow(nullptr);
124 ASSERT_TRUE(top_level_window); 124 ASSERT_TRUE(top_level_window);
125 ::ui::Window* child_window = client->NewWindow(); 125 ui::Window* child_window = client->NewWindow();
126 ASSERT_TRUE(child_window); 126 ASSERT_TRUE(child_window);
127 top_level_window->AddChild(child_window); 127 top_level_window->AddChild(child_window);
128 128
129 // Create another WindowTreeClient by way of embedding in 129 // Create another WindowTreeClient by way of embedding in
130 // |child_window|. This blocks until it succeeds. 130 // |child_window|. This blocks until it succeeds.
131 ::ui::mojom::WindowTreeClientPtr tree_client; 131 ui::mojom::WindowTreeClientPtr tree_client;
132 auto tree_client_request = GetProxy(&tree_client); 132 auto tree_client_request = GetProxy(&tree_client);
133 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed)); 133 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed));
134 std::unique_ptr<::ui::WindowTreeClient> child_client( 134 std::unique_ptr<ui::WindowTreeClient> child_client(new ui::WindowTreeClient(
135 new ::ui::WindowTreeClient(&window_tree_delegate, nullptr, 135 &window_tree_delegate, nullptr, std::move(tree_client_request)));
136 std::move(tree_client_request)));
137 child_client->WaitForEmbed(); 136 child_client->WaitForEmbed();
138 ASSERT_TRUE(!child_client->GetRoots().empty()); 137 ASSERT_TRUE(!child_client->GetRoots().empty());
139 } 138 }
140 139
141 TEST_F(WindowManagerTest, OpenWindowAndClose) { 140 TEST_F(WindowManagerTest, OpenWindowAndClose) {
142 connector()->Connect("mojo:ash"); 141 connector()->Connect("mojo:ash");
143 142
144 TestUserWindowObserver observer(connector()); 143 TestUserWindowObserver observer(connector());
145 144
146 // Connect to mus and create a new top level window. 145 // Connect to mus and create a new top level window.
147 WindowTreeClientDelegate window_tree_delegate; 146 WindowTreeClientDelegate window_tree_delegate;
148 std::unique_ptr<::ui::WindowTreeClient> client( 147 std::unique_ptr<ui::WindowTreeClient> client(
149 new ::ui::WindowTreeClient(&window_tree_delegate, nullptr, nullptr)); 148 new ui::WindowTreeClient(&window_tree_delegate, nullptr, nullptr));
150 client->ConnectViaWindowTreeFactory(connector()); 149 client->ConnectViaWindowTreeFactory(connector());
151 ::ui::Window* top_level_window = client->NewTopLevelWindow(nullptr); 150 ui::Window* top_level_window = client->NewTopLevelWindow(nullptr);
152 ASSERT_TRUE(top_level_window); 151 ASSERT_TRUE(top_level_window);
153 152
154 observer.WaitUntilWindowCountReaches(1u); 153 observer.WaitUntilWindowCountReaches(1u);
155 client.reset(); 154 client.reset();
156 observer.WaitUntilWindowCountReaches(0u); 155 observer.WaitUntilWindowCountReaches(0u);
157 } 156 }
158 157
159 } // namespace mus 158 } // namespace mus
160 } // namespace ash 159 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.cc ('k') | ash/mus/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698