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/common/devtools/ash_devtools_css_agent.h" | 5 #include "ash/common/devtools/ash_devtools_css_agent.h" |
| 6 #include "ash/common/devtools/ash_devtools_dom_agent.h" | 6 #include "ash/common/devtools/ash_devtools_dom_agent.h" |
| 7 #include "ash/common/test/ash_test.h" | 7 #include "ash/common/test/ash_test.h" |
| 8 #include "ash/common/wm_lookup.h" | |
| 9 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 10 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 11 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 12 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 14 #include "ui/display/display.h" | 13 #include "ui/display/display.h" |
| 15 #include "ui/views/background.h" | 14 #include "ui/views/background.h" |
| 16 #include "ui/views/widget/native_widget_private.h" | 15 #include "ui/views/widget/native_widget_private.h" |
| 17 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 18 | 17 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; | 291 std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; |
| 293 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; | 292 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; |
| 294 std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; | 293 std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; |
| 295 | 294 |
| 296 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); | 295 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); |
| 297 }; | 296 }; |
| 298 | 297 |
| 299 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { | 298 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { |
| 300 std::unique_ptr<views::Widget> widget( | 299 std::unique_ptr<views::Widget> widget( |
| 301 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 300 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 302 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 301 WmWindow* parent_window = WmWindow::Get(widget.get()->GetNativeWindow()); |
|
sky
2017/03/02 19:04:52
Remove the .get() in all these, e.g. widget->GetNa
thanhph1
2017/03/02 22:24:17
Thanks Scott, I double-checked and removed all of
| |
| 303 parent_window->SetName("parent_window"); | 302 parent_window->SetName("parent_window"); |
| 304 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 303 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 305 WmWindow* child_window = child_owner->window(); | 304 WmWindow* child_window = child_owner->window(); |
| 306 child_window->SetName("child_window"); | 305 child_window->SetName("child_window"); |
| 307 widget->Show(); | 306 widget->Show(); |
| 308 views::View* child_view = new TestView("child_view"); | 307 views::View* child_view = new TestView("child_view"); |
| 309 widget->GetRootView()->AddChildView(child_view); | 308 widget->GetRootView()->AddChildView(child_view); |
| 310 | 309 |
| 311 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 310 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 312 dom_agent()->getDocument(&root); | 311 dom_agent()->getDocument(&root); |
| 313 | 312 |
| 314 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 313 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
| 315 ASSERT_TRUE(parent_node); | 314 ASSERT_TRUE(parent_node); |
| 316 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 315 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
| 317 ASSERT_TRUE(parent_children); | 316 ASSERT_TRUE(parent_children); |
| 318 DOM::Node* widget_node = parent_children->get(0); | 317 DOM::Node* widget_node = parent_children->get(0); |
| 319 Compare(widget.get(), widget_node); | 318 Compare(widget.get(), widget_node); |
| 320 Compare(child_window, parent_children->get(1)); | 319 Compare(child_window, parent_children->get(1)); |
| 321 Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr); | 320 Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr); |
| 322 ASSERT_TRUE(widget_children); | 321 ASSERT_TRUE(widget_children); |
| 323 Compare(widget->GetRootView(), widget_children->get(0)); | 322 Compare(widget->GetRootView(), widget_children->get(0)); |
| 324 ASSERT_TRUE(widget_children->get(0)->getChildren(nullptr)); | 323 ASSERT_TRUE(widget_children->get(0)->getChildren(nullptr)); |
| 325 Compare(child_view, widget_children->get(0)->getChildren(nullptr)->get(1)); | 324 Compare(child_view, widget_children->get(0)->getChildren(nullptr)->get(1)); |
| 326 } | 325 } |
| 327 | 326 |
| 328 TEST_F(AshDevToolsTest, GetDocumentNativeWidgetOwnsWidget) { | 327 TEST_F(AshDevToolsTest, GetDocumentNativeWidgetOwnsWidget) { |
| 329 views::internal::NativeWidgetPrivate* native_widget_private = | 328 views::internal::NativeWidgetPrivate* native_widget_private = |
| 330 CreateTestNativeWidget(); | 329 CreateTestNativeWidget(); |
| 331 views::Widget* widget = native_widget_private->GetWidget(); | 330 views::Widget* widget = native_widget_private->GetWidget(); |
| 332 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget); | 331 WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); |
| 333 | 332 |
| 334 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 333 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 335 dom_agent()->getDocument(&root); | 334 dom_agent()->getDocument(&root); |
| 336 | 335 |
| 337 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 336 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
| 338 ASSERT_TRUE(parent_node); | 337 ASSERT_TRUE(parent_node); |
| 339 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 338 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); |
| 340 Compare(widget, widget_node); | 339 Compare(widget, widget_node); |
| 341 // Destroy NativeWidget followed by |widget| | 340 // Destroy NativeWidget followed by |widget| |
| 342 widget->CloseNow(); | 341 widget->CloseNow(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 Compare(parent_window, parent_node); | 445 Compare(parent_window, parent_node); |
| 447 Compare(child_window, child_node); | 446 Compare(child_window, child_node); |
| 448 parent_window->StackChildAbove(child_window, target_window); | 447 parent_window->StackChildAbove(child_window, target_window); |
| 449 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); | 448 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); |
| 450 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); | 449 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); |
| 451 } | 450 } |
| 452 | 451 |
| 453 TEST_F(AshDevToolsTest, ViewInserted) { | 452 TEST_F(AshDevToolsTest, ViewInserted) { |
| 454 std::unique_ptr<views::Widget> widget( | 453 std::unique_ptr<views::Widget> widget( |
| 455 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 454 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 456 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 455 WmWindow* window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 457 widget->Show(); | 456 widget->Show(); |
| 458 | 457 |
| 459 // Initialize DOMAgent | 458 // Initialize DOMAgent |
| 460 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 459 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 461 dom_agent()->getDocument(&root); | 460 dom_agent()->getDocument(&root); |
| 462 | 461 |
| 463 DOM::Node* parent_node = FindInRoot(window, root.get()); | 462 DOM::Node* parent_node = FindInRoot(window, root.get()); |
| 464 ASSERT_TRUE(parent_node); | 463 ASSERT_TRUE(parent_node); |
| 465 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 464 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); |
| 466 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 465 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); |
| 467 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 466 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); |
| 468 ASSERT_TRUE(root_view_children); | 467 ASSERT_TRUE(root_view_children); |
| 469 DOM::Node* sibling_view_node = | 468 DOM::Node* sibling_view_node = |
| 470 root_view_children->get(root_view_children->length() - 1); | 469 root_view_children->get(root_view_children->length() - 1); |
| 471 | 470 |
| 472 widget->GetRootView()->AddChildView(new views::View); | 471 widget->GetRootView()->AddChildView(new views::View); |
| 473 ExpectChildNodeInserted(root_view_node->getNodeId(), | 472 ExpectChildNodeInserted(root_view_node->getNodeId(), |
| 474 sibling_view_node->getNodeId()); | 473 sibling_view_node->getNodeId()); |
| 475 } | 474 } |
| 476 | 475 |
| 477 TEST_F(AshDevToolsTest, ViewRemoved) { | 476 TEST_F(AshDevToolsTest, ViewRemoved) { |
| 478 std::unique_ptr<views::Widget> widget( | 477 std::unique_ptr<views::Widget> widget( |
| 479 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 478 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 480 // Need to store |view| in unique_ptr because it is removed from the widget | 479 // Need to store |view| in unique_ptr because it is removed from the widget |
| 481 // and needs to be destroyed independently | 480 // and needs to be destroyed independently |
| 482 std::unique_ptr<views::View> child_view = base::MakeUnique<views::View>(); | 481 std::unique_ptr<views::View> child_view = base::MakeUnique<views::View>(); |
| 483 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 482 WmWindow* window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 484 widget->Show(); | 483 widget->Show(); |
| 485 views::View* root_view = widget->GetRootView(); | 484 views::View* root_view = widget->GetRootView(); |
| 486 root_view->AddChildView(child_view.get()); | 485 root_view->AddChildView(child_view.get()); |
| 487 | 486 |
| 488 // Initialize DOMAgent | 487 // Initialize DOMAgent |
| 489 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 488 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 490 dom_agent()->getDocument(&root); | 489 dom_agent()->getDocument(&root); |
| 491 | 490 |
| 492 DOM::Node* parent_node = FindInRoot(window, root.get()); | 491 DOM::Node* parent_node = FindInRoot(window, root.get()); |
| 493 ASSERT_TRUE(parent_node); | 492 ASSERT_TRUE(parent_node); |
| 494 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 493 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); |
| 495 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 494 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); |
| 496 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 495 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); |
| 497 ASSERT_TRUE(root_view_children); | 496 ASSERT_TRUE(root_view_children); |
| 498 DOM::Node* child_view_node = | 497 DOM::Node* child_view_node = |
| 499 root_view_children->get(root_view_children->length() - 1); | 498 root_view_children->get(root_view_children->length() - 1); |
| 500 | 499 |
| 501 Compare(child_view.get(), child_view_node); | 500 Compare(child_view.get(), child_view_node); |
| 502 root_view->RemoveChildView(child_view.get()); | 501 root_view->RemoveChildView(child_view.get()); |
| 503 ExpectChildNodeRemoved(root_view_node->getNodeId(), | 502 ExpectChildNodeRemoved(root_view_node->getNodeId(), |
| 504 child_view_node->getNodeId()); | 503 child_view_node->getNodeId()); |
| 505 } | 504 } |
| 506 | 505 |
| 507 TEST_F(AshDevToolsTest, ViewRearranged) { | 506 TEST_F(AshDevToolsTest, ViewRearranged) { |
| 508 std::unique_ptr<views::Widget> widget( | 507 std::unique_ptr<views::Widget> widget( |
| 509 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 508 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 510 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 509 WmWindow* window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 511 widget->Show(); | 510 widget->Show(); |
| 512 views::View* root_view = widget->GetRootView(); | 511 views::View* root_view = widget->GetRootView(); |
| 513 views::View* parent_view = new views::View; | 512 views::View* parent_view = new views::View; |
| 514 views::View* target_view = new views::View; | 513 views::View* target_view = new views::View; |
| 515 views::View* child_view = new views::View; | 514 views::View* child_view = new views::View; |
| 516 root_view->AddChildView(parent_view); | 515 root_view->AddChildView(parent_view); |
| 517 root_view->AddChildView(target_view); | 516 root_view->AddChildView(target_view); |
| 518 parent_view->AddChildView(child_view); | 517 parent_view->AddChildView(child_view); |
| 519 | 518 |
| 520 // Initialize DOMAgent | 519 // Initialize DOMAgent |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 538 Compare(child_view, child_view_node); | 537 Compare(child_view, child_view_node); |
| 539 target_view->AddChildView(child_view); | 538 target_view->AddChildView(child_view); |
| 540 ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 539 ExpectChildNodeRemoved(parent_view_node->getNodeId(), |
| 541 child_view_node->getNodeId()); | 540 child_view_node->getNodeId()); |
| 542 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 541 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); |
| 543 } | 542 } |
| 544 | 543 |
| 545 TEST_F(AshDevToolsTest, ViewRearrangedRemovedAndInserted) { | 544 TEST_F(AshDevToolsTest, ViewRearrangedRemovedAndInserted) { |
| 546 std::unique_ptr<views::Widget> widget( | 545 std::unique_ptr<views::Widget> widget( |
| 547 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 546 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 548 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 547 WmWindow* window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 549 widget->Show(); | 548 widget->Show(); |
| 550 views::View* root_view = widget->GetRootView(); | 549 views::View* root_view = widget->GetRootView(); |
| 551 views::View* parent_view = new views::View; | 550 views::View* parent_view = new views::View; |
| 552 views::View* target_view = new views::View; | 551 views::View* target_view = new views::View; |
| 553 views::View* child_view = new views::View; | 552 views::View* child_view = new views::View; |
| 554 root_view->AddChildView(parent_view); | 553 root_view->AddChildView(parent_view); |
| 555 root_view->AddChildView(target_view); | 554 root_view->AddChildView(target_view); |
| 556 parent_view->AddChildView(child_view); | 555 parent_view->AddChildView(child_view); |
| 557 | 556 |
| 558 // Initialize DOMAgent | 557 // Initialize DOMAgent |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 577 parent_view->RemoveChildView(child_view); | 576 parent_view->RemoveChildView(child_view); |
| 578 target_view->AddChildView(child_view); | 577 target_view->AddChildView(child_view); |
| 579 ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 578 ExpectChildNodeRemoved(parent_view_node->getNodeId(), |
| 580 child_view_node->getNodeId()); | 579 child_view_node->getNodeId()); |
| 581 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 580 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); |
| 582 } | 581 } |
| 583 | 582 |
| 584 TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) { | 583 TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) { |
| 585 std::unique_ptr<views::Widget> widget( | 584 std::unique_ptr<views::Widget> widget( |
| 586 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 585 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); |
| 587 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 586 WmWindow* parent_window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 588 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 587 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 589 WmWindow* window = child_owner->window(); | 588 WmWindow* window = child_owner->window(); |
| 590 views::View* root_view = widget->GetRootView(); | 589 views::View* root_view = widget->GetRootView(); |
| 591 | 590 |
| 592 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 591 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 593 dom_agent()->getDocument(&root); | 592 dom_agent()->getDocument(&root); |
| 594 | 593 |
| 595 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 594 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
| 596 ASSERT_TRUE(parent_node); | 595 ASSERT_TRUE(parent_node); |
| 597 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 596 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 | 636 |
| 638 window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay()); | 637 window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay()); |
| 639 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 638 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 640 HighlightNode(dom_agent()->GetNodeIdFromWindow(window)); | 639 HighlightNode(dom_agent()->GetNodeIdFromWindow(window)); |
| 641 ExpectHighlighted(window->GetBoundsInScreen(), 1); | 640 ExpectHighlighted(window->GetBoundsInScreen(), 1); |
| 642 } | 641 } |
| 643 | 642 |
| 644 TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { | 643 TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { |
| 645 std::unique_ptr<views::Widget> widget( | 644 std::unique_ptr<views::Widget> widget( |
| 646 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 645 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 647 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 646 WmWindow* parent_window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 648 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 647 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 649 WmWindow* window = child_owner->window(); | 648 WmWindow* window = child_owner->window(); |
| 650 gfx::Rect window_bounds(2, 2, 3, 3); | 649 gfx::Rect window_bounds(2, 2, 3, 3); |
| 651 gfx::Rect widget_bounds(50, 50, 100, 75); | 650 gfx::Rect widget_bounds(50, 50, 100, 75); |
| 652 gfx::Rect view_bounds(4, 4, 3, 3); | 651 gfx::Rect view_bounds(4, 4, 3, 3); |
| 653 window->SetBounds(window_bounds); | 652 window->SetBounds(window_bounds); |
| 654 widget->SetBounds(widget_bounds); | 653 widget->SetBounds(widget_bounds); |
| 655 widget->GetRootView()->SetBoundsRect(view_bounds); | 654 widget->GetRootView()->SetBoundsRect(view_bounds); |
| 656 | 655 |
| 657 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 656 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 658 dom_agent()->getDocument(&root); | 657 dom_agent()->getDocument(&root); |
| 659 | 658 |
| 660 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 659 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
| 661 ASSERT_TRUE(parent_node); | 660 ASSERT_TRUE(parent_node); |
| 662 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 661 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
| 663 ASSERT_TRUE(parent_children); | 662 ASSERT_TRUE(parent_children); |
| 664 | 663 |
| 665 CompareNodeBounds(parent_node, widget_bounds); | 664 CompareNodeBounds(parent_node, widget_bounds); |
| 666 CompareNodeBounds(parent_children->get(1), window_bounds); | 665 CompareNodeBounds(parent_children->get(1), window_bounds); |
| 667 CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0), | 666 CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0), |
| 668 view_bounds); | 667 view_bounds); |
| 669 } | 668 } |
| 670 | 669 |
| 671 TEST_F(AshDevToolsTest, WindowWidgetViewStyleSheetChanged) { | 670 TEST_F(AshDevToolsTest, WindowWidgetViewStyleSheetChanged) { |
| 672 std::unique_ptr<views::Widget> widget( | 671 std::unique_ptr<views::Widget> widget( |
| 673 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 672 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 674 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 673 WmWindow* widget_window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 675 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(widget_window)); | 674 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(widget_window)); |
| 676 WmWindow* child = child_owner->window(); | 675 WmWindow* child = child_owner->window(); |
| 677 | 676 |
| 678 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 677 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 679 dom_agent()->getDocument(&root); | 678 dom_agent()->getDocument(&root); |
| 680 | 679 |
| 681 gfx::Rect child_bounds(2, 2, 3, 3); | 680 gfx::Rect child_bounds(2, 2, 3, 3); |
| 682 gfx::Rect widget_bounds(10, 10, 150, 160); | 681 gfx::Rect widget_bounds(10, 10, 150, 160); |
| 683 gfx::Rect view_bounds(4, 4, 3, 3); | 682 gfx::Rect view_bounds(4, 4, 3, 3); |
| 684 child->SetBounds(child_bounds); | 683 child->SetBounds(child_bounds); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 696 EXPECT_EQ(2, | 695 EXPECT_EQ(2, |
| 697 GetStyleSheetChangedCount(widget_node_children->get(0) | 696 GetStyleSheetChangedCount(widget_node_children->get(0) |
| 698 ->getChildren(nullptr) | 697 ->getChildren(nullptr) |
| 699 ->get(0) | 698 ->get(0) |
| 700 ->getNodeId())); | 699 ->getNodeId())); |
| 701 } | 700 } |
| 702 | 701 |
| 703 TEST_F(AshDevToolsTest, WindowWidgetViewSetStyleText) { | 702 TEST_F(AshDevToolsTest, WindowWidgetViewSetStyleText) { |
| 704 std::unique_ptr<views::Widget> widget( | 703 std::unique_ptr<views::Widget> widget( |
| 705 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 704 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); |
| 706 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get()); | 705 WmWindow* parent_window = WmWindow::Get(widget.get()->GetNativeWindow()); |
| 707 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 706 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 708 WmWindow* window = child_owner->window(); | 707 WmWindow* window = child_owner->window(); |
| 709 views::View* root_view = widget->GetRootView(); | 708 views::View* root_view = widget->GetRootView(); |
| 710 | 709 |
| 711 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 710 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 712 dom_agent()->getDocument(&root); | 711 dom_agent()->getDocument(&root); |
| 713 | 712 |
| 714 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 713 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
| 715 ASSERT_TRUE(parent_node); | 714 ASSERT_TRUE(parent_node); |
| 716 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 715 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 EXPECT_EQ(gfx::Rect(25, 35, 45, 20), root_view->bounds()); // Not changed | 756 EXPECT_EQ(gfx::Rect(25, 35, 45, 20), root_view->bounds()); // Not changed |
| 758 | 757 |
| 759 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); | 758 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
| 760 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 759 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
| 761 | 760 |
| 762 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\n ", true); | 761 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\n ", true); |
| 763 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 762 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
| 764 } | 763 } |
| 765 | 764 |
| 766 } // namespace ash | 765 } // namespace ash |
| OLD | NEW |