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

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

Issue 2495533005: Fix bug where removed (but not deleted) windows are not reflected in the tree properly (Closed)
Patch Set: Create new child instead of using existing child 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 219 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
220 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 220 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
221 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 221 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
222 222
223 Compare(parent_window, parent_node); 223 Compare(parent_window, parent_node);
224 Compare(child_window, child_node); 224 Compare(child_window, child_node);
225 child_window->Destroy(); 225 child_window->Destroy();
226 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 226 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
227 } 227 }
228 228
229 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { 229 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) {
230 // Initialize DOMAgent 230 // Initialize DOMAgent
231 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 231 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
232 dom_agent()->getDocument(&root); 232 dom_agent()->getDocument(&root);
233 233
234 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 234 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
235 WmWindow* target_window = root_window->GetChildren()[1]; 235 WmWindow* target_window = root_window->GetChildren()[1];
236 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; 236 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0];
237 237
238 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 238 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
239 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 239 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
240 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 240 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
241 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 241 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
242 DOM::Node* sibling_node = 242 DOM::Node* sibling_node =
243 target_node_children->get(target_node_children->length() - 1); 243 target_node_children->get(target_node_children->length() - 1);
244 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 244 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
245 245
246 Compare(target_window, target_node); 246 Compare(target_window, target_node);
247 Compare(child_window, child_node); 247 Compare(child_window, child_node);
248 target_window->AddChild(child_window); 248 target_window->AddChild(child_window);
249 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 249 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
250 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 250 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
251 } 251 }
252 252
253 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
254 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
255 WmWindow* target_window = root_window->GetChildren()[1];
256 WmWindow* parent_window = root_window->GetChildren()[0];
257 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
258 WmWindow* child_window = child_owner->window();
259
260 // Initialize DOMAgent
261 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
262 dom_agent()->getDocument(&root);
263 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
264
265 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
266 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
267 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
268 DOM::Node* sibling_node =
269 target_node_children->get(target_node_children->length() - 1);
270 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
271 DOM::Node* child_node =
272 parent_node_children->get(parent_node_children->length() - 1);
273
274 Compare(target_window, target_node);
275 Compare(child_window, child_node);
276 parent_window->RemoveChild(child_window);
277 target_window->AddChild(child_window);
278 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
279 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
280 }
281
253 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { 282 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
254 // Initialize DOMAgent 283 // Initialize DOMAgent
255 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 284 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
256 dom_agent()->getDocument(&root); 285 dom_agent()->getDocument(&root);
257 286
258 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 287 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow();
259 WmWindow* child_window = parent_window->GetChildren()[0]; 288 WmWindow* child_window = parent_window->GetChildren()[0];
260 WmWindow* target_window = parent_window->GetChildren()[1]; 289 WmWindow* target_window = parent_window->GetChildren()[1];
261 290
262 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 291 DOM::Node* parent_node = root->getChildren(nullptr)->get(0);
263 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 292 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
264 DOM::Node* child_node = parent_node_children->get(0); 293 DOM::Node* child_node = parent_node_children->get(0);
265 DOM::Node* sibling_node = parent_node_children->get(1); 294 DOM::Node* sibling_node = parent_node_children->get(1);
266 int parent_id = parent_node->getNodeId(); 295 int parent_id = parent_node->getNodeId();
267 296
268 Compare(parent_window, parent_node); 297 Compare(parent_window, parent_node);
269 Compare(child_window, child_node); 298 Compare(child_window, child_node);
270 parent_window->StackChildAbove(child_window, target_window); 299 parent_window->StackChildAbove(child_window, target_window);
271 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); 300 ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
272 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); 301 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId());
273 } 302 }
274 303
275 } // namespace ash 304 } // 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