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

Unified Diff: services/ui/ws/window_manager_state_unittest.cc

Issue 2365243003: Fixes possible crash in ~Display (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/window_manager_state.cc ('k') | services/ui/ws/window_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/window_manager_state_unittest.cc
diff --git a/services/ui/ws/window_manager_state_unittest.cc b/services/ui/ws/window_manager_state_unittest.cc
index a4c685aa9f4d8166e3394f29c47af41f599ee7ff..4bea43dad7b5da67a20c8a178eb8c8b45f78a41e 100644
--- a/services/ui/ws/window_manager_state_unittest.cc
+++ b/services/ui/ws/window_manager_state_unittest.cc
@@ -17,6 +17,7 @@
#include "services/ui/ws/accelerator.h"
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_binding.h"
+#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/platform_display.h"
#include "services/ui/ws/platform_display_init_params.h"
#include "services/ui/ws/server_window_surface_manager_test_api.h"
@@ -543,6 +544,30 @@ TEST_F(WindowManagerStateTest, PostAcceleratorForgotten) {
EXPECT_FALSE(window_manager()->on_accelerator_called());
}
+// Verifies there is no crash if the WindowTree of a window manager is destroyed
+// with no roots.
+TEST(WindowManagerStateShutdownTest, DestroyTreeBeforeDisplay) {
+ WindowServerTestHelper ws_test_helper;
+ ws_test_helper.window_server_delegate()->set_num_displays_to_create(1);
+ WindowServer* window_server = ws_test_helper.window_server();
+ const UserId kUserId1 = "2";
+ WindowManagerWindowTreeFactorySetTestApi(
+ window_server->window_manager_window_tree_factory_set())
+ .Add(kUserId1);
+ ASSERT_EQ(1u, window_server->display_manager()->displays().size());
+ Display* display = *(window_server->display_manager()->displays().begin());
+ WindowManagerDisplayRoot* window_manager_display_root =
+ display->GetWindowManagerDisplayRootForUser(kUserId1);
+ ASSERT_TRUE(window_manager_display_root);
+ WindowTree* tree =
+ window_manager_display_root->window_manager_state()->window_tree();
+ ASSERT_EQ(1u, tree->roots().size());
+ ClientWindowId root_client_id;
+ ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id));
+ EXPECT_TRUE(tree->DeleteWindow(root_client_id));
+ window_server->DestroyTree(tree);
+}
+
} // namespace test
} // namespace ws
} // namespace ui
« no previous file with comments | « services/ui/ws/window_manager_state.cc ('k') | services/ui/ws/window_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698