| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 window_server()->user_id_tracker()->AddUserId(kTestId2); | 70 window_server()->user_id_tracker()->AddUserId(kTestId2); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 WindowServerTestHelper ws_test_helper_; | 74 WindowServerTestHelper ws_test_helper_; |
| 75 DISALLOW_COPY_AND_ASSIGN(DisplayTest); | 75 DISALLOW_COPY_AND_ASSIGN(DisplayTest); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 TEST_F(DisplayTest, CallsCreateDefaultDisplays) { | 78 TEST_F(DisplayTest, CallsCreateDefaultDisplays) { |
| 79 const int kNumHostsToCreate = 2; | 79 const int kNumHostsToCreate = 2; |
| 80 window_server_delegate()->set_num_displays_to_create(kNumHostsToCreate); | 80 window_server_delegate()->CreateDisplays(kNumHostsToCreate); |
| 81 | 81 |
| 82 DisplayManager* display_manager = window_server()->display_manager(); | 82 DisplayManager* display_manager = window_server()->display_manager(); |
| 83 WindowManagerWindowTreeFactorySetTestApi( | 83 WindowManagerWindowTreeFactorySetTestApi( |
| 84 window_server()->window_manager_window_tree_factory_set()) | 84 window_server()->window_manager_window_tree_factory_set()) |
| 85 .Add(kTestId1); | 85 .Add(kTestId1); |
| 86 // The first register should trigger creation of the default | 86 // The first register should trigger creation of the default |
| 87 // Displays. There should be kNumHostsToCreate Displays. | 87 // Displays. There should be kNumHostsToCreate Displays. |
| 88 EXPECT_EQ(static_cast<size_t>(kNumHostsToCreate), | 88 EXPECT_EQ(static_cast<size_t>(kNumHostsToCreate), |
| 89 display_manager->displays().size()); | 89 display_manager->displays().size()); |
| 90 | 90 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 107 WindowManagerDisplayRoot* root2 = | 107 WindowManagerDisplayRoot* root2 = |
| 108 display->GetWindowManagerDisplayRootForUser(kTestId2); | 108 display->GetWindowManagerDisplayRootForUser(kTestId2); |
| 109 ASSERT_TRUE(root2); | 109 ASSERT_TRUE(root2); |
| 110 // Verify the two states have different roots. | 110 // Verify the two states have different roots. |
| 111 EXPECT_NE(root1, root2); | 111 EXPECT_NE(root1, root2); |
| 112 EXPECT_NE(root1->root(), root2->root()); | 112 EXPECT_NE(root1->root(), root2->root()); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 TEST_F(DisplayTest, Destruction) { | 116 TEST_F(DisplayTest, Destruction) { |
| 117 window_server_delegate()->set_num_displays_to_create(1); | 117 window_server_delegate()->CreateDisplays(1); |
| 118 | 118 |
| 119 WindowManagerWindowTreeFactorySetTestApi( | 119 WindowManagerWindowTreeFactorySetTestApi( |
| 120 window_server()->window_manager_window_tree_factory_set()) | 120 window_server()->window_manager_window_tree_factory_set()) |
| 121 .Add(kTestId1); | 121 .Add(kTestId1); |
| 122 | 122 |
| 123 // Add another registry, should trigger creation of another wm. | 123 // Add another registry, should trigger creation of another wm. |
| 124 DisplayManager* display_manager = window_server()->display_manager(); | 124 DisplayManager* display_manager = window_server()->display_manager(); |
| 125 WindowManagerWindowTreeFactorySetTestApi( | 125 WindowManagerWindowTreeFactorySetTestApi( |
| 126 window_server()->window_manager_window_tree_factory_set()) | 126 window_server()->window_manager_window_tree_factory_set()) |
| 127 .Add(kTestId2); | 127 .Add(kTestId2); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 EXPECT_FALSE(window_server_delegate()->got_on_no_more_displays()); | 145 EXPECT_FALSE(window_server_delegate()->got_on_no_more_displays()); |
| 146 window_server()->display_manager()->DestroyDisplay(display); | 146 window_server()->display_manager()->DestroyDisplay(display); |
| 147 // There is still one tree left. | 147 // There is still one tree left. |
| 148 EXPECT_EQ(1u, window_server()->num_trees()); | 148 EXPECT_EQ(1u, window_server()->num_trees()); |
| 149 EXPECT_TRUE(window_server_delegate()->got_on_no_more_displays()); | 149 EXPECT_TRUE(window_server_delegate()->got_on_no_more_displays()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_F(DisplayTest, EventStateResetOnUserSwitch) { | 152 TEST_F(DisplayTest, EventStateResetOnUserSwitch) { |
| 153 window_server_delegate()->set_num_displays_to_create(1); | 153 window_server_delegate()->CreateDisplays(1); |
| 154 | 154 |
| 155 WindowManagerWindowTreeFactorySetTestApi( | 155 WindowManagerWindowTreeFactorySetTestApi( |
| 156 window_server()->window_manager_window_tree_factory_set()) | 156 window_server()->window_manager_window_tree_factory_set()) |
| 157 .Add(kTestId1); | 157 .Add(kTestId1); |
| 158 WindowManagerWindowTreeFactorySetTestApi( | 158 WindowManagerWindowTreeFactorySetTestApi( |
| 159 window_server()->window_manager_window_tree_factory_set()) | 159 window_server()->window_manager_window_tree_factory_set()) |
| 160 .Add(kTestId2); | 160 .Add(kTestId2); |
| 161 | 161 |
| 162 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 162 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
| 163 | 163 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 191 display->GetActiveWindowManagerDisplayRoot()->window_manager_state(); | 191 display->GetActiveWindowManagerDisplayRoot()->window_manager_state(); |
| 192 EXPECT_EQ(kTestId2, active_wms->user_id()); | 192 EXPECT_EQ(kTestId2, active_wms->user_id()); |
| 193 EXPECT_EQ(gfx::Point(20, 25), | 193 EXPECT_EQ(gfx::Point(20, 25), |
| 194 active_wms->event_dispatcher()->mouse_pointer_last_location()); | 194 active_wms->event_dispatcher()->mouse_pointer_last_location()); |
| 195 EXPECT_FALSE(EventDispatcherTestApi(active_wms->event_dispatcher()) | 195 EXPECT_FALSE(EventDispatcherTestApi(active_wms->event_dispatcher()) |
| 196 .AreAnyPointersDown()); | 196 .AreAnyPointersDown()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Verifies capture fails when wm is inactive and succeeds when wm is active. | 199 // Verifies capture fails when wm is inactive and succeeds when wm is active. |
| 200 TEST_F(DisplayTest, SetCaptureFromWindowManager) { | 200 TEST_F(DisplayTest, SetCaptureFromWindowManager) { |
| 201 window_server_delegate()->set_num_displays_to_create(1); | 201 window_server_delegate()->CreateDisplays(1); |
| 202 WindowManagerWindowTreeFactorySetTestApi( | 202 WindowManagerWindowTreeFactorySetTestApi( |
| 203 window_server()->window_manager_window_tree_factory_set()) | 203 window_server()->window_manager_window_tree_factory_set()) |
| 204 .Add(kTestId1); | 204 .Add(kTestId1); |
| 205 WindowManagerWindowTreeFactorySetTestApi( | 205 WindowManagerWindowTreeFactorySetTestApi( |
| 206 window_server()->window_manager_window_tree_factory_set()) | 206 window_server()->window_manager_window_tree_factory_set()) |
| 207 .Add(kTestId2); | 207 .Add(kTestId2); |
| 208 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 208 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
| 209 DisplayManager* display_manager = window_server()->display_manager(); | 209 DisplayManager* display_manager = window_server()->display_manager(); |
| 210 ASSERT_EQ(1u, display_manager->displays().size()); | 210 ASSERT_EQ(1u, display_manager->displays().size()); |
| 211 Display* display = *display_manager->displays().begin(); | 211 Display* display = *display_manager->displays().begin(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 224 // SetCapture() should fail for user id2 as it is inactive. | 224 // SetCapture() should fail for user id2 as it is inactive. |
| 225 EXPECT_FALSE(tree->SetCapture(child_window_id)); | 225 EXPECT_FALSE(tree->SetCapture(child_window_id)); |
| 226 | 226 |
| 227 // Make the second user active and verify capture works. | 227 // Make the second user active and verify capture works. |
| 228 window_server()->user_id_tracker()->SetActiveUserId(kTestId2); | 228 window_server()->user_id_tracker()->SetActiveUserId(kTestId2); |
| 229 EXPECT_TRUE(wms_for_id2->IsActive()); | 229 EXPECT_TRUE(wms_for_id2->IsActive()); |
| 230 EXPECT_TRUE(tree->SetCapture(child_window_id)); | 230 EXPECT_TRUE(tree->SetCapture(child_window_id)); |
| 231 } | 231 } |
| 232 | 232 |
| 233 TEST_F(DisplayTest, FocusFailsForInactiveUser) { | 233 TEST_F(DisplayTest, FocusFailsForInactiveUser) { |
| 234 window_server_delegate()->set_num_displays_to_create(1); | 234 window_server_delegate()->CreateDisplays(1); |
| 235 WindowManagerWindowTreeFactorySetTestApi( | 235 WindowManagerWindowTreeFactorySetTestApi( |
| 236 window_server()->window_manager_window_tree_factory_set()) | 236 window_server()->window_manager_window_tree_factory_set()) |
| 237 .Add(kTestId1); | 237 .Add(kTestId1); |
| 238 TestWindowTreeClient* window_tree_client1 = | 238 TestWindowTreeClient* window_tree_client1 = |
| 239 window_server_delegate()->last_client(); | 239 window_server_delegate()->last_client(); |
| 240 ASSERT_TRUE(window_tree_client1); | 240 ASSERT_TRUE(window_tree_client1); |
| 241 WindowManagerWindowTreeFactorySetTestApi( | 241 WindowManagerWindowTreeFactorySetTestApi( |
| 242 window_server()->window_manager_window_tree_factory_set()) | 242 window_server()->window_manager_window_tree_factory_set()) |
| 243 .Add(kTestId2); | 243 .Add(kTestId2); |
| 244 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 244 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 264 wms_for_id1->window_tree()->AddActivationParent( | 264 wms_for_id1->window_tree()->AddActivationParent( |
| 265 ClientWindowIdForFirstRoot(wms_for_id1->window_tree())); | 265 ClientWindowIdForFirstRoot(wms_for_id1->window_tree())); |
| 266 ClientWindowId child1_id; | 266 ClientWindowId child1_id; |
| 267 NewWindowInTree(wms_for_id1->window_tree(), &child1_id); | 267 NewWindowInTree(wms_for_id1->window_tree(), &child1_id); |
| 268 EXPECT_TRUE(wms_for_id1->IsActive()); | 268 EXPECT_TRUE(wms_for_id1->IsActive()); |
| 269 EXPECT_TRUE(wms_for_id1->window_tree()->SetFocus(child1_id)); | 269 EXPECT_TRUE(wms_for_id1->window_tree()->SetFocus(child1_id)); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Verifies a single tree is used for multiple displays. | 272 // Verifies a single tree is used for multiple displays. |
| 273 TEST_F(DisplayTest, MultipleDisplays) { | 273 TEST_F(DisplayTest, MultipleDisplays) { |
| 274 window_server_delegate()->set_num_displays_to_create(2); | 274 window_server_delegate()->CreateDisplays(2); |
| 275 WindowManagerWindowTreeFactorySetTestApi( | 275 WindowManagerWindowTreeFactorySetTestApi( |
| 276 window_server()->window_manager_window_tree_factory_set()) | 276 window_server()->window_manager_window_tree_factory_set()) |
| 277 .Add(kTestId1); | 277 .Add(kTestId1); |
| 278 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 278 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
| 279 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); | 279 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); |
| 280 TestWindowTreeBinding* window_tree_binding = | 280 TestWindowTreeBinding* window_tree_binding = |
| 281 (*window_server_delegate()->bindings())[0]; | 281 (*window_server_delegate()->bindings())[0]; |
| 282 WindowTree* tree = window_tree_binding->tree(); | 282 WindowTree* tree = window_tree_binding->tree(); |
| 283 ASSERT_EQ(2u, tree->roots().size()); | 283 ASSERT_EQ(2u, tree->roots().size()); |
| 284 std::set<const ServerWindow*> roots = tree->roots(); | 284 std::set<const ServerWindow*> roots = tree->roots(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 ServerWindow* window_; | 342 ServerWindow* window_; |
| 343 bool* destroyed_; | 343 bool* destroyed_; |
| 344 | 344 |
| 345 DISALLOW_COPY_AND_ASSIGN(ServerWindowDestructionObserver); | 345 DISALLOW_COPY_AND_ASSIGN(ServerWindowDestructionObserver); |
| 346 }; | 346 }; |
| 347 | 347 |
| 348 } // namespace | 348 } // namespace |
| 349 | 349 |
| 350 // Assertions around destroying a secondary display. | 350 // Assertions around destroying a secondary display. |
| 351 TEST_F(DisplayTest, DestroyingDisplayDoesntDelete) { | 351 TEST_F(DisplayTest, DestroyingDisplayDoesntDelete) { |
| 352 window_server_delegate()->set_num_displays_to_create(2); | 352 window_server_delegate()->CreateDisplays(2); |
| 353 WindowManagerWindowTreeFactorySetTestApi( | 353 WindowManagerWindowTreeFactorySetTestApi( |
| 354 window_server()->window_manager_window_tree_factory_set()) | 354 window_server()->window_manager_window_tree_factory_set()) |
| 355 .Add(kTestId1); | 355 .Add(kTestId1); |
| 356 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); | 356 window_server()->user_id_tracker()->SetActiveUserId(kTestId1); |
| 357 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); | 357 ASSERT_EQ(1u, window_server_delegate()->bindings()->size()); |
| 358 WindowTree* tree = (*window_server_delegate()->bindings())[0]->tree(); | 358 WindowTree* tree = (*window_server_delegate()->bindings())[0]->tree(); |
| 359 ASSERT_EQ(2u, tree->roots().size()); | 359 ASSERT_EQ(2u, tree->roots().size()); |
| 360 Display* secondary_display = | 360 Display* secondary_display = |
| 361 GetSecondaryDisplay(window_server()->display_manager()); | 361 GetSecondaryDisplay(window_server()->display_manager()); |
| 362 ASSERT_TRUE(secondary_display); | 362 ASSERT_TRUE(secondary_display); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 387 ASSERT_EQ(0u, tree_client->tracker()->changes()->size()); | 387 ASSERT_EQ(0u, tree_client->tracker()->changes()->size()); |
| 388 | 388 |
| 389 // The window should be destroyed when the client says so. | 389 // The window should be destroyed when the client says so. |
| 390 ASSERT_TRUE(tree->DeleteWindow(secondary_root_id)); | 390 ASSERT_TRUE(tree->DeleteWindow(secondary_root_id)); |
| 391 EXPECT_TRUE(secondary_root_destroyed); | 391 EXPECT_TRUE(secondary_root_destroyed); |
| 392 } | 392 } |
| 393 | 393 |
| 394 } // namespace test | 394 } // namespace test |
| 395 } // namespace ws | 395 } // namespace ws |
| 396 } // namespace ui | 396 } // namespace ui |
| OLD | NEW |