| 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" |
| 11 #include "ash/wm/widget_finder.h" |
| 11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
| 14 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
| 15 #include "ui/views/widget/native_widget_private.h" | 16 #include "ui/views/widget/native_widget_private.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace { | 20 namespace { |
| 20 using namespace ui::devtools::protocol; | 21 using namespace ui::devtools::protocol; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 Array<std::string>* attributes = node->getAttributes(nullptr); | 74 Array<std::string>* attributes = node->getAttributes(nullptr); |
| 74 for (size_t i = 0; i < attributes->length() - 1; i++) { | 75 for (size_t i = 0; i < attributes->length() - 1; i++) { |
| 75 if (attributes->get(i) == attribute) | 76 if (attributes->get(i) == attribute) |
| 76 return attributes->get(i + 1); | 77 return attributes->get(i + 1); |
| 77 } | 78 } |
| 78 return nullptr; | 79 return nullptr; |
| 79 } | 80 } |
| 80 | 81 |
| 81 bool Equals(WmWindow* window, DOM::Node* node) { | 82 bool Equals(WmWindow* window, DOM::Node* node) { |
| 82 int children_count = static_cast<int>(window->GetChildren().size()); | 83 int children_count = static_cast<int>(window->GetChildren().size()); |
| 83 if (window->GetInternalWidget()) | 84 if (GetInternalWidgetForWindow(window->aura_window())) |
| 84 children_count++; | 85 children_count++; |
| 85 return "Window" == node->getNodeName() && | 86 return "Window" == node->getNodeName() && |
| 86 window->aura_window()->GetName() == GetAttributeValue("name", node) && | 87 window->aura_window()->GetName() == GetAttributeValue("name", node) && |
| 87 children_count == node->getChildNodeCount(kDefaultChildNodeCount); | 88 children_count == node->getChildNodeCount(kDefaultChildNodeCount); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void Compare(views::Widget* widget, DOM::Node* node) { | 91 void Compare(views::Widget* widget, DOM::Node* node) { |
| 91 EXPECT_EQ("Widget", node->getNodeName()); | 92 EXPECT_EQ("Widget", node->getNodeName()); |
| 92 EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); | 93 EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); |
| 93 EXPECT_EQ(widget->GetRootView() ? 1 : 0, | 94 EXPECT_EQ(widget->GetRootView() ? 1 : 0, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 return DOM::HighlightConfig::create() | 163 return DOM::HighlightConfig::create() |
| 163 .setContentColor(SkColorToRGBA(background_color)) | 164 .setContentColor(SkColorToRGBA(background_color)) |
| 164 .setBorderColor(SkColorToRGBA(border_color)) | 165 .setBorderColor(SkColorToRGBA(border_color)) |
| 165 .build(); | 166 .build(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) { | 169 void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) { |
| 169 WmWindow* highlighting_window = GetHighlightingWindow(root_window_index); | 170 WmWindow* highlighting_window = GetHighlightingWindow(root_window_index); |
| 170 EXPECT_TRUE(highlighting_window->IsVisible()); | 171 EXPECT_TRUE(highlighting_window->IsVisible()); |
| 171 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); | 172 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); |
| 172 EXPECT_EQ(kBackgroundColor, highlighting_window->GetInternalWidget() | 173 EXPECT_EQ(kBackgroundColor, |
| 173 ->GetRootView() | 174 GetInternalWidgetForWindow(highlighting_window->aura_window()) |
| 174 ->background() | 175 ->GetRootView() |
| 175 ->get_color()); | 176 ->background() |
| 177 ->get_color()); |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace | 180 } // namespace |
| 179 | 181 |
| 180 class AshDevToolsTest : public AshTest { | 182 class AshDevToolsTest : public AshTest { |
| 181 public: | 183 public: |
| 182 AshDevToolsTest() {} | 184 AshDevToolsTest() {} |
| 183 ~AshDevToolsTest() override {} | 185 ~AshDevToolsTest() override {} |
| 184 | 186 |
| 185 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { | 187 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); | 767 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
| 766 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 768 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
| 767 | 769 |
| 768 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 770 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", |
| 769 true); | 771 true); |
| 770 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 772 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
| 771 EXPECT_TRUE(root_view->visible()); | 773 EXPECT_TRUE(root_view->visible()); |
| 772 } | 774 } |
| 773 | 775 |
| 774 } // namespace ash | 776 } // namespace ash |
| OLD | NEW |