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

Side by Side Diff: services/ui/ws/window_tree_unittest.cc

Issue 2352893002: Makes windowserver not send messages during shutdown (Closed)
Patch Set: merge 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 unified diff | Download patch
« no previous file with comments | « services/ui/ws/window_tree_binding.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_tree.h" 5 #include "services/ui/ws/window_tree.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 25 matching lines...) Expand all
36 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
37 #include "ui/events/event.h" 37 #include "ui/events/event.h"
38 #include "ui/events/event_utils.h" 38 #include "ui/events/event_utils.h"
39 #include "ui/gfx/geometry/rect.h" 39 #include "ui/gfx/geometry/rect.h"
40 40
41 namespace ui { 41 namespace ui {
42 namespace ws { 42 namespace ws {
43 namespace test { 43 namespace test {
44 namespace { 44 namespace {
45 45
46 const UserId kTestUserId1 = "2";
47
46 std::string WindowIdToString(const WindowId& id) { 48 std::string WindowIdToString(const WindowId& id) {
47 return base::StringPrintf("%d,%d", id.client_id, id.window_id); 49 return base::StringPrintf("%d,%d", id.client_id, id.window_id);
48 } 50 }
49 51
50 std::string ClientWindowIdToString(const ClientWindowId& id) { 52 std::string ClientWindowIdToString(const ClientWindowId& id) {
51 return WindowIdToString(WindowIdFromTransportId(id.id)); 53 return WindowIdToString(WindowIdFromTransportId(id.id));
52 } 54 }
53 55
54 ClientWindowId BuildClientWindowId(WindowTree* tree, 56 ClientWindowId BuildClientWindowId(WindowTree* tree,
55 ClientSpecificId window_id) { 57 ClientSpecificId window_id) {
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 1341
1340 // Set capture from server and ensure embedded tree notified. 1342 // Set capture from server and ensure embedded tree notified.
1341 EXPECT_TRUE(owning_tree->ReleaseCapture( 1343 EXPECT_TRUE(owning_tree->ReleaseCapture(
1342 ClientWindowIdForWindow(owning_tree, FirstRoot(embed_tree)))); 1344 ClientWindowIdForWindow(owning_tree, FirstRoot(embed_tree))));
1343 EXPECT_TRUE(wm_client()->tracker()->changes()->empty()); 1345 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
1344 ASSERT_TRUE(!embed_client->tracker()->changes()->empty()); 1346 ASSERT_TRUE(!embed_client->tracker()->changes()->empty());
1345 EXPECT_EQ("OnCaptureChanged new_window=null old_window=1,1", 1347 EXPECT_EQ("OnCaptureChanged new_window=null old_window=1,1",
1346 ChangesToDescription1(*embed_client->tracker()->changes())[0]); 1348 ChangesToDescription1(*embed_client->tracker()->changes())[0]);
1347 } 1349 }
1348 1350
1351 using WindowTreeShutdownTest = testing::Test;
1352
1353 // Makes sure WindowTreeClient doesn't get any messages during shutdown.
1354 TEST_F(WindowTreeShutdownTest, DontSendMessagesDuringShutdown) {
1355 std::unique_ptr<TestWindowTreeClient> client;
1356 {
1357 // Create a tree with one window.
1358 WindowServerTestHelper ws_test_helper;
1359 WindowServer* window_server = ws_test_helper.window_server();
1360 window_server->user_id_tracker()->AddUserId(kTestUserId1);
1361 const int kNumHostsToCreate = 1;
1362 ws_test_helper.window_server_delegate()->set_num_displays_to_create(
1363 kNumHostsToCreate);
1364
1365 WindowManagerWindowTreeFactorySetTestApi(
1366 window_server->window_manager_window_tree_factory_set())
1367 .Add(kTestUserId1);
1368 window_server->user_id_tracker()->SetActiveUserId(kTestUserId1);
1369 TestWindowTreeBinding* test_binding =
1370 ws_test_helper.window_server_delegate()->last_binding();
1371 ASSERT_TRUE(test_binding);
1372 WindowTree* tree = test_binding->tree();
1373 const ClientWindowId window_id = BuildClientWindowId(tree, 2);
1374 ASSERT_TRUE(tree->NewWindow(window_id, ServerWindow::Properties()));
1375
1376 // Release the client so that it survices shutdown.
1377 client = test_binding->ReleaseClient();
1378 client->tracker()->changes()->clear();
1379 }
1380
1381 // Client should not have got any messages after shutdown.
1382 EXPECT_TRUE(client->tracker()->changes()->empty());
1383 }
1384
1349 } // namespace test 1385 } // namespace test
1350 } // namespace ws 1386 } // namespace ws
1351 } // namespace ui 1387 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree_binding.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698