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

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

Issue 2508953002: Fix bug where removed (but not deleted) windows are not reflected in the tree properly (Closed)
Patch Set: Add test but disable on windows 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 #if defined(OS_WIN)
254 #define MAYBE_WindowReorganizedChildNodeRemovedAndInserted \
255 DISABLED_WindowReorganizedChildNodeRemovedAndInserted
256 #else
257 #define MAYBE_WindowReorganizedChildNodeRemovedAndInserted \
258 WindowReorganizedChildNodeRemovedAndInserted
259 #endif // defined(OS_WIN)
260 TEST_F(AshDevToolsTest, MAYBE_WindowReorganizedChildNodeRemovedAndInserted) {
261 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow();
262 WmWindow* target_window = root_window->GetChildren()[1];
263 WmWindow* parent_window = root_window->GetChildren()[0];
264 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
265 WmWindow* child_window = child_owner->window();
266
267 // Initialize DOMAgent
268 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
269 dom_agent()->getDocument(&root);
270 DOM::Node* root_node = root->getChildren(nullptr)->get(0);
271
272 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
273 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
274 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
275 DOM::Node* sibling_node =
276 target_node_children->get(target_node_children->length() - 1);
277 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
278 DOM::Node* child_node =
279 parent_node_children->get(parent_node_children->length() - 1);
280
281 Compare(target_window, target_node);
282 Compare(child_window, child_node);
283 parent_window->RemoveChild(child_window);
284 target_window->AddChild(child_window);
285 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
286 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
287 }
288
253 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { 289 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
254 // Initialize DOMAgent 290 // Initialize DOMAgent
255 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 291 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
256 dom_agent()->getDocument(&root); 292 dom_agent()->getDocument(&root);
257 293
258 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 294 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow();
259 WmWindow* child_window = parent_window->GetChildren()[0]; 295 WmWindow* child_window = parent_window->GetChildren()[0];
260 WmWindow* target_window = parent_window->GetChildren()[1]; 296 WmWindow* target_window = parent_window->GetChildren()[1];
261 297
262 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 298 DOM::Node* parent_node = root->getChildren(nullptr)->get(0);
263 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 299 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
264 DOM::Node* child_node = parent_node_children->get(0); 300 DOM::Node* child_node = parent_node_children->get(0);
265 DOM::Node* sibling_node = parent_node_children->get(1); 301 DOM::Node* sibling_node = parent_node_children->get(1);
266 int parent_id = parent_node->getNodeId(); 302 int parent_id = parent_node->getNodeId();
267 303
268 Compare(parent_window, parent_node); 304 Compare(parent_window, parent_node);
269 Compare(child_window, child_node); 305 Compare(child_window, child_node);
270 parent_window->StackChildAbove(child_window, target_window); 306 parent_window->StackChildAbove(child_window, target_window);
271 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); 307 ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
272 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); 308 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId());
273 } 309 }
274 310
275 } // namespace ash 311 } // 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