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 "services/ui/ws/window_manager_state.h" | 5 #include "services/ui/ws/window_manager_state.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "services/shell/public/interfaces/connector.mojom.h" | 14 #include "services/shell/public/interfaces/connector.mojom.h" |
15 #include "services/ui/common/event_matcher_util.h" | 15 #include "services/ui/common/event_matcher_util.h" |
16 #include "services/ui/surfaces/surfaces_state.h" | 16 #include "services/ui/surfaces/surfaces_state.h" |
17 #include "services/ui/ws/accelerator.h" | 17 #include "services/ui/ws/accelerator.h" |
18 #include "services/ui/ws/display.h" | 18 #include "services/ui/ws/display.h" |
19 #include "services/ui/ws/display_binding.h" | 19 #include "services/ui/ws/display_binding.h" |
| 20 #include "services/ui/ws/display_manager.h" |
20 #include "services/ui/ws/platform_display.h" | 21 #include "services/ui/ws/platform_display.h" |
21 #include "services/ui/ws/platform_display_init_params.h" | 22 #include "services/ui/ws/platform_display_init_params.h" |
22 #include "services/ui/ws/server_window_surface_manager_test_api.h" | 23 #include "services/ui/ws/server_window_surface_manager_test_api.h" |
23 #include "services/ui/ws/test_change_tracker.h" | 24 #include "services/ui/ws/test_change_tracker.h" |
24 #include "services/ui/ws/test_server_window_delegate.h" | 25 #include "services/ui/ws/test_server_window_delegate.h" |
25 #include "services/ui/ws/test_utils.h" | 26 #include "services/ui/ws/test_utils.h" |
26 #include "services/ui/ws/window_manager_access_policy.h" | 27 #include "services/ui/ws/window_manager_access_policy.h" |
27 #include "services/ui/ws/window_manager_display_root.h" | 28 #include "services/ui/ws/window_manager_display_root.h" |
28 #include "services/ui/ws/window_manager_state.h" | 29 #include "services/ui/ws/window_manager_state.h" |
29 #include "services/ui/ws/window_server.h" | 30 #include "services/ui/ws/window_server.h" |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 ui::KeyEvent non_accelerator_key(ui::ET_KEY_PRESSED, ui::VKEY_T, | 537 ui::KeyEvent non_accelerator_key(ui::ET_KEY_PRESSED, ui::VKEY_T, |
537 ui::EF_CONTROL_DOWN); | 538 ui::EF_CONTROL_DOWN); |
538 DispatchInputEventToWindow(target, non_accelerator_key, nullptr); | 539 DispatchInputEventToWindow(target, non_accelerator_key, nullptr); |
539 ASSERT_EQ(1u, tracker->changes()->size()); | 540 ASSERT_EQ(1u, tracker->changes()->size()); |
540 EXPECT_EQ("InputEvent window=1,1 event_action=7", | 541 EXPECT_EQ("InputEvent window=1,1 event_action=7", |
541 ChangesToDescription1(*tracker->changes())[0]); | 542 ChangesToDescription1(*tracker->changes())[0]); |
542 WindowTreeTestApi(window_tree()).AckLastEvent(mojom::EventResult::UNHANDLED); | 543 WindowTreeTestApi(window_tree()).AckLastEvent(mojom::EventResult::UNHANDLED); |
543 EXPECT_FALSE(window_manager()->on_accelerator_called()); | 544 EXPECT_FALSE(window_manager()->on_accelerator_called()); |
544 } | 545 } |
545 | 546 |
| 547 // Verifies there is no crash if the WindowTree of a window manager is destroyed |
| 548 // with no roots. |
| 549 TEST(WindowManagerStateShutdownTest, DestroyTreeBeforeDisplay) { |
| 550 WindowServerTestHelper ws_test_helper; |
| 551 ws_test_helper.window_server_delegate()->set_num_displays_to_create(1); |
| 552 WindowServer* window_server = ws_test_helper.window_server(); |
| 553 const UserId kUserId1 = "2"; |
| 554 WindowManagerWindowTreeFactorySetTestApi( |
| 555 window_server->window_manager_window_tree_factory_set()) |
| 556 .Add(kUserId1); |
| 557 ASSERT_EQ(1u, window_server->display_manager()->displays().size()); |
| 558 Display* display = *(window_server->display_manager()->displays().begin()); |
| 559 WindowManagerDisplayRoot* window_manager_display_root = |
| 560 display->GetWindowManagerDisplayRootForUser(kUserId1); |
| 561 ASSERT_TRUE(window_manager_display_root); |
| 562 WindowTree* tree = |
| 563 window_manager_display_root->window_manager_state()->window_tree(); |
| 564 ASSERT_EQ(1u, tree->roots().size()); |
| 565 ClientWindowId root_client_id; |
| 566 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id)); |
| 567 EXPECT_TRUE(tree->DeleteWindow(root_client_id)); |
| 568 window_server->DestroyTree(tree); |
| 569 } |
| 570 |
546 } // namespace test | 571 } // namespace test |
547 } // namespace ws | 572 } // namespace ws |
548 } // namespace ui | 573 } // namespace ui |
OLD | NEW |