| 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/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" | 
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" | 
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" | 
| 10 #include "ash/shell_port.h" | 10 #include "ash/test/ash_test_base.h" | 
| 11 #include "ash/test/ash_test.h" |  | 
| 12 #include "ash/wm/widget_finder.h" | 11 #include "ash/wm/widget_finder.h" | 
| 13 #include "ash/wm_window.h" |  | 
| 14 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" | 
| 15 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" | 
| 16 #include "ui/display/display.h" | 14 #include "ui/display/display.h" | 
| 17 #include "ui/views/background.h" | 15 #include "ui/views/background.h" | 
| 18 #include "ui/views/widget/native_widget_private.h" | 16 #include "ui/views/widget/native_widget_private.h" | 
| 19 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" | 
| 20 | 18 | 
| 21 namespace ash { | 19 namespace ash { | 
| 22 namespace { | 20 namespace { | 
| 23 using namespace ui::devtools::protocol; | 21 using namespace ui::devtools::protocol; | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 74 std::string GetAttributeValue(const std::string& attribute, DOM::Node* node) { | 72 std::string GetAttributeValue(const std::string& attribute, DOM::Node* node) { | 
| 75   EXPECT_TRUE(node->hasAttributes()); | 73   EXPECT_TRUE(node->hasAttributes()); | 
| 76   Array<std::string>* attributes = node->getAttributes(nullptr); | 74   Array<std::string>* attributes = node->getAttributes(nullptr); | 
| 77   for (size_t i = 0; i < attributes->length() - 1; i++) { | 75   for (size_t i = 0; i < attributes->length() - 1; i++) { | 
| 78     if (attributes->get(i) == attribute) | 76     if (attributes->get(i) == attribute) | 
| 79       return attributes->get(i + 1); | 77       return attributes->get(i + 1); | 
| 80   } | 78   } | 
| 81   return nullptr; | 79   return nullptr; | 
| 82 } | 80 } | 
| 83 | 81 | 
| 84 bool Equals(WmWindow* window, DOM::Node* node) { | 82 bool Equals(aura::Window* window, DOM::Node* node) { | 
| 85   int children_count = static_cast<int>(window->GetChildren().size()); | 83   int children_count = static_cast<int>(window->children().size()); | 
| 86   if (GetInternalWidgetForWindow(window->aura_window())) | 84   if (GetInternalWidgetForWindow(window)) | 
| 87     children_count++; | 85     children_count++; | 
| 88   return "Window" == node->getNodeName() && | 86   return "Window" == node->getNodeName() && | 
| 89          window->aura_window()->GetName() == GetAttributeValue("name", node) && | 87          window->GetName() == GetAttributeValue("name", node) && | 
| 90          children_count == node->getChildNodeCount(kDefaultChildNodeCount); | 88          children_count == node->getChildNodeCount(kDefaultChildNodeCount); | 
| 91 } | 89 } | 
| 92 | 90 | 
| 93 void Compare(views::Widget* widget, DOM::Node* node) { | 91 void Compare(views::Widget* widget, DOM::Node* node) { | 
| 94   EXPECT_EQ("Widget", node->getNodeName()); | 92   EXPECT_EQ("Widget", node->getNodeName()); | 
| 95   EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); | 93   EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); | 
| 96   EXPECT_EQ(widget->GetRootView() ? 1 : 0, | 94   EXPECT_EQ(widget->GetRootView() ? 1 : 0, | 
| 97             node->getChildNodeCount(kDefaultChildNodeCount)); | 95             node->getChildNodeCount(kDefaultChildNodeCount)); | 
| 98 } | 96 } | 
| 99 | 97 | 
| 100 void Compare(views::View* view, DOM::Node* node) { | 98 void Compare(views::View* view, DOM::Node* node) { | 
| 101   EXPECT_EQ("View", node->getNodeName()); | 99   EXPECT_EQ("View", node->getNodeName()); | 
| 102   EXPECT_EQ(view->GetClassName(), GetAttributeValue("name", node)); | 100   EXPECT_EQ(view->GetClassName(), GetAttributeValue("name", node)); | 
| 103   EXPECT_EQ(view->child_count(), | 101   EXPECT_EQ(view->child_count(), | 
| 104             node->getChildNodeCount(kDefaultChildNodeCount)); | 102             node->getChildNodeCount(kDefaultChildNodeCount)); | 
| 105 } | 103 } | 
| 106 | 104 | 
| 107 void Compare(WmWindow* window, DOM::Node* node) { | 105 void Compare(aura::Window* window, DOM::Node* node) { | 
| 108   EXPECT_TRUE(Equals(window, node)); | 106   EXPECT_TRUE(Equals(window, node)); | 
| 109 } | 107 } | 
| 110 | 108 | 
| 111 DOM::Node* FindInRoot(WmWindow* window, DOM::Node* root) { | 109 DOM::Node* FindInRoot(aura::Window* window, DOM::Node* root) { | 
| 112   if (Equals(window, root)) | 110   if (Equals(window, root)) | 
| 113     return root; | 111     return root; | 
| 114 | 112 | 
| 115   Array<DOM::Node>* children = root->getChildren(nullptr); | 113   Array<DOM::Node>* children = root->getChildren(nullptr); | 
| 116   DOM::Node* window_node = nullptr; | 114   DOM::Node* window_node = nullptr; | 
| 117   for (size_t i = 0; i < children->length(); i++) { | 115   for (size_t i = 0; i < children->length(); i++) { | 
| 118     window_node = FindInRoot(window, children->get(i)); | 116     window_node = FindInRoot(window, children->get(i)); | 
| 119     if (window_node) | 117     if (window_node) | 
| 120       return window_node; | 118       return window_node; | 
| 121   } | 119   } | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 170 void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) { | 168 void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) { | 
| 171   aura::Window* highlighting_window = GetHighlightingWindow(root_window_index); | 169   aura::Window* highlighting_window = GetHighlightingWindow(root_window_index); | 
| 172   EXPECT_TRUE(highlighting_window->IsVisible()); | 170   EXPECT_TRUE(highlighting_window->IsVisible()); | 
| 173   EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); | 171   EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); | 
| 174   EXPECT_EQ(kBackgroundColor, GetInternalWidgetForWindow(highlighting_window) | 172   EXPECT_EQ(kBackgroundColor, GetInternalWidgetForWindow(highlighting_window) | 
| 175                                   ->GetRootView() | 173                                   ->GetRootView() | 
| 176                                   ->background() | 174                                   ->background() | 
| 177                                   ->get_color()); | 175                                   ->get_color()); | 
| 178 } | 176 } | 
| 179 | 177 | 
| 180 WmWindow* GetPrimaryRootWindow() { | 178 aura::Window* GetPrimaryRootWindow() { | 
| 181   return ShellPort::Get()->GetPrimaryRootWindow(); | 179   return Shell::Get()->GetPrimaryRootWindow(); | 
| 182 } | 180 } | 
| 183 | 181 | 
| 184 }  // namespace | 182 }  // namespace | 
| 185 | 183 | 
| 186 class AshDevToolsTest : public AshTest { | 184 class AshDevToolsTest : public test::AshTestBase { | 
| 187  public: | 185  public: | 
| 188   AshDevToolsTest() {} | 186   AshDevToolsTest() {} | 
| 189   ~AshDevToolsTest() override {} | 187   ~AshDevToolsTest() override {} | 
| 190 | 188 | 
| 191   views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { | 189   views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { | 
| 192     views::Widget* widget = new views::Widget; | 190     views::Widget* widget = new views::Widget; | 
| 193     views::Widget::InitParams params; | 191     views::Widget::InitParams params; | 
| 194     params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; | 192     params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; | 
| 195     ShellPort::Get() | 193     Shell::GetPrimaryRootWindowController() | 
| 196         ->GetPrimaryRootWindowController() |  | 
| 197         ->ConfigureWidgetInitParamsForContainer( | 194         ->ConfigureWidgetInitParamsForContainer( | 
| 198             widget, kShellWindowId_DefaultContainer, ¶ms); | 195             widget, kShellWindowId_DefaultContainer, ¶ms); | 
| 199     widget->Init(params); | 196     widget->Init(params); | 
| 200     return widget->native_widget_private(); | 197     return widget->native_widget_private(); | 
| 201   } | 198   } | 
| 202 | 199 | 
|  | 200   std::unique_ptr<views::Widget> CreateTestWidget(const gfx::Rect& bounds) { | 
|  | 201     return AshTestBase::CreateTestWidget(nullptr, kShellWindowId_Invalid, | 
|  | 202                                          bounds); | 
|  | 203   } | 
|  | 204 | 
| 203   void SetUp() override { | 205   void SetUp() override { | 
| 204     AshTest::SetUp(); | 206     AshTestBase::SetUp(); | 
| 205     fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>(); | 207     fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>(); | 
| 206     uber_dispatcher_ = | 208     uber_dispatcher_ = | 
| 207         base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get()); | 209         base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get()); | 
| 208     dom_agent_ = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 210     dom_agent_ = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 
| 209     dom_agent_->Init(uber_dispatcher_.get()); | 211     dom_agent_->Init(uber_dispatcher_.get()); | 
| 210     css_agent_ = | 212     css_agent_ = | 
| 211         base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_agent_.get()); | 213         base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_agent_.get()); | 
| 212     css_agent_->Init(uber_dispatcher_.get()); | 214     css_agent_->Init(uber_dispatcher_.get()); | 
| 213     css_agent_->enable(); | 215     css_agent_->enable(); | 
| 214   } | 216   } | 
| 215 | 217 | 
| 216   void TearDown() override { | 218   void TearDown() override { | 
| 217     css_agent_.reset(); | 219     css_agent_.reset(); | 
| 218     dom_agent_.reset(); | 220     dom_agent_.reset(); | 
| 219     uber_dispatcher_.reset(); | 221     uber_dispatcher_.reset(); | 
| 220     fake_frontend_channel_.reset(); | 222     fake_frontend_channel_.reset(); | 
| 221     AshTest::TearDown(); | 223     AshTestBase::TearDown(); | 
| 222   } | 224   } | 
| 223 | 225 | 
| 224   void ExpectChildNodeInserted(int parent_id, int prev_sibling_id) { | 226   void ExpectChildNodeInserted(int parent_id, int prev_sibling_id) { | 
| 225     EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessageStartsWith( | 227     EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessageStartsWith( | 
| 226                      base::StringPrintf("{\"method\":\"DOM.childNodeInserted\"," | 228                      base::StringPrintf("{\"method\":\"DOM.childNodeInserted\"," | 
| 227                                         "\"params\":{\"parentNodeId\":%d," | 229                                         "\"params\":{\"parentNodeId\":%d," | 
| 228                                         "\"previousNodeId\":%d", | 230                                         "\"previousNodeId\":%d", | 
| 229                                         parent_id, prev_sibling_id))); | 231                                         parent_id, prev_sibling_id))); | 
| 230   } | 232   } | 
| 231 | 233 | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 296   std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; | 298   std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; | 
| 297   std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; | 299   std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; | 
| 298   std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; | 300   std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; | 
| 299 | 301 | 
| 300   DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); | 302   DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); | 
| 301 }; | 303 }; | 
| 302 | 304 | 
| 303 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { | 305 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { | 
| 304   std::unique_ptr<views::Widget> widget( | 306   std::unique_ptr<views::Widget> widget( | 
| 305       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 307       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 306   WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); | 308   aura::Window* parent_window = widget->GetNativeWindow(); | 
| 307   parent_window->aura_window()->SetName("parent_window"); | 309   parent_window->SetName("parent_window"); | 
| 308   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 310   std::unique_ptr<aura::Window> child_window = CreateChildWindow(parent_window); | 
| 309   WmWindow* child_window = child_owner->window(); | 311   child_window->SetName("child_window"); | 
| 310   child_window->aura_window()->SetName("child_window"); |  | 
| 311   widget->Show(); | 312   widget->Show(); | 
| 312   views::View* child_view = new TestView("child_view"); | 313   views::View* child_view = new TestView("child_view"); | 
| 313   widget->GetRootView()->AddChildView(child_view); | 314   widget->GetRootView()->AddChildView(child_view); | 
| 314 | 315 | 
| 315   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 316   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 316   dom_agent()->getDocument(&root); | 317   dom_agent()->getDocument(&root); | 
| 317 | 318 | 
| 318   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 319   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 
| 319   ASSERT_TRUE(parent_node); | 320   ASSERT_TRUE(parent_node); | 
| 320   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 321   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 
| 321   ASSERT_TRUE(parent_children); | 322   ASSERT_TRUE(parent_children); | 
| 322   DOM::Node* widget_node = parent_children->get(0); | 323   DOM::Node* widget_node = parent_children->get(0); | 
| 323   Compare(widget.get(), widget_node); | 324   Compare(widget.get(), widget_node); | 
| 324   Compare(child_window, parent_children->get(1)); | 325   Compare(child_window.get(), parent_children->get(1)); | 
| 325   Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr); | 326   Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr); | 
| 326   ASSERT_TRUE(widget_children); | 327   ASSERT_TRUE(widget_children); | 
| 327   Compare(widget->GetRootView(), widget_children->get(0)); | 328   Compare(widget->GetRootView(), widget_children->get(0)); | 
| 328   ASSERT_TRUE(widget_children->get(0)->getChildren(nullptr)); | 329   ASSERT_TRUE(widget_children->get(0)->getChildren(nullptr)); | 
| 329   Compare(child_view, widget_children->get(0)->getChildren(nullptr)->get(1)); | 330   Compare(child_view, widget_children->get(0)->getChildren(nullptr)->get(1)); | 
| 330 } | 331 } | 
| 331 | 332 | 
| 332 TEST_F(AshDevToolsTest, GetDocumentNativeWidgetOwnsWidget) { | 333 TEST_F(AshDevToolsTest, GetDocumentNativeWidgetOwnsWidget) { | 
| 333   views::internal::NativeWidgetPrivate* native_widget_private = | 334   views::internal::NativeWidgetPrivate* native_widget_private = | 
| 334       CreateTestNativeWidget(); | 335       CreateTestNativeWidget(); | 
| 335   views::Widget* widget = native_widget_private->GetWidget(); | 336   views::Widget* widget = native_widget_private->GetWidget(); | 
| 336   WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); | 337   aura::Window* parent_window = widget->GetNativeWindow(); | 
| 337 | 338 | 
| 338   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 339   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 339   dom_agent()->getDocument(&root); | 340   dom_agent()->getDocument(&root); | 
| 340 | 341 | 
| 341   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 342   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 
| 342   ASSERT_TRUE(parent_node); | 343   ASSERT_TRUE(parent_node); | 
| 343   DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 344   DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 
| 344   Compare(widget, widget_node); | 345   Compare(widget, widget_node); | 
| 345   // Destroy NativeWidget followed by |widget| | 346   // Destroy NativeWidget followed by |widget| | 
| 346   widget->CloseNow(); | 347   widget->CloseNow(); | 
| 347 } | 348 } | 
| 348 | 349 | 
| 349 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { | 350 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { | 
| 350   // Initialize DOMAgent | 351   // Initialize DOMAgent | 
| 351   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 352   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 352   dom_agent()->getDocument(&root); | 353   dom_agent()->getDocument(&root); | 
| 353 | 354 | 
| 354   WmWindow* root_window = GetPrimaryRootWindow(); | 355   aura::Window* root_window = GetPrimaryRootWindow(); | 
| 355   WmWindow* parent_window = root_window->GetChildren()[0]; | 356   aura::Window* parent_window = root_window->children()[0]; | 
| 356   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 357   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 
| 357   Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 358   Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 
| 358   DOM::Node* sibling_node = | 359   DOM::Node* sibling_node = | 
| 359       parent_node_children->get(parent_node_children->length() - 1); | 360       parent_node_children->get(parent_node_children->length() - 1); | 
| 360 | 361 | 
| 361   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 362   std::unique_ptr<aura::Window> child(CreateChildWindow(parent_window)); | 
| 362   ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); | 363   ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); | 
| 363 } | 364 } | 
| 364 | 365 | 
| 365 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { | 366 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { | 
| 366   // Initialize DOMAgent | 367   // Initialize DOMAgent | 
| 367   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 368   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 368   dom_agent()->getDocument(&root); | 369   dom_agent()->getDocument(&root); | 
| 369 | 370 | 
| 370   WmWindow* root_window = GetPrimaryRootWindow(); | 371   aura::Window* root_window = GetPrimaryRootWindow(); | 
| 371   WmWindow* rotation_window = root_window->GetChildren()[0]; | 372   aura::Window* rotation_window = root_window->children()[0]; | 
| 372   WmWindow* parent_window = rotation_window->GetChildren()[0]; | 373   aura::Window* parent_window = rotation_window->children()[0]; | 
| 373   WmWindow* child_window = parent_window->GetChildren()[0]; | 374   aura::Window* child_window = parent_window->children()[0]; | 
| 374   DOM::Node* root_node = | 375   DOM::Node* root_node = | 
| 375       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 376       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 
| 376   DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 377   DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 
| 377   DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 378   DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 
| 378 | 379 | 
| 379   Compare(parent_window, parent_node); | 380   Compare(parent_window, parent_node); | 
| 380   Compare(child_window, child_node); | 381   Compare(child_window, child_node); | 
| 381   child_window->Destroy(); | 382   delete child_window; | 
| 382   ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 383   ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 
| 383 } | 384 } | 
| 384 | 385 | 
| 385 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { | 386 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { | 
| 386   // Initialize DOMAgent | 387   // Initialize DOMAgent | 
| 387   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 388   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 388   dom_agent()->getDocument(&root); | 389   dom_agent()->getDocument(&root); | 
| 389 | 390 | 
| 390   WmWindow* root_window = GetPrimaryRootWindow(); | 391   aura::Window* root_window = GetPrimaryRootWindow(); | 
| 391   WmWindow* rotation_window = root_window->GetChildren()[0]; | 392   aura::Window* rotation_window = root_window->children()[0]; | 
| 392   WmWindow* parent_window = rotation_window->GetChildren()[0]; | 393   aura::Window* parent_window = rotation_window->children()[0]; | 
| 393   WmWindow* target_window = rotation_window->GetChildren()[1]; | 394   aura::Window* target_window = rotation_window->children()[1]; | 
| 394   WmWindow* child_window = parent_window->GetChildren()[0]; | 395   aura::Window* child_window = parent_window->children()[0]; | 
| 395 | 396 | 
| 396   DOM::Node* root_node = | 397   DOM::Node* root_node = | 
| 397       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 398       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 
| 398   DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 399   DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 
| 399   DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 400   DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 
| 400   Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 401   Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 
| 401   DOM::Node* sibling_node = | 402   DOM::Node* sibling_node = | 
| 402       target_node_children->get(target_node_children->length() - 1); | 403       target_node_children->get(target_node_children->length() - 1); | 
| 403   DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 404   DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 
| 404 | 405 | 
| 405   Compare(parent_window, parent_node); | 406   Compare(parent_window, parent_node); | 
| 406   Compare(target_window, target_node); | 407   Compare(target_window, target_node); | 
| 407   Compare(child_window, child_node); | 408   Compare(child_window, child_node); | 
| 408   target_window->AddChild(child_window); | 409   target_window->AddChild(child_window); | 
| 409   ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 410   ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 
| 410   ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 411   ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 
| 411 } | 412 } | 
| 412 | 413 | 
| 413 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { | 414 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { | 
| 414   WmWindow* root_window = GetPrimaryRootWindow(); | 415   aura::Window* root_window = GetPrimaryRootWindow(); | 
| 415   WmWindow* rotation_window = root_window->GetChildren()[0]; | 416   aura::Window* rotation_window = root_window->children()[0]; | 
| 416   WmWindow* parent_window = rotation_window->GetChildren()[0]; | 417   aura::Window* parent_window = rotation_window->children()[0]; | 
| 417   WmWindow* target_window = rotation_window->GetChildren()[1]; | 418   aura::Window* target_window = rotation_window->children()[1]; | 
| 418   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 419   std::unique_ptr<aura::Window> child_window(CreateChildWindow(parent_window)); | 
| 419   WmWindow* child_window = child_owner->window(); |  | 
| 420 | 420 | 
| 421   // Initialize DOMAgent | 421   // Initialize DOMAgent | 
| 422   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 422   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 423   dom_agent()->getDocument(&root); | 423   dom_agent()->getDocument(&root); | 
| 424   DOM::Node* root_node = | 424   DOM::Node* root_node = | 
| 425       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 425       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 
| 426   DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 426   DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 
| 427   DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 427   DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 
| 428   Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 428   Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 
| 429   DOM::Node* sibling_node = | 429   DOM::Node* sibling_node = | 
| 430       target_node_children->get(target_node_children->length() - 1); | 430       target_node_children->get(target_node_children->length() - 1); | 
| 431   Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 431   Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 
| 432   DOM::Node* child_node = | 432   DOM::Node* child_node = | 
| 433       parent_node_children->get(parent_node_children->length() - 1); | 433       parent_node_children->get(parent_node_children->length() - 1); | 
| 434 | 434 | 
| 435   Compare(parent_window, parent_node); | 435   Compare(parent_window, parent_node); | 
| 436   Compare(target_window, target_node); | 436   Compare(target_window, target_node); | 
| 437   Compare(child_window, child_node); | 437   Compare(child_window.get(), child_node); | 
| 438   parent_window->RemoveChild(child_window); | 438   parent_window->RemoveChild(child_window.get()); | 
| 439   target_window->AddChild(child_window); | 439   target_window->AddChild(child_window.get()); | 
| 440   ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 440   ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 
| 441   ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 441   ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 
| 442 } | 442 } | 
| 443 | 443 | 
| 444 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { | 444 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { | 
| 445   // Initialize DOMAgent | 445   // Initialize DOMAgent | 
| 446   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 446   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 447   dom_agent()->getDocument(&root); | 447   dom_agent()->getDocument(&root); | 
| 448 | 448 | 
| 449   WmWindow* root_window = GetPrimaryRootWindow(); | 449   aura::Window* root_window = GetPrimaryRootWindow(); | 
| 450   WmWindow* parent_window = root_window->GetChildren()[0]; | 450   aura::Window* parent_window = root_window->children()[0]; | 
| 451   WmWindow* child_window = parent_window->GetChildren()[0]; | 451   aura::Window* child_window = parent_window->children()[0]; | 
| 452   WmWindow* target_window = parent_window->GetChildren()[1]; | 452   aura::Window* target_window = parent_window->children()[1]; | 
| 453 | 453 | 
| 454   DOM::Node* parent_node = | 454   DOM::Node* parent_node = | 
| 455       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 455       root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 
| 456   Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 456   Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 
| 457   DOM::Node* child_node = parent_node_children->get(0); | 457   DOM::Node* child_node = parent_node_children->get(0); | 
| 458   DOM::Node* sibling_node = parent_node_children->get(1); | 458   DOM::Node* sibling_node = parent_node_children->get(1); | 
| 459   int parent_id = parent_node->getNodeId(); | 459   int parent_id = parent_node->getNodeId(); | 
| 460 | 460 | 
| 461   Compare(parent_window, parent_node); | 461   Compare(parent_window, parent_node); | 
| 462   Compare(child_window, child_node); | 462   Compare(child_window, child_node); | 
| 463   parent_window->StackChildAbove(child_window, target_window); | 463   parent_window->StackChildAbove(child_window, target_window); | 
| 464   ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); | 464   ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); | 
| 465   ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); | 465   ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); | 
| 466 } | 466 } | 
| 467 | 467 | 
| 468 TEST_F(AshDevToolsTest, ViewInserted) { | 468 TEST_F(AshDevToolsTest, ViewInserted) { | 
| 469   std::unique_ptr<views::Widget> widget( | 469   std::unique_ptr<views::Widget> widget( | 
| 470       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 470       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 471   WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); | 471   aura::Window* window = widget->GetNativeWindow(); | 
| 472   widget->Show(); | 472   widget->Show(); | 
| 473 | 473 | 
| 474   // Initialize DOMAgent | 474   // Initialize DOMAgent | 
| 475   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 475   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 476   dom_agent()->getDocument(&root); | 476   dom_agent()->getDocument(&root); | 
| 477 | 477 | 
| 478   DOM::Node* parent_node = FindInRoot(window, root.get()); | 478   DOM::Node* parent_node = FindInRoot(window, root.get()); | 
| 479   ASSERT_TRUE(parent_node); | 479   ASSERT_TRUE(parent_node); | 
| 480   DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 480   DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 
| 481   DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 481   DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 
| 482   Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 482   Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 
| 483   ASSERT_TRUE(root_view_children); | 483   ASSERT_TRUE(root_view_children); | 
| 484   DOM::Node* sibling_view_node = | 484   DOM::Node* sibling_view_node = | 
| 485       root_view_children->get(root_view_children->length() - 1); | 485       root_view_children->get(root_view_children->length() - 1); | 
| 486 | 486 | 
| 487   widget->GetRootView()->AddChildView(new views::View); | 487   widget->GetRootView()->AddChildView(new views::View); | 
| 488   ExpectChildNodeInserted(root_view_node->getNodeId(), | 488   ExpectChildNodeInserted(root_view_node->getNodeId(), | 
| 489                           sibling_view_node->getNodeId()); | 489                           sibling_view_node->getNodeId()); | 
| 490 } | 490 } | 
| 491 | 491 | 
| 492 TEST_F(AshDevToolsTest, ViewRemoved) { | 492 TEST_F(AshDevToolsTest, ViewRemoved) { | 
| 493   std::unique_ptr<views::Widget> widget( | 493   std::unique_ptr<views::Widget> widget( | 
| 494       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 494       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 495   // Need to store |view| in unique_ptr because it is removed from the widget | 495   // Need to store |view| in unique_ptr because it is removed from the widget | 
| 496   // and needs to be destroyed independently | 496   // and needs to be destroyed independently | 
| 497   std::unique_ptr<views::View> child_view = base::MakeUnique<views::View>(); | 497   std::unique_ptr<views::View> child_view = base::MakeUnique<views::View>(); | 
| 498   WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); | 498   aura::Window* window = widget->GetNativeWindow(); | 
| 499   widget->Show(); | 499   widget->Show(); | 
| 500   views::View* root_view = widget->GetRootView(); | 500   views::View* root_view = widget->GetRootView(); | 
| 501   root_view->AddChildView(child_view.get()); | 501   root_view->AddChildView(child_view.get()); | 
| 502 | 502 | 
| 503   // Initialize DOMAgent | 503   // Initialize DOMAgent | 
| 504   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 504   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 505   dom_agent()->getDocument(&root); | 505   dom_agent()->getDocument(&root); | 
| 506 | 506 | 
| 507   DOM::Node* parent_node = FindInRoot(window, root.get()); | 507   DOM::Node* parent_node = FindInRoot(window, root.get()); | 
| 508   ASSERT_TRUE(parent_node); | 508   ASSERT_TRUE(parent_node); | 
| 509   DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 509   DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 
| 510   DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 510   DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 
| 511   Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 511   Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 
| 512   ASSERT_TRUE(root_view_children); | 512   ASSERT_TRUE(root_view_children); | 
| 513   DOM::Node* child_view_node = | 513   DOM::Node* child_view_node = | 
| 514       root_view_children->get(root_view_children->length() - 1); | 514       root_view_children->get(root_view_children->length() - 1); | 
| 515 | 515 | 
| 516   Compare(child_view.get(), child_view_node); | 516   Compare(child_view.get(), child_view_node); | 
| 517   root_view->RemoveChildView(child_view.get()); | 517   root_view->RemoveChildView(child_view.get()); | 
| 518   ExpectChildNodeRemoved(root_view_node->getNodeId(), | 518   ExpectChildNodeRemoved(root_view_node->getNodeId(), | 
| 519                          child_view_node->getNodeId()); | 519                          child_view_node->getNodeId()); | 
| 520 } | 520 } | 
| 521 | 521 | 
| 522 TEST_F(AshDevToolsTest, ViewRearranged) { | 522 TEST_F(AshDevToolsTest, ViewRearranged) { | 
| 523   std::unique_ptr<views::Widget> widget( | 523   std::unique_ptr<views::Widget> widget( | 
| 524       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 524       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 525   WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); | 525   aura::Window* window = widget->GetNativeWindow(); | 
| 526   widget->Show(); | 526   widget->Show(); | 
| 527   views::View* root_view = widget->GetRootView(); | 527   views::View* root_view = widget->GetRootView(); | 
| 528   views::View* parent_view = new views::View; | 528   views::View* parent_view = new views::View; | 
| 529   views::View* target_view = new views::View; | 529   views::View* target_view = new views::View; | 
| 530   views::View* child_view = new views::View; | 530   views::View* child_view = new views::View; | 
| 531   root_view->AddChildView(parent_view); | 531   root_view->AddChildView(parent_view); | 
| 532   root_view->AddChildView(target_view); | 532   root_view->AddChildView(target_view); | 
| 533   parent_view->AddChildView(child_view); | 533   parent_view->AddChildView(child_view); | 
| 534 | 534 | 
| 535   // Initialize DOMAgent | 535   // Initialize DOMAgent | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 553   Compare(child_view, child_view_node); | 553   Compare(child_view, child_view_node); | 
| 554   target_view->AddChildView(child_view); | 554   target_view->AddChildView(child_view); | 
| 555   ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 555   ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 
| 556                          child_view_node->getNodeId()); | 556                          child_view_node->getNodeId()); | 
| 557   ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 557   ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 
| 558 } | 558 } | 
| 559 | 559 | 
| 560 TEST_F(AshDevToolsTest, ViewRearrangedRemovedAndInserted) { | 560 TEST_F(AshDevToolsTest, ViewRearrangedRemovedAndInserted) { | 
| 561   std::unique_ptr<views::Widget> widget( | 561   std::unique_ptr<views::Widget> widget( | 
| 562       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 562       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 563   WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); | 563   aura::Window* window = widget->GetNativeWindow(); | 
| 564   widget->Show(); | 564   widget->Show(); | 
| 565   views::View* root_view = widget->GetRootView(); | 565   views::View* root_view = widget->GetRootView(); | 
| 566   views::View* parent_view = new views::View; | 566   views::View* parent_view = new views::View; | 
| 567   views::View* target_view = new views::View; | 567   views::View* target_view = new views::View; | 
| 568   views::View* child_view = new views::View; | 568   views::View* child_view = new views::View; | 
| 569   root_view->AddChildView(parent_view); | 569   root_view->AddChildView(parent_view); | 
| 570   root_view->AddChildView(target_view); | 570   root_view->AddChildView(target_view); | 
| 571   parent_view->AddChildView(child_view); | 571   parent_view->AddChildView(child_view); | 
| 572 | 572 | 
| 573   // Initialize DOMAgent | 573   // Initialize DOMAgent | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 592   parent_view->RemoveChildView(child_view); | 592   parent_view->RemoveChildView(child_view); | 
| 593   target_view->AddChildView(child_view); | 593   target_view->AddChildView(child_view); | 
| 594   ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 594   ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 
| 595                          child_view_node->getNodeId()); | 595                          child_view_node->getNodeId()); | 
| 596   ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 596   ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 
| 597 } | 597 } | 
| 598 | 598 | 
| 599 TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) { | 599 TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) { | 
| 600   std::unique_ptr<views::Widget> widget( | 600   std::unique_ptr<views::Widget> widget( | 
| 601       CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 601       CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 
| 602   WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); | 602   aura::Window* parent_window = widget->GetNativeWindow(); | 
| 603   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 603   std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); | 
| 604   WmWindow* window = child_owner->window(); |  | 
| 605   views::View* root_view = widget->GetRootView(); | 604   views::View* root_view = widget->GetRootView(); | 
| 606 | 605 | 
| 607   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 606   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 608   dom_agent()->getDocument(&root); | 607   dom_agent()->getDocument(&root); | 
| 609 | 608 | 
| 610   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 609   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 
| 611   ASSERT_TRUE(parent_node); | 610   ASSERT_TRUE(parent_node); | 
| 612   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 611   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 
| 613   ASSERT_TRUE(parent_children); | 612   ASSERT_TRUE(parent_children); | 
| 614   DOM::Node* window_node = parent_children->get(1); | 613   DOM::Node* window_node = parent_children->get(1); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 631   HideHighlight(0); | 630   HideHighlight(0); | 
| 632 | 631 | 
| 633   // Highlight non-existent node | 632   // Highlight non-existent node | 
| 634   HighlightNode(10000); | 633   HighlightNode(10000); | 
| 635   EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); | 634   EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); | 
| 636 } | 635 } | 
| 637 | 636 | 
| 638 TEST_F(AshDevToolsTest, MultipleDisplayHighlight) { | 637 TEST_F(AshDevToolsTest, MultipleDisplayHighlight) { | 
| 639   UpdateDisplay("300x400,500x500"); | 638   UpdateDisplay("300x400,500x500"); | 
| 640 | 639 | 
| 641   WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows(); | 640   aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 
| 642   std::unique_ptr<WindowOwner> window_owner( | 641   std::unique_ptr<aura::Window> window( | 
| 643       CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 642       CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); | 
| 644   WmWindow* window = window_owner->window(); |  | 
| 645 | 643 | 
| 646   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 644   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 647   dom_agent()->getDocument(&root); | 645   dom_agent()->getDocument(&root); | 
| 648 | 646 | 
| 649   EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 647   EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 
| 650   HighlightNode(dom_agent()->GetNodeIdFromWindow(window)); | 648   HighlightNode(dom_agent()->GetNodeIdFromWindow(window.get())); | 
| 651   ExpectHighlighted(window->GetBoundsInScreen(), 0); | 649   ExpectHighlighted(window->GetBoundsInScreen(), 0); | 
| 652 | 650 | 
| 653   window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay()); | 651   window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay()); | 
| 654   EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 652   EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 
| 655   HighlightNode(dom_agent()->GetNodeIdFromWindow(window)); | 653   HighlightNode(dom_agent()->GetNodeIdFromWindow(window.get())); | 
| 656   ExpectHighlighted(window->GetBoundsInScreen(), 1); | 654   ExpectHighlighted(window->GetBoundsInScreen(), 1); | 
| 657 } | 655 } | 
| 658 | 656 | 
| 659 TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { | 657 TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { | 
| 660   std::unique_ptr<views::Widget> widget( | 658   std::unique_ptr<views::Widget> widget( | 
| 661       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 659       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 662   WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); | 660   aura::Window* parent_window = widget->GetNativeWindow(); | 
| 663   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 661   std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); | 
| 664   WmWindow* window = child_owner->window(); |  | 
| 665   gfx::Rect window_bounds(2, 2, 3, 3); | 662   gfx::Rect window_bounds(2, 2, 3, 3); | 
| 666   gfx::Rect widget_bounds(50, 50, 100, 75); | 663   gfx::Rect widget_bounds(50, 50, 100, 75); | 
| 667   gfx::Rect view_bounds(4, 4, 3, 3); | 664   gfx::Rect view_bounds(4, 4, 3, 3); | 
| 668   window->SetBounds(window_bounds); | 665   window->SetBounds(window_bounds); | 
| 669   widget->SetBounds(widget_bounds); | 666   widget->SetBounds(widget_bounds); | 
| 670   widget->GetRootView()->SetBoundsRect(view_bounds); | 667   widget->GetRootView()->SetBoundsRect(view_bounds); | 
| 671 | 668 | 
| 672   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 669   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 673   dom_agent()->getDocument(&root); | 670   dom_agent()->getDocument(&root); | 
| 674 | 671 | 
| 675   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 672   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 
| 676   ASSERT_TRUE(parent_node); | 673   ASSERT_TRUE(parent_node); | 
| 677   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 674   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 
| 678   ASSERT_TRUE(parent_children); | 675   ASSERT_TRUE(parent_children); | 
| 679 | 676 | 
| 680   CompareNodeBounds(parent_node, widget_bounds); | 677   CompareNodeBounds(parent_node, widget_bounds); | 
| 681   CompareNodeBounds(parent_children->get(1), window_bounds); | 678   CompareNodeBounds(parent_children->get(1), window_bounds); | 
| 682   CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0), | 679   CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0), | 
| 683                     view_bounds); | 680                     view_bounds); | 
| 684 } | 681 } | 
| 685 | 682 | 
| 686 TEST_F(AshDevToolsTest, WindowWidgetViewStyleSheetChanged) { | 683 TEST_F(AshDevToolsTest, WindowWidgetViewStyleSheetChanged) { | 
| 687   std::unique_ptr<views::Widget> widget( | 684   std::unique_ptr<views::Widget> widget( | 
| 688       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 685       CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 
| 689   WmWindow* widget_window = WmWindow::Get(widget->GetNativeWindow()); | 686   aura::Window* widget_window = widget->GetNativeWindow(); | 
| 690   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(widget_window)); | 687   std::unique_ptr<aura::Window> child(CreateChildWindow(widget_window)); | 
| 691   WmWindow* child = child_owner->window(); |  | 
| 692 | 688 | 
| 693   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 689   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 694   dom_agent()->getDocument(&root); | 690   dom_agent()->getDocument(&root); | 
| 695 | 691 | 
| 696   gfx::Rect child_bounds(2, 2, 3, 3); | 692   gfx::Rect child_bounds(2, 2, 3, 3); | 
| 697   gfx::Rect widget_bounds(10, 10, 150, 160); | 693   gfx::Rect widget_bounds(10, 10, 150, 160); | 
| 698   gfx::Rect view_bounds(4, 4, 3, 3); | 694   gfx::Rect view_bounds(4, 4, 3, 3); | 
| 699   child->SetBounds(child_bounds); | 695   child->SetBounds(child_bounds); | 
| 700   widget->SetBounds(widget_bounds); | 696   widget->SetBounds(widget_bounds); | 
| 701   widget->GetRootView()->SetBoundsRect(view_bounds); | 697   widget->GetRootView()->SetBoundsRect(view_bounds); | 
| 702 | 698 | 
| 703   DOM::Node* widget_node = FindInRoot(widget_window, root.get()); | 699   DOM::Node* widget_node = FindInRoot(widget_window, root.get()); | 
| 704   ASSERT_TRUE(widget_node); | 700   ASSERT_TRUE(widget_node); | 
| 705   Array<DOM::Node>* widget_node_children = widget_node->getChildren(nullptr); | 701   Array<DOM::Node>* widget_node_children = widget_node->getChildren(nullptr); | 
| 706   ASSERT_TRUE(widget_node_children); | 702   ASSERT_TRUE(widget_node_children); | 
| 707 | 703 | 
| 708   EXPECT_EQ(1, GetStyleSheetChangedCount(widget_node->getNodeId())); | 704   EXPECT_EQ(1, GetStyleSheetChangedCount(widget_node->getNodeId())); | 
| 709   EXPECT_EQ( | 705   EXPECT_EQ( | 
| 710       1, GetStyleSheetChangedCount(widget_node_children->get(1)->getNodeId())); | 706       1, GetStyleSheetChangedCount(widget_node_children->get(1)->getNodeId())); | 
| 711   EXPECT_EQ(2, | 707   EXPECT_EQ(2, | 
| 712             GetStyleSheetChangedCount(widget_node_children->get(0) | 708             GetStyleSheetChangedCount(widget_node_children->get(0) | 
| 713                                           ->getChildren(nullptr) | 709                                           ->getChildren(nullptr) | 
| 714                                           ->get(0) | 710                                           ->get(0) | 
| 715                                           ->getNodeId())); | 711                                           ->getNodeId())); | 
| 716 } | 712 } | 
| 717 | 713 | 
| 718 TEST_F(AshDevToolsTest, WindowWidgetViewSetStyleText) { | 714 TEST_F(AshDevToolsTest, WindowWidgetViewSetStyleText) { | 
| 719   std::unique_ptr<views::Widget> widget( | 715   std::unique_ptr<views::Widget> widget( | 
| 720       CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 716       CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 
| 721   WmWindow* parent_window = WmWindow::Get(widget->GetNativeWindow()); | 717   aura::Window* parent_window = widget->GetNativeWindow(); | 
| 722   std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); | 718   std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); | 
| 723   WmWindow* window = child_owner->window(); |  | 
| 724   views::View* root_view = widget->GetRootView(); | 719   views::View* root_view = widget->GetRootView(); | 
| 725 | 720 | 
| 726   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 721   std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 
| 727   dom_agent()->getDocument(&root); | 722   dom_agent()->getDocument(&root); | 
| 728 | 723 | 
| 729   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 724   DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 
| 730   ASSERT_TRUE(parent_node); | 725   ASSERT_TRUE(parent_node); | 
| 731   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 726   Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 
| 732   ASSERT_TRUE(parent_children); | 727   ASSERT_TRUE(parent_children); | 
| 733 | 728 | 
| 734   // Test different combinations on window node | 729   // Test different combinations on window node | 
| 735   DOM::Node* window_node = parent_children->get(1); | 730   DOM::Node* window_node = parent_children->get(1); | 
| 736 | 731 | 
| 737   SetStyleTexts(window_node, | 732   SetStyleTexts(window_node, | 
| 738                 "x: 25; y:35; width: 5; height: 20; visibility: 1;", true); | 733                 "x: 25; y:35; width: 5; height: 20; visibility: 1;", true); | 
| 739   EXPECT_EQ(gfx::Rect(25, 35, 5, 20), window->GetBounds()); | 734   EXPECT_EQ(gfx::Rect(25, 35, 5, 20), window->bounds()); | 
| 740   EXPECT_TRUE(window->IsVisible()); | 735   EXPECT_TRUE(window->IsVisible()); | 
| 741 | 736 | 
| 742   SetStyleTexts(window_node, "test_nothing_happens:1;", false); | 737   SetStyleTexts(window_node, "test_nothing_happens:1;", false); | 
| 743   EXPECT_EQ(gfx::Rect(25, 35, 5, 20), window->GetBounds());  // Not changed | 738   EXPECT_EQ(gfx::Rect(25, 35, 5, 20), window->bounds());  // Not changed | 
| 744 | 739 | 
| 745   SetStyleTexts(window_node, "\nheight: 10;\nvisibility: 0;\n", true); | 740   SetStyleTexts(window_node, "\nheight: 10;\nvisibility: 0;\n", true); | 
| 746   EXPECT_EQ(gfx::Rect(25, 35, 5, 10), window->GetBounds()); | 741   EXPECT_EQ(gfx::Rect(25, 35, 5, 10), window->bounds()); | 
| 747   EXPECT_FALSE(window->IsVisible()); | 742   EXPECT_FALSE(window->IsVisible()); | 
| 748 | 743 | 
| 749   SetStyleTexts(window_node, "\nx: 10; y: 23; width: 52;\n  ", true); | 744   SetStyleTexts(window_node, "\nx: 10; y: 23; width: 52;\n  ", true); | 
| 750   EXPECT_EQ(gfx::Rect(10, 23, 52, 10), window->GetBounds()); | 745   EXPECT_EQ(gfx::Rect(10, 23, 52, 10), window->bounds()); | 
| 751 | 746 | 
| 752   // Test different combinations on widget node | 747   // Test different combinations on widget node | 
| 753   DOM::Node* widget_node = parent_children->get(0); | 748   DOM::Node* widget_node = parent_children->get(0); | 
| 754 | 749 | 
| 755   SetStyleTexts(widget_node, | 750   SetStyleTexts(widget_node, | 
| 756                 "x: 25; y:35; width: 53; height: 64; visibility: 0;", true); | 751                 "x: 25; y:35; width: 53; height: 64; visibility: 0;", true); | 
| 757   EXPECT_EQ(gfx::Rect(25, 35, 53, 64), widget->GetRestoredBounds()); | 752   EXPECT_EQ(gfx::Rect(25, 35, 53, 64), widget->GetRestoredBounds()); | 
| 758   EXPECT_FALSE(widget->IsVisible()); | 753   EXPECT_FALSE(widget->IsVisible()); | 
| 759 | 754 | 
| 760   SetStyleTexts(widget_node, "test_nothing_happens:1;", false); | 755   SetStyleTexts(widget_node, "test_nothing_happens:1;", false); | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 782   SetStyleTexts(root_view_node, "\nheight: 73;\n  ", true); | 777   SetStyleTexts(root_view_node, "\nheight: 73;\n  ", true); | 
| 783   EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 778   EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 
| 784 | 779 | 
| 785   SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 780   SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 
| 786                 true); | 781                 true); | 
| 787   EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 782   EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 
| 788   EXPECT_TRUE(root_view->visible()); | 783   EXPECT_TRUE(root_view->visible()); | 
| 789 } | 784 } | 
| 790 | 785 | 
| 791 }  // namespace ash | 786 }  // namespace ash | 
| OLD | NEW | 
|---|