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::WindowElement* window_element = | |
641 static_cast<devtools::WindowElement*>( | |
642 dom_agent()->node_id_to_ui_element()[window_node->getNodeId()]); | |
sadrul
2017/05/25 19:07:28
Can you just use dom_agent()->GetElementFromNodeId
thanhph
2017/05/25 20:16:40
Done.
| |
643 EXPECT_EQ(window_element->GetNodeWindowAndBounds().first, window.get()); | |
644 EXPECT_EQ(window_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 devtools::WidgetElement* widget_element = | |
653 static_cast<devtools::WidgetElement*>( | |
654 dom_agent()->node_id_to_ui_element()[widget_node->getNodeId()]); | |
655 EXPECT_EQ(widget_element->GetNodeWindowAndBounds().first, | |
656 widget->GetNativeWindow()); | |
657 EXPECT_EQ(widget_element->GetNodeWindowAndBounds().second, | |
658 widget->GetWindowBoundsInScreen()); | |
659 | |
644 HideHighlight(0); | 660 HideHighlight(0); |
645 | 661 |
646 HighlightNode(root_view_node->getNodeId()); | 662 HighlightNode(root_view_node->getNodeId()); |
647 ExpectHighlighted(root_view->GetBoundsInScreen(), 0); | 663 ExpectHighlighted(root_view->GetBoundsInScreen(), 0); |
648 | 664 |
665 devtools::ViewElement* view_element = static_cast<devtools::ViewElement*>( | |
666 dom_agent()->node_id_to_ui_element()[root_view_node->getNodeId()]); | |
667 EXPECT_EQ(view_element->GetNodeWindowAndBounds().first, | |
668 root_view->GetWidget()->GetNativeWindow()); | |
669 EXPECT_EQ(view_element->GetNodeWindowAndBounds().second, | |
670 root_view->GetBoundsInScreen()); | |
671 | |
649 HideHighlight(0); | 672 HideHighlight(0); |
650 | 673 |
651 // Highlight non-existent node | 674 // Highlight non-existent node |
652 HighlightNode(10000); | 675 HighlightNode(10000); |
653 EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); | 676 EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); |
654 } | 677 } |
655 | 678 |
656 int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) { | 679 int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) { |
657 for (auto* child : ui_element->children()) { | 680 for (auto* child : ui_element->children()) { |
658 if (child->type() == devtools::UIElementType::WINDOW && | 681 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); | 838 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
816 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 839 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
817 | 840 |
818 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 841 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", |
819 true); | 842 true); |
820 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 843 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
821 EXPECT_TRUE(root_view->visible()); | 844 EXPECT_TRUE(root_view->visible()); |
822 } | 845 } |
823 | 846 |
824 } // namespace ash | 847 } // namespace ash |
OLD | NEW |