OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DisplayTest() {} | 96 DisplayTest() {} |
97 ~DisplayTest() override {} | 97 ~DisplayTest() override {} |
98 | 98 |
99 WindowServer* window_server() { return ws_test_helper_.window_server(); } | 99 WindowServer* window_server() { return ws_test_helper_.window_server(); } |
100 DisplayManager* display_manager() { | 100 DisplayManager* display_manager() { |
101 return window_server()->display_manager(); | 101 return window_server()->display_manager(); |
102 } | 102 } |
103 TestWindowServerDelegate* window_server_delegate() { | 103 TestWindowServerDelegate* window_server_delegate() { |
104 return ws_test_helper_.window_server_delegate(); | 104 return ws_test_helper_.window_server_delegate(); |
105 } | 105 } |
106 TestPlatformScreen& platform_screen() { return platform_screen_; } | 106 TestScreenManager& screen_manager() { return screen_manager_; } |
107 | 107 |
108 protected: | 108 protected: |
109 // testing::Test: | 109 // testing::Test: |
110 void SetUp() override { | 110 void SetUp() override { |
111 platform_screen_.Init(window_server()->display_manager()); | 111 screen_manager_.Init(window_server()->display_manager()); |
112 window_server()->user_id_tracker()->AddUserId(kTestId1); | 112 window_server()->user_id_tracker()->AddUserId(kTestId1); |
113 window_server()->user_id_tracker()->AddUserId(kTestId2); | 113 window_server()->user_id_tracker()->AddUserId(kTestId2); |
114 } | 114 } |
115 | 115 |
116 private: | 116 private: |
117 WindowServerTestHelper ws_test_helper_; | 117 WindowServerTestHelper ws_test_helper_; |
118 TestPlatformScreen platform_screen_; | 118 TestScreenManager screen_manager_; |
119 | 119 |
120 DISALLOW_COPY_AND_ASSIGN(DisplayTest); | 120 DISALLOW_COPY_AND_ASSIGN(DisplayTest); |
121 }; | 121 }; |
122 | 122 |
123 TEST_F(DisplayTest, CreateDisplay) { | 123 TEST_F(DisplayTest, CreateDisplay) { |
124 AddWindowManager(window_server(), kTestId1); | 124 AddWindowManager(window_server(), kTestId1); |
125 const int64_t display_id = | 125 const int64_t display_id = |
126 platform_screen().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f)); | 126 screen_manager().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f)); |
127 | 127 |
128 ASSERT_EQ(1u, display_manager()->displays().size()); | 128 ASSERT_EQ(1u, display_manager()->displays().size()); |
129 Display* display = display_manager()->GetDisplayById(display_id); | 129 Display* display = display_manager()->GetDisplayById(display_id); |
130 | 130 |
131 // Display should have root window with correct size. | 131 // Display should have root window with correct size. |
132 ASSERT_NE(nullptr, display->root_window()); | 132 ASSERT_NE(nullptr, display->root_window()); |
133 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); | 133 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); |
134 | 134 |
135 // Display should have a WM root window with the correct size too. | 135 // Display should have a WM root window with the correct size too. |
136 EXPECT_EQ(1u, display->num_window_manger_states()); | 136 EXPECT_EQ(1u, display->num_window_manger_states()); |
137 WindowManagerDisplayRoot* root1 = | 137 WindowManagerDisplayRoot* root1 = |
138 display->GetWindowManagerDisplayRootForUser(kTestId1); | 138 display->GetWindowManagerDisplayRootForUser(kTestId1); |
139 ASSERT_NE(nullptr, root1); | 139 ASSERT_NE(nullptr, root1); |
140 ASSERT_NE(nullptr, root1->root()); | 140 ASSERT_NE(nullptr, root1->root()); |
141 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString()); | 141 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString()); |
142 } | 142 } |
143 | 143 |
144 TEST_F(DisplayTest, CreateDisplayBeforeWM) { | 144 TEST_F(DisplayTest, CreateDisplayBeforeWM) { |
145 // Add one display, no WM exists yet. | 145 // Add one display, no WM exists yet. |
146 const int64_t display_id = | 146 const int64_t display_id = |
147 platform_screen().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f)); | 147 screen_manager().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f)); |
148 EXPECT_EQ(1u, display_manager()->displays().size()); | 148 EXPECT_EQ(1u, display_manager()->displays().size()); |
149 | 149 |
150 Display* display = display_manager()->GetDisplayById(display_id); | 150 Display* display = display_manager()->GetDisplayById(display_id); |
151 | 151 |
152 // Display should have root window with correct size. | 152 // Display should have root window with correct size. |
153 ASSERT_NE(nullptr, display->root_window()); | 153 ASSERT_NE(nullptr, display->root_window()); |
154 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); | 154 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); |
155 | 155 |
156 // There should be no WM state for display yet. | 156 // There should be no WM state for display yet. |
157 EXPECT_EQ(0u, display->num_window_manger_states()); | 157 EXPECT_EQ(0u, display->num_window_manger_states()); |
158 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1)); | 158 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1)); |
159 | 159 |
160 AddWindowManager(window_server(), kTestId1); | 160 AddWindowManager(window_server(), kTestId1); |
161 | 161 |
162 // After adding a WM display should have WM state and WM root for the display. | 162 // After adding a WM display should have WM state and WM root for the display. |
163 EXPECT_EQ(1u, display->num_window_manger_states()); | 163 EXPECT_EQ(1u, display->num_window_manger_states()); |
164 WindowManagerDisplayRoot* root1 = | 164 WindowManagerDisplayRoot* root1 = |
165 display->GetWindowManagerDisplayRootForUser(kTestId1); | 165 display->GetWindowManagerDisplayRootForUser(kTestId1); |
166 ASSERT_NE(nullptr, root1); | 166 ASSERT_NE(nullptr, root1); |
167 ASSERT_NE(nullptr, root1->root()); | 167 ASSERT_NE(nullptr, root1->root()); |
168 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString()); | 168 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString()); |
169 } | 169 } |
170 | 170 |
171 TEST_F(DisplayTest, CreateDisplayWithTwoWindowManagers) { | 171 TEST_F(DisplayTest, CreateDisplayWithTwoWindowManagers) { |
172 AddWindowManager(window_server(), kTestId1); | 172 AddWindowManager(window_server(), kTestId1); |
173 const int64_t display_id = platform_screen().AddDisplay(); | 173 const int64_t display_id = screen_manager().AddDisplay(); |
174 Display* display = display_manager()->GetDisplayById(display_id); | 174 Display* display = display_manager()->GetDisplayById(display_id); |
175 | 175 |
176 // There should be only be one WM at this point. | 176 // There should be only be one WM at this point. |
177 ASSERT_EQ(1u, display->num_window_manger_states()); | 177 ASSERT_EQ(1u, display->num_window_manger_states()); |
178 EXPECT_NE(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1)); | 178 EXPECT_NE(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1)); |
179 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId2)); | 179 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId2)); |
180 | 180 |
181 AddWindowManager(window_server(), kTestId2); | 181 AddWindowManager(window_server(), kTestId2); |
182 | 182 |
183 // There should now be two WMs. | 183 // There should now be two WMs. |
(...skipping 10 matching lines...) Expand all Loading... |
194 EXPECT_NE(root1->root(), root2->root()); | 194 EXPECT_NE(root1->root(), root2->root()); |
195 EXPECT_EQ(root1->root()->bounds(), root2->root()->bounds()); | 195 EXPECT_EQ(root1->root()->bounds(), root2->root()->bounds()); |
196 } | 196 } |
197 | 197 |
198 TEST_F(DisplayTest, CreateDisplayWithDeviceScaleFactor) { | 198 TEST_F(DisplayTest, CreateDisplayWithDeviceScaleFactor) { |
199 // The display bounds should be the pixel_size / device_scale_factor. | 199 // The display bounds should be the pixel_size / device_scale_factor. |
200 const ViewportMetrics metrics = MakeViewportMetrics(0, 0, 1024, 768, 2.0f); | 200 const ViewportMetrics metrics = MakeViewportMetrics(0, 0, 1024, 768, 2.0f); |
201 EXPECT_EQ("0,0 512x384", metrics.bounds.ToString()); | 201 EXPECT_EQ("0,0 512x384", metrics.bounds.ToString()); |
202 EXPECT_EQ("1024x768", metrics.pixel_size.ToString()); | 202 EXPECT_EQ("1024x768", metrics.pixel_size.ToString()); |
203 | 203 |
204 const int64_t display_id = platform_screen().AddDisplay(metrics); | 204 const int64_t display_id = screen_manager().AddDisplay(metrics); |
205 Display* display = display_manager()->GetDisplayById(display_id); | 205 Display* display = display_manager()->GetDisplayById(display_id); |
206 | 206 |
207 // The root ServerWindow bounds should be in PP. | 207 // The root ServerWindow bounds should be in PP. |
208 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); | 208 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); |
209 | 209 |
210 ViewportMetrics modified_metrics = metrics; | 210 ViewportMetrics modified_metrics = metrics; |
211 modified_metrics.work_area.set_height(metrics.work_area.height() - 48); | 211 modified_metrics.work_area.set_height(metrics.work_area.height() - 48); |
212 platform_screen().ModifyDisplay(display_id, modified_metrics); | 212 screen_manager().ModifyDisplay(display_id, modified_metrics); |
213 | 213 |
214 // The root ServerWindow should still be in PP after updating the work area. | 214 // The root ServerWindow should still be in PP after updating the work area. |
215 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); | 215 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); |
216 } | 216 } |
217 | 217 |
218 TEST_F(DisplayTest, Destruction) { | 218 TEST_F(DisplayTest, Destruction) { |
219 AddWindowManager(window_server(), kTestId1); | 219 AddWindowManager(window_server(), kTestId1); |
220 | 220 |
221 int64_t display_id = platform_screen().AddDisplay(); | 221 int64_t display_id = screen_manager().AddDisplay(); |
222 | 222 |
223 // Add a second WM. | 223 // Add a second WM. |
224 AddWindowManager(window_server(), kTestId2); | 224 AddWindowManager(window_server(), kTestId2); |
225 ASSERT_EQ(1u, display_manager()->displays().size()); | 225 ASSERT_EQ(1u, display_manager()->displays().size()); |
226 Display* display = display_manager()->GetDisplayById(display_id); | 226 Display* display = display_manager()->GetDisplayById(display_id); |
227 ASSERT_EQ(2u, display->num_window_manger_states()); | 227 ASSERT_EQ(2u, display->num_window_manger_states()); |
228 // There should be two trees, one for each windowmanager. | 228 // There should be two trees, one for each windowmanager. |
229 EXPECT_EQ(2u, window_server()->num_trees()); | 229 EXPECT_EQ(2u, window_server()->num_trees()); |
230 | 230 |
231 { | 231 { |
232 WindowManagerState* state = GetWindowManagerStateForUser(display, kTestId1); | 232 WindowManagerState* state = GetWindowManagerStateForUser(display, kTestId1); |
233 // Destroy the tree associated with |state|. Should result in deleting | 233 // Destroy the tree associated with |state|. Should result in deleting |
234 // |state|. | 234 // |state|. |
235 window_server()->DestroyTree(state->window_tree()); | 235 window_server()->DestroyTree(state->window_tree()); |
236 ASSERT_EQ(1u, display->num_window_manger_states()); | 236 ASSERT_EQ(1u, display->num_window_manger_states()); |
237 EXPECT_FALSE(GetWindowManagerStateForUser(display, kTestId1)); | 237 EXPECT_FALSE(GetWindowManagerStateForUser(display, kTestId1)); |
238 EXPECT_EQ(1u, display_manager()->displays().size()); | 238 EXPECT_EQ(1u, display_manager()->displays().size()); |
239 EXPECT_EQ(1u, window_server()->num_trees()); | 239 EXPECT_EQ(1u, window_server()->num_trees()); |
240 } | 240 } |
241 | 241 |
242 EXPECT_FALSE(window_server_delegate()->got_on_no_more_displays()); | 242 EXPECT_FALSE(window_server_delegate()->got_on_no_more_displays()); |
243 platform_screen().RemoveDisplay(display_id); | 243 screen_manager().RemoveDisplay(display_id); |
244 // There is still one tree left. | 244 // There is still one tree left. |
245 EXPECT_EQ(1u, window_server()->num_trees()); | 245 EXPECT_EQ(1u, window_server()->num_trees()); |
246 EXPECT_TRUE(window_server_delegate()->got_on_no_more_displays()); | 246 EXPECT_TRUE(window_server_delegate()->got_on_no_more_displays()); |
247 } | 247 } |
248 | 248 |
249 TEST_F(DisplayTest, EventStateResetOnUserSwitch) { | 249 TEST_F(DisplayTest, EventStateResetOnUserSwitch) { |
250 const int64_t display_id = platform_screen().AddDisplay(); | 250 const int64_t display_id = screen_manager().AddDisplay(); |
251 | 251 |
252 AddWindowManager(window_server(), kTestId1); | 252 AddWindowManager(window_server(), kTestId1); |
253 AddWindowManager(window_server(), kTestId2); | 253 AddWindowManager(window_server(), kTestId2); |
254 | 254 |
255 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 255 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
256 | 256 |
257 ASSERT_EQ(1u, display_manager()->displays().size()); | 257 ASSERT_EQ(1u, display_manager()->displays().size()); |
258 Display* display = display_manager()->GetDisplayById(display_id); | 258 Display* display = display_manager()->GetDisplayById(display_id); |
259 WindowManagerState* active_wms = | 259 WindowManagerState* active_wms = |
260 display->GetActiveWindowManagerDisplayRoot()->window_manager_state(); | 260 display->GetActiveWindowManagerDisplayRoot()->window_manager_state(); |
(...skipping 22 matching lines...) Expand all Loading... |
283 display->GetActiveWindowManagerDisplayRoot()->window_manager_state(); | 283 display->GetActiveWindowManagerDisplayRoot()->window_manager_state(); |
284 EXPECT_EQ(kTestId2, active_wms->user_id()); | 284 EXPECT_EQ(kTestId2, active_wms->user_id()); |
285 EXPECT_EQ(gfx::Point(20, 25), | 285 EXPECT_EQ(gfx::Point(20, 25), |
286 active_wms->event_dispatcher()->mouse_pointer_last_location()); | 286 active_wms->event_dispatcher()->mouse_pointer_last_location()); |
287 EXPECT_FALSE(EventDispatcherTestApi(active_wms->event_dispatcher()) | 287 EXPECT_FALSE(EventDispatcherTestApi(active_wms->event_dispatcher()) |
288 .AreAnyPointersDown()); | 288 .AreAnyPointersDown()); |
289 } | 289 } |
290 | 290 |
291 // Verifies capture fails when wm is inactive and succeeds when wm is active. | 291 // Verifies capture fails when wm is inactive and succeeds when wm is active. |
292 TEST_F(DisplayTest, SetCaptureFromWindowManager) { | 292 TEST_F(DisplayTest, SetCaptureFromWindowManager) { |
293 const int64_t display_id = platform_screen().AddDisplay(); | 293 const int64_t display_id = screen_manager().AddDisplay(); |
294 AddWindowManager(window_server(), kTestId1); | 294 AddWindowManager(window_server(), kTestId1); |
295 AddWindowManager(window_server(), kTestId2); | 295 AddWindowManager(window_server(), kTestId2); |
296 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 296 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
297 ASSERT_EQ(1u, display_manager()->displays().size()); | 297 ASSERT_EQ(1u, display_manager()->displays().size()); |
298 Display* display = display_manager()->GetDisplayById(display_id); | 298 Display* display = display_manager()->GetDisplayById(display_id); |
299 WindowManagerState* wms_for_id2 = | 299 WindowManagerState* wms_for_id2 = |
300 GetWindowManagerStateForUser(display, kTestId2); | 300 GetWindowManagerStateForUser(display, kTestId2); |
301 ASSERT_TRUE(wms_for_id2); | 301 ASSERT_TRUE(wms_for_id2); |
302 EXPECT_FALSE(wms_for_id2->IsActive()); | 302 EXPECT_FALSE(wms_for_id2->IsActive()); |
303 | 303 |
304 // Create a child of the root that we can set capture on. | 304 // Create a child of the root that we can set capture on. |
305 WindowTree* tree = wms_for_id2->window_tree(); | 305 WindowTree* tree = wms_for_id2->window_tree(); |
306 ClientWindowId child_window_id; | 306 ClientWindowId child_window_id; |
307 ASSERT_TRUE(NewWindowInTree(tree, &child_window_id)); | 307 ASSERT_TRUE(NewWindowInTree(tree, &child_window_id)); |
308 | 308 |
309 WindowTreeTestApi(tree).EnableCapture(); | 309 WindowTreeTestApi(tree).EnableCapture(); |
310 | 310 |
311 // SetCapture() should fail for user id2 as it is inactive. | 311 // SetCapture() should fail for user id2 as it is inactive. |
312 EXPECT_FALSE(tree->SetCapture(child_window_id)); | 312 EXPECT_FALSE(tree->SetCapture(child_window_id)); |
313 | 313 |
314 // Make the second user active and verify capture works. | 314 // Make the second user active and verify capture works. |
315 window_server()->user_id_tracker()->SetActiveUserId(kTestId2); | 315 window_server()->user_id_tracker()->SetActiveUserId(kTestId2); |
316 EXPECT_TRUE(wms_for_id2->IsActive()); | 316 EXPECT_TRUE(wms_for_id2->IsActive()); |
317 EXPECT_TRUE(tree->SetCapture(child_window_id)); | 317 EXPECT_TRUE(tree->SetCapture(child_window_id)); |
318 } | 318 } |
319 | 319 |
320 TEST_F(DisplayTest, FocusFailsForInactiveUser) { | 320 TEST_F(DisplayTest, FocusFailsForInactiveUser) { |
321 const int64_t display_id = platform_screen().AddDisplay(); | 321 const int64_t display_id = screen_manager().AddDisplay(); |
322 AddWindowManager(window_server(), kTestId1); | 322 AddWindowManager(window_server(), kTestId1); |
323 TestWindowTreeClient* window_tree_client1 = | 323 TestWindowTreeClient* window_tree_client1 = |
324 window_server_delegate()->last_client(); | 324 window_server_delegate()->last_client(); |
325 ASSERT_TRUE(window_tree_client1); | 325 ASSERT_TRUE(window_tree_client1); |
326 AddWindowManager(window_server(), kTestId2); | 326 AddWindowManager(window_server(), kTestId2); |
327 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 327 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
328 ASSERT_EQ(1u, display_manager()->displays().size()); | 328 ASSERT_EQ(1u, display_manager()->displays().size()); |
329 Display* display = display_manager()->GetDisplayById(display_id); | 329 Display* display = display_manager()->GetDisplayById(display_id); |
330 WindowManagerState* wms_for_id2 = | 330 WindowManagerState* wms_for_id2 = |
331 GetWindowManagerStateForUser(display, kTestId2); | 331 GetWindowManagerStateForUser(display, kTestId2); |
(...skipping 14 matching lines...) Expand all Loading... |
346 wms_for_id1->window_tree()->AddActivationParent( | 346 wms_for_id1->window_tree()->AddActivationParent( |
347 ClientWindowIdForFirstRoot(wms_for_id1->window_tree())); | 347 ClientWindowIdForFirstRoot(wms_for_id1->window_tree())); |
348 ClientWindowId child1_id; | 348 ClientWindowId child1_id; |
349 NewWindowInTree(wms_for_id1->window_tree(), &child1_id); | 349 NewWindowInTree(wms_for_id1->window_tree(), &child1_id); |
350 EXPECT_TRUE(wms_for_id1->IsActive()); | 350 EXPECT_TRUE(wms_for_id1->IsActive()); |
351 EXPECT_TRUE(wms_for_id1->window_tree()->SetFocus(child1_id)); | 351 EXPECT_TRUE(wms_for_id1->window_tree()->SetFocus(child1_id)); |
352 } | 352 } |
353 | 353 |
354 // Verifies a single tree is used for multiple displays. | 354 // Verifies a single tree is used for multiple displays. |
355 TEST_F(DisplayTest, MultipleDisplays) { | 355 TEST_F(DisplayTest, MultipleDisplays) { |
356 platform_screen().AddDisplay(); | 356 screen_manager().AddDisplay(); |
357 platform_screen().AddDisplay(); | 357 screen_manager().AddDisplay(); |
358 AddWindowManager(window_server(), kTestId1); | 358 AddWindowManager(window_server(), kTestId1); |
359 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 359 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
360 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); | 360 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); |
361 TestWindowTreeBinding* window_tree_binding = | 361 TestWindowTreeBinding* window_tree_binding = |
362 (*window_server_delegate()->bindings())[0]; | 362 (*window_server_delegate()->bindings())[0]; |
363 WindowTree* tree = window_tree_binding->tree(); | 363 WindowTree* tree = window_tree_binding->tree(); |
364 ASSERT_EQ(2u, tree->roots().size()); | 364 ASSERT_EQ(2u, tree->roots().size()); |
365 std::set<const ServerWindow*> roots = tree->roots(); | 365 std::set<const ServerWindow*> roots = tree->roots(); |
366 auto it = roots.begin(); | 366 auto it = roots.begin(); |
367 ServerWindow* root1 = tree->GetWindow((*it)->id()); | 367 ServerWindow* root1 = tree->GetWindow((*it)->id()); |
368 ++it; | 368 ++it; |
369 ServerWindow* root2 = tree->GetWindow((*it)->id()); | 369 ServerWindow* root2 = tree->GetWindow((*it)->id()); |
370 ASSERT_NE(root1, root2); | 370 ASSERT_NE(root1, root2); |
371 Display* display1 = tree->GetDisplay(root1); | 371 Display* display1 = tree->GetDisplay(root1); |
372 WindowManagerState* display1_wms = | 372 WindowManagerState* display1_wms = |
373 display1->GetWindowManagerDisplayRootForUser(kTestId1) | 373 display1->GetWindowManagerDisplayRootForUser(kTestId1) |
374 ->window_manager_state(); | 374 ->window_manager_state(); |
375 Display* display2 = tree->GetDisplay(root2); | 375 Display* display2 = tree->GetDisplay(root2); |
376 WindowManagerState* display2_wms = | 376 WindowManagerState* display2_wms = |
377 display2->GetWindowManagerDisplayRootForUser(kTestId1) | 377 display2->GetWindowManagerDisplayRootForUser(kTestId1) |
378 ->window_manager_state(); | 378 ->window_manager_state(); |
379 EXPECT_EQ(display1_wms->window_tree(), display2_wms->window_tree()); | 379 EXPECT_EQ(display1_wms->window_tree(), display2_wms->window_tree()); |
380 } | 380 } |
381 | 381 |
382 // Assertions around destroying a secondary display. | 382 // Assertions around destroying a secondary display. |
383 TEST_F(DisplayTest, DestroyingDisplayDoesntDelete) { | 383 TEST_F(DisplayTest, DestroyingDisplayDoesntDelete) { |
384 AddWindowManager(window_server(), kTestId1); | 384 AddWindowManager(window_server(), kTestId1); |
385 platform_screen().AddDisplay(); | 385 screen_manager().AddDisplay(); |
386 const int64_t secondary_display_id = platform_screen().AddDisplay(); | 386 const int64_t secondary_display_id = screen_manager().AddDisplay(); |
387 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 387 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
388 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); | 388 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); |
389 WindowTree* tree = (*window_server_delegate()->bindings())[0]->tree(); | 389 WindowTree* tree = (*window_server_delegate()->bindings())[0]->tree(); |
390 ASSERT_EQ(2u, tree->roots().size()); | 390 ASSERT_EQ(2u, tree->roots().size()); |
391 Display* secondary_display = | 391 Display* secondary_display = |
392 display_manager()->GetDisplayById(secondary_display_id); | 392 display_manager()->GetDisplayById(secondary_display_id); |
393 ASSERT_TRUE(secondary_display); | 393 ASSERT_TRUE(secondary_display); |
394 bool secondary_root_destroyed = false; | 394 bool secondary_root_destroyed = false; |
395 ServerWindow* secondary_root = GetRootOnDisplay(tree, secondary_display); | 395 ServerWindow* secondary_root = GetRootOnDisplay(tree, secondary_display); |
396 ASSERT_TRUE(secondary_root); | 396 ASSERT_TRUE(secondary_root); |
397 ServerWindowDestructionObserver observer(secondary_root, | 397 ServerWindowDestructionObserver observer(secondary_root, |
398 &secondary_root_destroyed); | 398 &secondary_root_destroyed); |
399 ClientWindowId secondary_root_id = | 399 ClientWindowId secondary_root_id = |
400 ClientWindowIdForWindow(tree, secondary_root); | 400 ClientWindowIdForWindow(tree, secondary_root); |
401 TestWindowTreeClient* tree_client = | 401 TestWindowTreeClient* tree_client = |
402 static_cast<TestWindowTreeClient*>(tree->client()); | 402 static_cast<TestWindowTreeClient*>(tree->client()); |
403 tree_client->tracker()->changes()->clear(); | 403 tree_client->tracker()->changes()->clear(); |
404 TestWindowManager* test_window_manager = | 404 TestWindowManager* test_window_manager = |
405 window_server_delegate()->last_binding()->window_manager(); | 405 window_server_delegate()->last_binding()->window_manager(); |
406 EXPECT_FALSE(test_window_manager->got_display_removed()); | 406 EXPECT_FALSE(test_window_manager->got_display_removed()); |
407 platform_screen().RemoveDisplay(secondary_display_id); | 407 screen_manager().RemoveDisplay(secondary_display_id); |
408 | 408 |
409 // Destroying the display should result in the following: | 409 // Destroying the display should result in the following: |
410 // . The WindowManager should be told it was removed with the right id. | 410 // . The WindowManager should be told it was removed with the right id. |
411 EXPECT_TRUE(test_window_manager->got_display_removed()); | 411 EXPECT_TRUE(test_window_manager->got_display_removed()); |
412 EXPECT_EQ(secondary_display_id, test_window_manager->display_removed_id()); | 412 EXPECT_EQ(secondary_display_id, test_window_manager->display_removed_id()); |
413 EXPECT_FALSE(secondary_root_destroyed); | 413 EXPECT_FALSE(secondary_root_destroyed); |
414 // The window should still be valid on the server side. | 414 // The window should still be valid on the server side. |
415 ASSERT_TRUE(tree->GetWindowByClientId(secondary_root_id)); | 415 ASSERT_TRUE(tree->GetWindowByClientId(secondary_root_id)); |
416 // No changes. | 416 // No changes. |
417 ASSERT_EQ(0u, tree_client->tracker()->changes()->size()); | 417 ASSERT_EQ(0u, tree_client->tracker()->changes()->size()); |
418 | 418 |
419 // The window should be destroyed when the client says so. | 419 // The window should be destroyed when the client says so. |
420 ASSERT_TRUE(tree->DeleteWindow(secondary_root_id)); | 420 ASSERT_TRUE(tree->DeleteWindow(secondary_root_id)); |
421 EXPECT_TRUE(secondary_root_destroyed); | 421 EXPECT_TRUE(secondary_root_destroyed); |
422 } | 422 } |
423 | 423 |
424 } // namespace test | 424 } // namespace test |
425 } // namespace ws | 425 } // namespace ws |
426 } // namespace ui | 426 } // namespace ui |
OLD | NEW |