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/devtools/ui_element.h" | 7 #include "ash/devtools/ui_element.h" |
| 8 #include "ash/devtools/view_element.h" |
| 9 #include "ash/devtools/widget_element.h" |
8 #include "ash/devtools/window_element.h" | 10 #include "ash/devtools/window_element.h" |
9 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
11 #include "ash/shell.h" | 13 #include "ash/shell.h" |
12 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
13 #include "ash/wm/widget_finder.h" | 15 #include "ash/wm/widget_finder.h" |
14 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
15 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
16 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
17 #include "ui/views/background.h" | 19 #include "ui/views/background.h" |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 630 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
629 ASSERT_TRUE(parent_node); | 631 ASSERT_TRUE(parent_node); |
630 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 632 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
631 ASSERT_TRUE(parent_children); | 633 ASSERT_TRUE(parent_children); |
632 DOM::Node* window_node = parent_children->get(1); | 634 DOM::Node* window_node = parent_children->get(1); |
633 DOM::Node* widget_node = parent_children->get(0); | 635 DOM::Node* widget_node = parent_children->get(0); |
634 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 636 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); |
635 | 637 |
636 HighlightNode(window_node->getNodeId()); | 638 HighlightNode(window_node->getNodeId()); |
637 ExpectHighlighted(window->GetBoundsInScreen(), 0); | 639 ExpectHighlighted(window->GetBoundsInScreen(), 0); |
| 640 devtools::UIElement* element = |
| 641 dom_agent()->GetElementFromNodeId(window_node->getNodeId()); |
| 642 ASSERT_EQ(devtools::UIElementType::WINDOW, element->type()); |
| 643 EXPECT_EQ(element->GetNodeWindowAndBounds().first, window.get()); |
| 644 EXPECT_EQ(element->GetNodeWindowAndBounds().second, |
| 645 window->GetBoundsInScreen()); |
638 | 646 |
639 HideHighlight(0); | 647 HideHighlight(0); |
640 | 648 |
641 HighlightNode(widget_node->getNodeId()); | 649 HighlightNode(widget_node->getNodeId()); |
642 ExpectHighlighted(widget->GetWindowBoundsInScreen(), 0); | 650 ExpectHighlighted(widget->GetWindowBoundsInScreen(), 0); |
643 | 651 |
| 652 element = dom_agent()->GetElementFromNodeId(widget_node->getNodeId()); |
| 653 ASSERT_EQ(devtools::UIElementType::WIDGET, element->type()); |
| 654 EXPECT_EQ(element->GetNodeWindowAndBounds().first, widget->GetNativeWindow()); |
| 655 EXPECT_EQ(element->GetNodeWindowAndBounds().second, |
| 656 widget->GetWindowBoundsInScreen()); |
| 657 |
644 HideHighlight(0); | 658 HideHighlight(0); |
645 | 659 |
646 HighlightNode(root_view_node->getNodeId()); | 660 HighlightNode(root_view_node->getNodeId()); |
647 ExpectHighlighted(root_view->GetBoundsInScreen(), 0); | 661 ExpectHighlighted(root_view->GetBoundsInScreen(), 0); |
648 | 662 |
| 663 element = dom_agent()->GetElementFromNodeId(root_view_node->getNodeId()); |
| 664 ASSERT_EQ(devtools::UIElementType::VIEW, element->type()); |
| 665 EXPECT_EQ(element->GetNodeWindowAndBounds().first, |
| 666 root_view->GetWidget()->GetNativeWindow()); |
| 667 EXPECT_EQ(element->GetNodeWindowAndBounds().second, |
| 668 root_view->GetBoundsInScreen()); |
| 669 |
649 HideHighlight(0); | 670 HideHighlight(0); |
650 | 671 |
651 // Highlight non-existent node | 672 // Highlight non-existent node |
652 HighlightNode(10000); | 673 HighlightNode(10000); |
653 EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); | 674 EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); |
654 } | 675 } |
655 | 676 |
656 int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) { | 677 int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) { |
657 for (auto* child : ui_element->children()) { | 678 for (auto* child : ui_element->children()) { |
658 if (child->type() == devtools::UIElementType::WINDOW && | 679 if (child->type() == devtools::UIElementType::WINDOW && |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); | 836 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
816 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 837 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
817 | 838 |
818 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 839 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", |
819 true); | 840 true); |
820 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 841 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
821 EXPECT_TRUE(root_view->visible()); | 842 EXPECT_TRUE(root_view->visible()); |
822 } | 843 } |
823 | 844 |
824 } // namespace ash | 845 } // namespace ash |
OLD | NEW |