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

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

Issue 2476353002: Fix bug where removed (but not deleted) windows are not reflected in the tree properly (Closed)
Patch Set: Remove old_parent parameter 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) {
229 // Initialize DOMAgent
230 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
231 dom_agent()->getDocument(&root);
232
233 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
234 WmWindow* target_window = root_window->GetChildren()[1];
235 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0];
236
237 DOM::Node* root_node = root->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);
240 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
241 DOM::Node* sibling_node =
242 target_node_children->get(target_node_children->length() - 1);
243 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
244
245 Compare(target_window, target_node);
246 Compare(child_window, child_node);
247 target_window->AddChild(child_window);
248 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
249 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
250 }
251
228 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { 252 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
229 // Initialize DOMAgent 253 // Initialize DOMAgent
230 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 254 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
231 dom_agent()->getDocument(&root); 255 dom_agent()->getDocument(&root);
232 256
233 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 257 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
234 WmWindow* target_window = root_window->GetChildren()[1]; 258 WmWindow* target_window = root_window->GetChildren()[1];
235 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; 259 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0];
236 260
237 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 261 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
238 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 262 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
239 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 263 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
240 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 264 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
241 DOM::Node* sibling_node = 265 DOM::Node* sibling_node =
242 target_node_children->get(target_node_children->length() - 1); 266 target_node_children->get(target_node_children->length() - 1);
243 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 267 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
244 268
245 Compare(target_window, target_node); 269 Compare(target_window, target_node);
246 Compare(child_window, child_node); 270 Compare(child_window, child_node);
271 child_window->GetParent()->RemoveChild(child_window);
sadrul 2016/11/10 20:25:24 Why is this necessary?
Sarmad Hashmi 2016/11/10 21:00:34 We know AddChild removes |window| from its old par
247 target_window->AddChild(child_window); 272 target_window->AddChild(child_window);
248 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 273 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
249 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 274 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
250 } 275 }
251 276
252 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { 277 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
253 // Initialize DOMAgent 278 // Initialize DOMAgent
254 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 279 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
255 dom_agent()->getDocument(&root); 280 dom_agent()->getDocument(&root);
256 281
257 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 282 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow();
258 WmWindow* child_window = parent_window->GetChildren()[0]; 283 WmWindow* child_window = parent_window->GetChildren()[0];
259 WmWindow* target_window = parent_window->GetChildren()[1]; 284 WmWindow* target_window = parent_window->GetChildren()[1];
260 285
261 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 286 DOM::Node* parent_node = root->getChildren(nullptr)->get(0);
262 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 287 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
263 DOM::Node* child_node = parent_node_children->get(0); 288 DOM::Node* child_node = parent_node_children->get(0);
264 DOM::Node* sibling_node = parent_node_children->get(1); 289 DOM::Node* sibling_node = parent_node_children->get(1);
265 int parent_id = parent_node->getNodeId(); 290 int parent_id = parent_node->getNodeId();
266 291
267 Compare(parent_window, parent_node); 292 Compare(parent_window, parent_node);
268 Compare(child_window, child_node); 293 Compare(child_window, child_node);
269 parent_window->StackChildAbove(child_window, target_window); 294 parent_window->StackChildAbove(child_window, target_window);
270 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); 295 ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
271 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); 296 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId());
272 } 297 }
273 298
274 } // namespace ash 299 } // 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