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

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

Issue 2717333002: %s/num_window_manger_states/num_window_manager_states/g (Closed)
Patch Set: Created 3 years, 9 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/display.h ('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 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 screen_manager().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f)); 126 screen_manager().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f));
127 127
128 ASSERT_EQ(1u, display_manager()->displays().size()); 128 ASSERT_EQ(1u, display_manager()->displays().size());
129 Display* display = display_manager()->GetDisplayById(display_id); 129 Display* display = display_manager()->GetDisplayById(display_id);
130 130
131 // Display should have root window with correct size. 131 // Display should have root window with correct size.
132 ASSERT_NE(nullptr, display->root_window()); 132 ASSERT_NE(nullptr, display->root_window());
133 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); 133 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString());
134 134
135 // Display should have a WM root window with the correct size too. 135 // Display should have a WM root window with the correct size too.
136 EXPECT_EQ(1u, display->num_window_manger_states()); 136 EXPECT_EQ(1u, display->num_window_manager_states());
137 WindowManagerDisplayRoot* root1 = 137 WindowManagerDisplayRoot* root1 =
138 display->GetWindowManagerDisplayRootForUser(kTestId1); 138 display->GetWindowManagerDisplayRootForUser(kTestId1);
139 ASSERT_NE(nullptr, root1); 139 ASSERT_NE(nullptr, root1);
140 ASSERT_NE(nullptr, root1->root()); 140 ASSERT_NE(nullptr, root1->root());
141 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString()); 141 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString());
142 } 142 }
143 143
144 TEST_F(DisplayTest, CreateDisplayBeforeWM) { 144 TEST_F(DisplayTest, CreateDisplayBeforeWM) {
145 // Add one display, no WM exists yet. 145 // Add one display, no WM exists yet.
146 const int64_t display_id = 146 const int64_t display_id =
147 screen_manager().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f)); 147 screen_manager().AddDisplay(MakeViewportMetrics(0, 0, 1024, 768, 1.0f));
148 EXPECT_EQ(1u, display_manager()->displays().size()); 148 EXPECT_EQ(1u, display_manager()->displays().size());
149 149
150 Display* display = display_manager()->GetDisplayById(display_id); 150 Display* display = display_manager()->GetDisplayById(display_id);
151 151
152 // Display should have root window with correct size. 152 // Display should have root window with correct size.
153 ASSERT_NE(nullptr, display->root_window()); 153 ASSERT_NE(nullptr, display->root_window());
154 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString()); 154 EXPECT_EQ("0,0 1024x768", display->root_window()->bounds().ToString());
155 155
156 // There should be no WM state for display yet. 156 // There should be no WM state for display yet.
157 EXPECT_EQ(0u, display->num_window_manger_states()); 157 EXPECT_EQ(0u, display->num_window_manager_states());
158 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1)); 158 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1));
159 159
160 AddWindowManager(window_server(), kTestId1); 160 AddWindowManager(window_server(), kTestId1);
161 161
162 // After adding a WM display should have WM state and WM root for the display. 162 // After adding a WM display should have WM state and WM root for the display.
163 EXPECT_EQ(1u, display->num_window_manger_states()); 163 EXPECT_EQ(1u, display->num_window_manager_states());
164 WindowManagerDisplayRoot* root1 = 164 WindowManagerDisplayRoot* root1 =
165 display->GetWindowManagerDisplayRootForUser(kTestId1); 165 display->GetWindowManagerDisplayRootForUser(kTestId1);
166 ASSERT_NE(nullptr, root1); 166 ASSERT_NE(nullptr, root1);
167 ASSERT_NE(nullptr, root1->root()); 167 ASSERT_NE(nullptr, root1->root());
168 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString()); 168 EXPECT_EQ("0,0 1024x768", root1->root()->bounds().ToString());
169 } 169 }
170 170
171 TEST_F(DisplayTest, CreateDisplayWithTwoWindowManagers) { 171 TEST_F(DisplayTest, CreateDisplayWithTwoWindowManagers) {
172 AddWindowManager(window_server(), kTestId1); 172 AddWindowManager(window_server(), kTestId1);
173 const int64_t display_id = screen_manager().AddDisplay(); 173 const int64_t display_id = screen_manager().AddDisplay();
174 Display* display = display_manager()->GetDisplayById(display_id); 174 Display* display = display_manager()->GetDisplayById(display_id);
175 175
176 // There should be only be one WM at this point. 176 // There should be only be one WM at this point.
177 ASSERT_EQ(1u, display->num_window_manger_states()); 177 ASSERT_EQ(1u, display->num_window_manager_states());
178 EXPECT_NE(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1)); 178 EXPECT_NE(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId1));
179 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId2)); 179 EXPECT_EQ(nullptr, display->GetWindowManagerDisplayRootForUser(kTestId2));
180 180
181 AddWindowManager(window_server(), kTestId2); 181 AddWindowManager(window_server(), kTestId2);
182 182
183 // There should now be two WMs. 183 // There should now be two WMs.
184 ASSERT_EQ(2u, display->num_window_manger_states()); 184 ASSERT_EQ(2u, display->num_window_manager_states());
185 WindowManagerDisplayRoot* root1 = 185 WindowManagerDisplayRoot* root1 =
186 display->GetWindowManagerDisplayRootForUser(kTestId1); 186 display->GetWindowManagerDisplayRootForUser(kTestId1);
187 ASSERT_NE(nullptr, root1); 187 ASSERT_NE(nullptr, root1);
188 WindowManagerDisplayRoot* root2 = 188 WindowManagerDisplayRoot* root2 =
189 display->GetWindowManagerDisplayRootForUser(kTestId2); 189 display->GetWindowManagerDisplayRootForUser(kTestId2);
190 ASSERT_NE(nullptr, root2); 190 ASSERT_NE(nullptr, root2);
191 191
192 // Verify the two WMs have different roots but with the same bounds. 192 // Verify the two WMs have different roots but with the same bounds.
193 EXPECT_NE(root1, root2); 193 EXPECT_NE(root1, root2);
194 EXPECT_NE(root1->root(), root2->root()); 194 EXPECT_NE(root1->root(), root2->root());
(...skipping 22 matching lines...) Expand all
217 217
218 TEST_F(DisplayTest, Destruction) { 218 TEST_F(DisplayTest, Destruction) {
219 AddWindowManager(window_server(), kTestId1); 219 AddWindowManager(window_server(), kTestId1);
220 220
221 int64_t display_id = screen_manager().AddDisplay(); 221 int64_t display_id = screen_manager().AddDisplay();
222 222
223 // Add a second WM. 223 // Add a second WM.
224 AddWindowManager(window_server(), kTestId2); 224 AddWindowManager(window_server(), kTestId2);
225 ASSERT_EQ(1u, display_manager()->displays().size()); 225 ASSERT_EQ(1u, display_manager()->displays().size());
226 Display* display = display_manager()->GetDisplayById(display_id); 226 Display* display = display_manager()->GetDisplayById(display_id);
227 ASSERT_EQ(2u, display->num_window_manger_states()); 227 ASSERT_EQ(2u, display->num_window_manager_states());
228 // There should be two trees, one for each windowmanager. 228 // There should be two trees, one for each windowmanager.
229 EXPECT_EQ(2u, window_server()->num_trees()); 229 EXPECT_EQ(2u, window_server()->num_trees());
230 230
231 { 231 {
232 WindowManagerState* state = GetWindowManagerStateForUser(display, kTestId1); 232 WindowManagerState* state = GetWindowManagerStateForUser(display, kTestId1);
233 // Destroy the tree associated with |state|. Should result in deleting 233 // Destroy the tree associated with |state|. Should result in deleting
234 // |state|. 234 // |state|.
235 window_server()->DestroyTree(state->window_tree()); 235 window_server()->DestroyTree(state->window_tree());
236 ASSERT_EQ(1u, display->num_window_manger_states()); 236 ASSERT_EQ(1u, display->num_window_manager_states());
237 EXPECT_FALSE(GetWindowManagerStateForUser(display, kTestId1)); 237 EXPECT_FALSE(GetWindowManagerStateForUser(display, kTestId1));
238 EXPECT_EQ(1u, display_manager()->displays().size()); 238 EXPECT_EQ(1u, display_manager()->displays().size());
239 EXPECT_EQ(1u, window_server()->num_trees()); 239 EXPECT_EQ(1u, window_server()->num_trees());
240 } 240 }
241 241
242 EXPECT_FALSE(window_server_delegate()->got_on_no_more_displays()); 242 EXPECT_FALSE(window_server_delegate()->got_on_no_more_displays());
243 screen_manager().RemoveDisplay(display_id); 243 screen_manager().RemoveDisplay(display_id);
244 // There is still one tree left. 244 // There is still one tree left.
245 EXPECT_EQ(1u, window_server()->num_trees()); 245 EXPECT_EQ(1u, window_server()->num_trees());
246 EXPECT_TRUE(window_server_delegate()->got_on_no_more_displays()); 246 EXPECT_TRUE(window_server_delegate()->got_on_no_more_displays());
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 ASSERT_EQ(0u, tree_client->tracker()->changes()->size()); 417 ASSERT_EQ(0u, tree_client->tracker()->changes()->size());
418 418
419 // The window should be destroyed when the client says so. 419 // The window should be destroyed when the client says so.
420 ASSERT_TRUE(tree->DeleteWindow(secondary_root_id)); 420 ASSERT_TRUE(tree->DeleteWindow(secondary_root_id));
421 EXPECT_TRUE(secondary_root_destroyed); 421 EXPECT_TRUE(secondary_root_destroyed);
422 } 422 }
423 423
424 } // namespace test 424 } // namespace test
425 } // namespace ws 425 } // namespace ws
426 } // namespace ui 426 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698