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

Side by Side Diff: ash/common/devtools/ash_devtools_unittest.cc

Issue 2498593002: Revert of Fix bug where removed (but not deleted) windows are not reflected in the tree properly (Closed)
Patch Set: Created 4 years, 1 month 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 | « ash/common/devtools/ash_devtools_dom_agent.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 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 "ash/common/devtools/ash_devtools_dom_agent.h" 5 #include "ash/common/devtools/ash_devtools_dom_agent.h"
6 6
7 #include "ash/common/test/ash_test.h" 7 #include "ash/common/test/ash_test.h"
8 #include "ash/common/wm_lookup.h" 8 #include "ash/common/wm_lookup.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 218 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
219 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 219 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
220 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 220 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
221 221
222 Compare(parent_window, parent_node); 222 Compare(parent_window, parent_node);
223 Compare(child_window, child_node); 223 Compare(child_window, child_node);
224 child_window->Destroy(); 224 child_window->Destroy();
225 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 225 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
226 } 226 }
227 227
228 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { 228 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
229 // Initialize DOMAgent 229 // Initialize DOMAgent
230 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 230 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
231 dom_agent()->getDocument(&root); 231 dom_agent()->getDocument(&root);
232 232
233 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 233 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
234 WmWindow* target_window = root_window->GetChildren()[1]; 234 WmWindow* target_window = root_window->GetChildren()[1];
235 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; 235 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0];
236 236
237 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 237 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
238 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 238 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
239 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 239 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
240 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 240 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
241 DOM::Node* sibling_node = 241 DOM::Node* sibling_node =
242 target_node_children->get(target_node_children->length() - 1); 242 target_node_children->get(target_node_children->length() - 1);
243 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 243 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
244 244
245 Compare(target_window, target_node); 245 Compare(target_window, target_node);
246 Compare(child_window, child_node); 246 Compare(child_window, child_node);
247 target_window->AddChild(child_window); 247 target_window->AddChild(child_window);
248 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 248 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
249 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 249 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
250 } 250 }
251 251
252 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
253 // Initialize DOMAgent
254 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
255 dom_agent()->getDocument(&root);
256
257 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
258 WmWindow* target_window = root_window->GetChildren()[1];
259 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0];
260
261 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
262 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
263 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
264 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
265 DOM::Node* sibling_node =
266 target_node_children->get(target_node_children->length() - 1);
267 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
268
269 Compare(target_window, target_node);
270 Compare(child_window, child_node);
271 child_window->GetParent()->RemoveChild(child_window);
272 target_window->AddChild(child_window);
273 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
274 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
275 }
276
277 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { 252 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
278 // Initialize DOMAgent 253 // Initialize DOMAgent
279 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 254 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
280 dom_agent()->getDocument(&root); 255 dom_agent()->getDocument(&root);
281 256
282 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 257 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow();
283 WmWindow* child_window = parent_window->GetChildren()[0]; 258 WmWindow* child_window = parent_window->GetChildren()[0];
284 WmWindow* target_window = parent_window->GetChildren()[1]; 259 WmWindow* target_window = parent_window->GetChildren()[1];
285 260
286 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 261 DOM::Node* parent_node = root->getChildren(nullptr)->get(0);
287 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 262 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
288 DOM::Node* child_node = parent_node_children->get(0); 263 DOM::Node* child_node = parent_node_children->get(0);
289 DOM::Node* sibling_node = parent_node_children->get(1); 264 DOM::Node* sibling_node = parent_node_children->get(1);
290 int parent_id = parent_node->getNodeId(); 265 int parent_id = parent_node->getNodeId();
291 266
292 Compare(parent_window, parent_node); 267 Compare(parent_window, parent_node);
293 Compare(child_window, child_node); 268 Compare(child_window, child_node);
294 parent_window->StackChildAbove(child_window, target_window); 269 parent_window->StackChildAbove(child_window, target_window);
295 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); 270 ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
296 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); 271 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId());
297 } 272 }
298 273
299 } // namespace ash 274 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_dom_agent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698