| OLD | NEW |
| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DOM::Node* root_node = root->getChildren(default_children)->get(0); | 225 DOM::Node* root_node = root->getChildren(default_children)->get(0); |
| 226 DOM::Node* parent_node = root_node->getChildren(default_children)->get(0); | 226 DOM::Node* parent_node = root_node->getChildren(default_children)->get(0); |
| 227 DOM::Node* child_node = parent_node->getChildren(default_children)->get(0); | 227 DOM::Node* child_node = parent_node->getChildren(default_children)->get(0); |
| 228 | 228 |
| 229 Compare(parent_window, parent_node); | 229 Compare(parent_window, parent_node); |
| 230 Compare(child_window, child_node); | 230 Compare(child_window, child_node); |
| 231 child_window->Destroy(); | 231 child_window->Destroy(); |
| 232 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 232 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { |
| 236 // Initialize DOMAgent |
| 237 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 238 dom_agent()->getDocument(&root); |
| 239 |
| 240 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); |
| 241 WmWindow* target_window = root_window->GetChildren()[1]; |
| 242 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; |
| 243 |
| 244 DOM::Node* root_node = root->getChildren(default_children)->get(0); |
| 245 DOM::Node* parent_node = root_node->getChildren(default_children)->get(0); |
| 246 DOM::Node* target_node = root_node->getChildren(default_children)->get(1); |
| 247 Array<DOM::Node>* target_node_children = |
| 248 target_node->getChildren(default_children); |
| 249 DOM::Node* sibling_node = |
| 250 target_node_children->get(target_node_children->length() - 1); |
| 251 DOM::Node* child_node = parent_node->getChildren(default_children)->get(0); |
| 252 |
| 253 Compare(target_window, target_node); |
| 254 Compare(child_window, child_node); |
| 255 target_window->AddChild(child_window); |
| 256 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
| 257 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); |
| 258 } |
| 259 |
| 235 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { | 260 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { |
| 236 // Initialize DOMAgent | 261 // Initialize DOMAgent |
| 237 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 262 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 238 dom_agent()->getDocument(&root); | 263 dom_agent()->getDocument(&root); |
| 239 | 264 |
| 240 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); | 265 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); |
| 241 WmWindow* target_window = root_window->GetChildren()[1]; | 266 WmWindow* target_window = root_window->GetChildren()[1]; |
| 242 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; | 267 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; |
| 243 | 268 |
| 244 DOM::Node* root_node = root->getChildren(default_children)->get(0); | 269 DOM::Node* root_node = root->getChildren(default_children)->get(0); |
| 245 DOM::Node* parent_node = root_node->getChildren(default_children)->get(0); | 270 DOM::Node* parent_node = root_node->getChildren(default_children)->get(0); |
| 246 DOM::Node* target_node = root_node->getChildren(default_children)->get(1); | 271 DOM::Node* target_node = root_node->getChildren(default_children)->get(1); |
| 247 Array<DOM::Node>* target_node_children = | 272 Array<DOM::Node>* target_node_children = |
| 248 target_node->getChildren(default_children); | 273 target_node->getChildren(default_children); |
| 249 DOM::Node* sibling_node = | 274 DOM::Node* sibling_node = |
| 250 target_node_children->get(target_node_children->length() - 1); | 275 target_node_children->get(target_node_children->length() - 1); |
| 251 DOM::Node* child_node = parent_node->getChildren(default_children)->get(0); | 276 DOM::Node* child_node = parent_node->getChildren(default_children)->get(0); |
| 252 | 277 |
| 253 Compare(target_window, target_node); | 278 Compare(target_window, target_node); |
| 254 Compare(child_window, child_node); | 279 Compare(child_window, child_node); |
| 280 child_window->GetParent()->RemoveChild(child_window); |
| 255 target_window->AddChild(child_window); | 281 target_window->AddChild(child_window); |
| 256 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 282 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
| 257 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 283 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); |
| 258 } | 284 } |
| 259 | 285 |
| 260 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { | 286 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { |
| 261 // Initialize DOMAgent | 287 // Initialize DOMAgent |
| 262 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 288 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 263 dom_agent()->getDocument(&root); | 289 dom_agent()->getDocument(&root); |
| 264 | 290 |
| 265 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); | 291 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); |
| 266 WmWindow* child_window = parent_window->GetChildren()[0]; | 292 WmWindow* child_window = parent_window->GetChildren()[0]; |
| 267 WmWindow* target_window = parent_window->GetChildren()[1]; | 293 WmWindow* target_window = parent_window->GetChildren()[1]; |
| 268 | 294 |
| 269 DOM::Node* parent_node = root->getChildren(default_children)->get(0); | 295 DOM::Node* parent_node = root->getChildren(default_children)->get(0); |
| 270 Array<DOM::Node>* parent_node_children = | 296 Array<DOM::Node>* parent_node_children = |
| 271 parent_node->getChildren(default_children); | 297 parent_node->getChildren(default_children); |
| 272 DOM::Node* child_node = parent_node_children->get(0); | 298 DOM::Node* child_node = parent_node_children->get(0); |
| 273 DOM::Node* sibling_node = parent_node_children->get(1); | 299 DOM::Node* sibling_node = parent_node_children->get(1); |
| 274 int parent_id = parent_node->getNodeId(); | 300 int parent_id = parent_node->getNodeId(); |
| 275 | 301 |
| 276 Compare(parent_window, parent_node); | 302 Compare(parent_window, parent_node); |
| 277 Compare(child_window, child_node); | 303 Compare(child_window, child_node); |
| 278 parent_window->StackChildAbove(child_window, target_window); | 304 parent_window->StackChildAbove(child_window, target_window); |
| 279 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); | 305 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); |
| 280 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); | 306 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); |
| 281 } | 307 } |
| 282 | 308 |
| 283 } // namespace ash | 309 } // namespace ash |
| OLD | NEW |