Chromium Code Reviews| 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/devtools/ash_devtools_css_agent.h" | 5 #include "ash/devtools/ash_devtools_css_agent.h" |
| 6 #include "ash/devtools/ash_devtools_dom_agent.h" | 6 #include "ash/devtools/ash_devtools_dom_agent.h" |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/test/ash_test.h" | 8 #include "ash/test/ash_test.h" |
| 9 #include "ash/wm/widget_finder.h" | 9 #include "ash/wm/widget_finder.h" |
| 10 #include "ash/wm_shell.h" | 10 #include "ash/wm_shell.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 Compare(widget, widget_node); | 340 Compare(widget, widget_node); |
| 341 // Destroy NativeWidget followed by |widget| | 341 // Destroy NativeWidget followed by |widget| |
| 342 widget->CloseNow(); | 342 widget->CloseNow(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { | 345 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { |
| 346 // Initialize DOMAgent | 346 // Initialize DOMAgent |
| 347 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 347 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 348 dom_agent()->getDocument(&root); | 348 dom_agent()->getDocument(&root); |
| 349 | 349 |
| 350 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); | 350 WmWindow* parent_window = |
| 351 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); | 351 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; |
| 352 DOM::Node* parent_node = | |
| 353 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | |
| 352 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 354 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
| 353 DOM::Node* sibling_node = | 355 DOM::Node* sibling_node = |
| 354 parent_node_children->get(parent_node_children->length() - 1); | 356 parent_node_children->get(parent_node_children->length() - 1); |
| 355 | 357 |
| 356 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 358 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 357 ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); | 359 ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); |
| 358 } | 360 } |
| 359 | 361 |
| 360 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { | 362 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { |
| 361 // Initialize DOMAgent | 363 // Initialize DOMAgent |
| 362 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 364 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 363 dom_agent()->getDocument(&root); | 365 dom_agent()->getDocument(&root); |
| 364 | 366 |
| 365 WmWindow* parent_window = | 367 WmWindow* parent_window = WmShell::Get() |
| 366 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; | 368 ->GetPrimaryRootWindow() |
| 369 ->GetChildren()[0] | |
|
oshima
2017/04/10 19:44:11
define a utility function to get the parent window
wutao
2017/04/10 23:03:54
Done. And changed other related parts.
oshima
2017/04/11 21:48:08
Sorry if it wasn't clear. I was thinking of someth
wutao
2017/04/13 18:09:39
I changed as sadrul@ suggested. GetPrimaryRootWind
| |
| 370 ->GetChildren()[0]; | |
| 367 WmWindow* child_window = parent_window->GetChildren()[0]; | 371 WmWindow* child_window = parent_window->GetChildren()[0]; |
| 368 DOM::Node* root_node = root->getChildren(nullptr)->get(0); | 372 DOM::Node* root_node = |
| 373 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | |
| 369 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 374 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); |
| 370 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 375 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); |
| 371 | 376 |
| 372 Compare(parent_window, parent_node); | 377 Compare(parent_window, parent_node); |
| 373 Compare(child_window, child_node); | 378 Compare(child_window, child_node); |
| 374 child_window->Destroy(); | 379 child_window->Destroy(); |
| 375 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 380 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
| 376 } | 381 } |
| 377 | 382 |
| 378 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { | 383 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { |
| 379 // Initialize DOMAgent | 384 // Initialize DOMAgent |
| 380 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 385 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 381 dom_agent()->getDocument(&root); | 386 dom_agent()->getDocument(&root); |
| 382 | 387 |
| 383 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); | 388 WmWindow* root_window = |
| 389 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; | |
| 390 | |
| 384 WmWindow* target_window = root_window->GetChildren()[1]; | 391 WmWindow* target_window = root_window->GetChildren()[1]; |
| 385 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; | 392 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; |
| 386 | 393 |
| 387 DOM::Node* root_node = root->getChildren(nullptr)->get(0); | 394 DOM::Node* root_node = |
| 395 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | |
| 388 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 396 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); |
| 389 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 397 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); |
| 390 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 398 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); |
| 391 DOM::Node* sibling_node = | 399 DOM::Node* sibling_node = |
| 392 target_node_children->get(target_node_children->length() - 1); | 400 target_node_children->get(target_node_children->length() - 1); |
| 393 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 401 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); |
| 394 | 402 |
| 395 Compare(target_window, target_node); | 403 Compare(target_window, target_node); |
| 396 Compare(child_window, child_node); | 404 Compare(child_window, child_node); |
| 397 target_window->AddChild(child_window); | 405 target_window->AddChild(child_window); |
| 398 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 406 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
| 399 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 407 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); |
| 400 } | 408 } |
| 401 | 409 |
| 402 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { | 410 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { |
| 403 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); | 411 WmWindow* root_window = |
| 412 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; | |
| 404 WmWindow* target_window = root_window->GetChildren()[1]; | 413 WmWindow* target_window = root_window->GetChildren()[1]; |
| 405 WmWindow* parent_window = root_window->GetChildren()[0]; | 414 WmWindow* parent_window = root_window->GetChildren()[0]; |
| 406 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 415 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 407 WmWindow* child_window = child_owner->window(); | 416 WmWindow* child_window = child_owner->window(); |
| 408 | 417 |
| 409 // Initialize DOMAgent | 418 // Initialize DOMAgent |
| 410 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 419 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 411 dom_agent()->getDocument(&root); | 420 dom_agent()->getDocument(&root); |
| 412 DOM::Node* root_node = root->getChildren(nullptr)->get(0); | 421 DOM::Node* root_node = |
| 422 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | |
| 413 | 423 |
| 414 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 424 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); |
| 415 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 425 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); |
| 416 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 426 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); |
| 417 DOM::Node* sibling_node = | 427 DOM::Node* sibling_node = |
| 418 target_node_children->get(target_node_children->length() - 1); | 428 target_node_children->get(target_node_children->length() - 1); |
| 419 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 429 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
| 420 DOM::Node* child_node = | 430 DOM::Node* child_node = |
| 421 parent_node_children->get(parent_node_children->length() - 1); | 431 parent_node_children->get(parent_node_children->length() - 1); |
| 422 | 432 |
| 423 Compare(target_window, target_node); | 433 Compare(target_window, target_node); |
| 424 Compare(child_window, child_node); | 434 Compare(child_window, child_node); |
| 425 parent_window->RemoveChild(child_window); | 435 parent_window->RemoveChild(child_window); |
| 426 target_window->AddChild(child_window); | 436 target_window->AddChild(child_window); |
| 427 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 437 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
| 428 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 438 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); |
| 429 } | 439 } |
| 430 | 440 |
| 431 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { | 441 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { |
| 432 // Initialize DOMAgent | 442 // Initialize DOMAgent |
| 433 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 443 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 434 dom_agent()->getDocument(&root); | 444 dom_agent()->getDocument(&root); |
| 435 | 445 |
| 436 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); | 446 WmWindow* parent_window = |
| 447 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; | |
| 437 WmWindow* child_window = parent_window->GetChildren()[0]; | 448 WmWindow* child_window = parent_window->GetChildren()[0]; |
| 438 WmWindow* target_window = parent_window->GetChildren()[1]; | 449 WmWindow* target_window = parent_window->GetChildren()[1]; |
| 439 | 450 |
| 440 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); | 451 DOM::Node* parent_node = |
| 452 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | |
| 441 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 453 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
| 442 DOM::Node* child_node = parent_node_children->get(0); | 454 DOM::Node* child_node = parent_node_children->get(0); |
| 443 DOM::Node* sibling_node = parent_node_children->get(1); | 455 DOM::Node* sibling_node = parent_node_children->get(1); |
| 444 int parent_id = parent_node->getNodeId(); | 456 int parent_id = parent_node->getNodeId(); |
| 445 | 457 |
| 446 Compare(parent_window, parent_node); | 458 Compare(parent_window, parent_node); |
| 447 Compare(child_window, child_node); | 459 Compare(child_window, child_node); |
| 448 parent_window->StackChildAbove(child_window, target_window); | 460 parent_window->StackChildAbove(child_window, target_window); |
| 449 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); | 461 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); |
| 450 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); | 462 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); | 779 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
| 768 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 780 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
| 769 | 781 |
| 770 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 782 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", |
| 771 true); | 783 true); |
| 772 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 784 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
| 773 EXPECT_TRUE(root_view->visible()); | 785 EXPECT_TRUE(root_view->visible()); |
| 774 } | 786 } |
| 775 | 787 |
| 776 } // namespace ash | 788 } // namespace ash |
| OLD | NEW |