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

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

Issue 2349003002: Makes WindowTree::DeleteWindow() unembed for roots (Closed)
Patch Set: comment 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.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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
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 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 changes2()->clear(); 1123 changes2()->clear();
1124 ASSERT_TRUE(wt_client2()->DeleteWindow(window_2_1)); 1124 ASSERT_TRUE(wt_client2()->DeleteWindow(window_2_1));
1125 EXPECT_TRUE(changes2()->empty()); 1125 EXPECT_TRUE(changes2()->empty());
1126 1126
1127 wt_client1_->WaitForChangeCount(1); 1127 wt_client1_->WaitForChangeCount(1);
1128 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1), 1128 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1),
1129 SingleChangeToDescription(*changes1())); 1129 SingleChangeToDescription(*changes1()));
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 // Verifies DeleteWindow() on the root suceeds.
1134 TEST_F(WindowTreeClientTest, DeleteRoot) {
1135 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true));
1136 Id window_1_1 = BuildWindowId(client_id_1(), 1);
1137 EXPECT_TRUE(wt_client2()->DeleteWindow(window_1_1));
1138 // Client1 should get OnEmbeddedAppDisconnected().
1139 wt_client1_->WaitForChangeCount(1);
1140 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_1_1),
1141 SingleChangeToDescription(*changes1()));
1142
1143 // Create a new window and try adding to |window_1_1| from client 2, should
1144 // fail as client 2 no longer knows about |window_1_1|.
1145 Id window_2_1 = wt_client2()->NewWindow(1);
1146 ASSERT_TRUE(window_2_1);
1147 EXPECT_FALSE(wt_client2()->AddWindow(window_1_1, window_2_1));
1148 }
1149
1150 // Verifies DeleteWindow() on the root suceeds.
1151 TEST_F(WindowTreeClientTest, DeleteRootWithChildren) {
1152 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true));
1153 Id window_1_1 = BuildWindowId(client_id_1(), 1);
1154 Id window_2_1 = wt_client2()->NewWindow(1);
1155 ASSERT_TRUE(window_2_1);
1156 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1157 changes2()->clear();
1158 EXPECT_TRUE(wt_client2()->DeleteWindow(window_1_1));
1159 // DeleteWindow() should not result in any calls to client 2.
1160 EXPECT_TRUE(changes2()->empty());
1161
1162 // Create a new window parented to 2_1. Should work as 2_1 is still valid.
1163 Id window_2_2 = wt_client2()->NewWindow(2);
1164 ASSERT_TRUE(window_2_2);
1165 ASSERT_TRUE(wt_client2()->AddWindow(window_2_1, window_2_2));
1166 }
1167
1133 // Verifies DeleteWindow isn't allowed from a separate client. 1168 // Verifies DeleteWindow isn't allowed from a separate client.
1134 TEST_F(WindowTreeClientTest, DeleteWindowFromAnotherClientDisallowed) { 1169 TEST_F(WindowTreeClientTest, DeleteWindowFromAnotherClientDisallowed) {
1135 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); 1170 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true));
1136 EXPECT_FALSE(wt_client2()->DeleteWindow(BuildWindowId(client_id_1(), 1))); 1171 // This id is unknown, so deletion should fail.
1172 EXPECT_FALSE(wt_client2()->DeleteWindow(BuildWindowId(client_id_1(), 2)));
1137 } 1173 }
1138 1174
1139 // Verifies if a window was deleted and then reused that other clients are 1175 // Verifies if a window was deleted and then reused that other clients are
1140 // properly notified. 1176 // properly notified.
1141 TEST_F(WindowTreeClientTest, ReuseDeletedWindowId) { 1177 TEST_F(WindowTreeClientTest, ReuseDeletedWindowId) {
1142 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); 1178 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true));
1143 Id window_1_1 = BuildWindowId(client_id_1(), 1); 1179 Id window_1_1 = BuildWindowId(client_id_1(), 1);
1144 Id window_2_1 = wt_client2()->NewWindow(1); 1180 Id window_2_1 = wt_client2()->NewWindow(1);
1145 ASSERT_TRUE(window_2_1); 1181 ASSERT_TRUE(window_2_1);
1146 1182
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 2110
2075 // TODO(sky): make sure coverage of what was 2111 // TODO(sky): make sure coverage of what was
2076 // WindowManagerTest.SecondEmbedRoot_InitService and 2112 // WindowManagerTest.SecondEmbedRoot_InitService and
2077 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 2113 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
2078 // manager 2114 // manager
2079 // tests. 2115 // tests.
2080 2116
2081 } // namespace test 2117 } // namespace test
2082 } // namespace ws 2118 } // namespace ws
2083 } // namespace ui 2119 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698