| 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_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return attributes->get(i + 1); | 76 return attributes->get(i + 1); |
| 77 } | 77 } |
| 78 return nullptr; | 78 return nullptr; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool Equals(WmWindow* window, DOM::Node* node) { | 81 bool Equals(WmWindow* window, DOM::Node* node) { |
| 82 int children_count = static_cast<int>(window->GetChildren().size()); | 82 int children_count = static_cast<int>(window->GetChildren().size()); |
| 83 if (window->GetInternalWidget()) | 83 if (window->GetInternalWidget()) |
| 84 children_count++; | 84 children_count++; |
| 85 return "Window" == node->getNodeName() && | 85 return "Window" == node->getNodeName() && |
| 86 window->GetName() == GetAttributeValue("name", node) && | 86 window->aura_window()->GetName() == GetAttributeValue("name", node) && |
| 87 children_count == node->getChildNodeCount(kDefaultChildNodeCount); | 87 children_count == node->getChildNodeCount(kDefaultChildNodeCount); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void Compare(views::Widget* widget, DOM::Node* node) { | 90 void Compare(views::Widget* widget, DOM::Node* node) { |
| 91 EXPECT_EQ("Widget", node->getNodeName()); | 91 EXPECT_EQ("Widget", node->getNodeName()); |
| 92 EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); | 92 EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); |
| 93 EXPECT_EQ(widget->GetRootView() ? 1 : 0, | 93 EXPECT_EQ(widget->GetRootView() ? 1 : 0, |
| 94 node->getChildNodeCount(kDefaultChildNodeCount)); | 94 node->getChildNodeCount(kDefaultChildNodeCount)); |
| 95 } | 95 } |
| 96 | 96 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return -1; | 133 return -1; |
| 134 } | 134 } |
| 135 | 135 |
| 136 WmWindow* GetHighlightingWindow(int root_window_index) { | 136 WmWindow* GetHighlightingWindow(int root_window_index) { |
| 137 WmWindow::Windows overlay_windows = | 137 WmWindow::Windows overlay_windows = |
| 138 WmShell::Get() | 138 WmShell::Get() |
| 139 ->GetAllRootWindows()[root_window_index] | 139 ->GetAllRootWindows()[root_window_index] |
| 140 ->GetChildByShellWindowId(kShellWindowId_OverlayContainer) | 140 ->GetChildByShellWindowId(kShellWindowId_OverlayContainer) |
| 141 ->GetChildren(); | 141 ->GetChildren(); |
| 142 for (WmWindow* window : overlay_windows) { | 142 for (WmWindow* window : overlay_windows) { |
| 143 if (window->GetName() == "HighlightingWidget") | 143 if (window->aura_window()->GetName() == "HighlightingWidget") |
| 144 return window; | 144 return window; |
| 145 } | 145 } |
| 146 NOTREACHED(); | 146 NOTREACHED(); |
| 147 return nullptr; | 147 return nullptr; |
| 148 } | 148 } |
| 149 | 149 |
| 150 std::unique_ptr<DOM::RGBA> SkColorToRGBA(const SkColor& color) { | 150 std::unique_ptr<DOM::RGBA> SkColorToRGBA(const SkColor& color) { |
| 151 return DOM::RGBA::create() | 151 return DOM::RGBA::create() |
| 152 .setA(SkColorGetA(color) / 255) | 152 .setA(SkColorGetA(color) / 255) |
| 153 .setB(SkColorGetB(color)) | 153 .setB(SkColorGetB(color)) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; | 291 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; |
| 292 std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; | 292 std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; |
| 293 | 293 |
| 294 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); | 294 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { | 297 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { |
| 298 std::unique_ptr<views::Widget> widget( | 298 std::unique_ptr<views::Widget> widget( |
| 299 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 299 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
| 300 WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); | 300 WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); |
| 301 parent_window->SetName("parent_window"); | 301 parent_window->aura_window()->SetName("parent_window"); |
| 302 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 302 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); |
| 303 WmWindow* child_window = child_owner->window(); | 303 WmWindow* child_window = child_owner->window(); |
| 304 child_window->SetName("child_window"); | 304 child_window->aura_window()->SetName("child_window"); |
| 305 widget->Show(); | 305 widget->Show(); |
| 306 views::View* child_view = new TestView("child_view"); | 306 views::View* child_view = new TestView("child_view"); |
| 307 widget->GetRootView()->AddChildView(child_view); | 307 widget->GetRootView()->AddChildView(child_view); |
| 308 | 308 |
| 309 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 309 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
| 310 dom_agent()->getDocument(&root); | 310 dom_agent()->getDocument(&root); |
| 311 | 311 |
| 312 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 312 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
| 313 ASSERT_TRUE(parent_node); | 313 ASSERT_TRUE(parent_node); |
| 314 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 314 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); | 765 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
| 766 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 766 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
| 767 | 767 |
| 768 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 768 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", |
| 769 true); | 769 true); |
| 770 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 770 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
| 771 EXPECT_TRUE(root_view->visible()); | 771 EXPECT_TRUE(root_view->visible()); |
| 772 } | 772 } |
| 773 | 773 |
| 774 } // namespace ash | 774 } // namespace ash |
| OLD | NEW |