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" | |
6 #include "ash/devtools/ash_devtools_dom_agent.h" | |
7 #include "ash/devtools/ui_element.h" | |
8 #include "ash/devtools/view_element.h" | |
9 #include "ash/devtools/widget_element.h" | |
10 #include "ash/devtools/window_element.h" | |
11 #include "ash/shell.h" | |
12 #include "ash/test/ash_test_base.h" | |
13 #include "ash/wm/widget_finder.h" | |
14 #include "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
15 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "components/ui_devtools/views/ui_devtools_css_agent.h" |
| 8 #include "components/ui_devtools/views/ui_devtools_dom_agent.h" |
| 9 #include "components/ui_devtools/views/ui_element.h" |
| 10 #include "components/ui_devtools/views/view_element.h" |
| 11 #include "components/ui_devtools/views/widget_element.h" |
| 12 #include "components/ui_devtools/views/window_element.h" |
16 #include "ui/aura/client/window_parenting_client.h" | 13 #include "ui/aura/client/window_parenting_client.h" |
17 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
18 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
19 #include "ui/views/background.h" | 16 #include "ui/views/background.h" |
| 17 #include "ui/views/test/views_test_base.h" |
20 #include "ui/views/widget/native_widget_private.h" | 18 #include "ui/views/widget/native_widget_private.h" |
21 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
22 #include "ui/wm/core/coordinate_conversion.h" | 20 #include "ui/wm/core/coordinate_conversion.h" |
23 | 21 |
24 namespace ash { | 22 namespace ui { |
25 namespace { | 23 namespace { |
26 | 24 |
27 using namespace ui::devtools::protocol; | 25 using namespace ui::devtools::protocol; |
28 | 26 |
29 const int kDefaultChildNodeCount = -1; | 27 const int kDefaultChildNodeCount = -1; |
30 const SkColor kBackgroundColor = SK_ColorRED; | 28 const SkColor kBackgroundColor = SK_ColorRED; |
31 const SkColor kBorderColor = SK_ColorBLUE; | 29 const SkColor kBorderColor = SK_ColorBLUE; |
32 | 30 |
33 class TestView : public views::View { | 31 class TestView : public views::View { |
34 public: | 32 public: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 Array<std::string>* attributes = node->getAttributes(nullptr); | 79 Array<std::string>* attributes = node->getAttributes(nullptr); |
82 for (size_t i = 0; i < attributes->length() - 1; i++) { | 80 for (size_t i = 0; i < attributes->length() - 1; i++) { |
83 if (attributes->get(i) == attribute) | 81 if (attributes->get(i) == attribute) |
84 return attributes->get(i + 1); | 82 return attributes->get(i + 1); |
85 } | 83 } |
86 return nullptr; | 84 return nullptr; |
87 } | 85 } |
88 | 86 |
89 bool Equals(aura::Window* window, DOM::Node* node) { | 87 bool Equals(aura::Window* window, DOM::Node* node) { |
90 int children_count = static_cast<int>(window->children().size()); | 88 int children_count = static_cast<int>(window->children().size()); |
91 if (GetInternalWidgetForWindow(window)) | 89 if (views::Widget::GetWidgetForNativeView(window)) |
92 children_count++; | 90 children_count++; |
93 return "Window" == node->getNodeName() && | 91 return "Window" == node->getNodeName() && |
94 window->GetName() == GetAttributeValue("name", node) && | 92 window->GetName() == GetAttributeValue("name", node) && |
95 children_count == node->getChildNodeCount(kDefaultChildNodeCount); | 93 children_count == node->getChildNodeCount(kDefaultChildNodeCount); |
96 } | 94 } |
97 | 95 |
98 void Compare(views::Widget* widget, DOM::Node* node) { | 96 void Compare(views::Widget* widget, DOM::Node* node) { |
99 EXPECT_EQ("Widget", node->getNodeName()); | 97 EXPECT_EQ("Widget", node->getNodeName()); |
100 EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); | 98 EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node)); |
101 EXPECT_EQ(widget->GetRootView() ? 1 : 0, | 99 EXPECT_EQ(widget->GetRootView() ? 1 : 0, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return DOM::HighlightConfig::create() | 164 return DOM::HighlightConfig::create() |
167 .setContentColor(SkColorToRGBA(background_color)) | 165 .setContentColor(SkColorToRGBA(background_color)) |
168 .setBorderColor(SkColorToRGBA(border_color)) | 166 .setBorderColor(SkColorToRGBA(border_color)) |
169 .build(); | 167 .build(); |
170 } | 168 } |
171 | 169 |
172 void ExpectHighlighted(const gfx::Rect& bounds, aura::Window* root_window) { | 170 void ExpectHighlighted(const gfx::Rect& bounds, aura::Window* root_window) { |
173 aura::Window* highlighting_window = GetHighlightingWindow(root_window); | 171 aura::Window* highlighting_window = GetHighlightingWindow(root_window); |
174 EXPECT_TRUE(highlighting_window->IsVisible()); | 172 EXPECT_TRUE(highlighting_window->IsVisible()); |
175 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); | 173 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); |
176 EXPECT_EQ(kBackgroundColor, GetInternalWidgetForWindow(highlighting_window) | 174 EXPECT_EQ(kBackgroundColor, |
177 ->GetRootView() | 175 views::Widget::GetWidgetForNativeView(highlighting_window) |
178 ->background() | 176 ->GetRootView() |
179 ->get_color()); | 177 ->background() |
| 178 ->get_color()); |
180 } | 179 } |
181 | 180 |
182 } // namespace | 181 } // namespace |
183 | 182 |
184 class AshDevToolsTest : public test::AshTestBase { | 183 class UIDevToolsTest : public views::ViewsTestBase { |
185 public: | 184 public: |
186 AshDevToolsTest() {} | 185 UIDevToolsTest() {} |
187 ~AshDevToolsTest() override {} | 186 ~UIDevToolsTest() override {} |
188 | 187 |
189 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { | 188 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { |
190 views::Widget* widget = new views::Widget; | 189 views::Widget* widget = new views::Widget; |
191 views::Widget::InitParams params; | 190 views::Widget::InitParams params; |
192 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; | 191 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; |
| 192 params.parent = GetPrimaryRootWindow(); |
193 widget->Init(params); | 193 widget->Init(params); |
194 return widget->native_widget_private(); | 194 return widget->native_widget_private(); |
195 } | 195 } |
196 | 196 |
197 std::unique_ptr<views::Widget> CreateTestWidget(const gfx::Rect& bounds) { | 197 std::unique_ptr<views::Widget> CreateTestWidget(const gfx::Rect& bounds) { |
198 return AshTestBase::CreateTestWidget(nullptr, kShellWindowId_Invalid, | 198 std::unique_ptr<views::Widget> widget(new views::Widget); |
199 bounds); | 199 views::Widget::InitParams params; |
| 200 params.delegate = nullptr; |
| 201 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 202 params.bounds = bounds; |
| 203 params.parent = GetPrimaryRootWindow(); |
| 204 widget->Init(params); |
| 205 widget->Show(); |
| 206 return widget; |
| 207 } |
| 208 |
| 209 std::unique_ptr<aura::Window> CreateChildWindow( |
| 210 aura::Window* parent, |
| 211 aura::client::WindowType type = aura::client::WINDOW_TYPE_NORMAL) { |
| 212 std::unique_ptr<aura::Window> window = |
| 213 base::MakeUnique<aura::Window>(nullptr, type); |
| 214 window->Init(ui::LAYER_NOT_DRAWN); |
| 215 window->SetBounds(gfx::Rect()); |
| 216 parent->AddChild(window.get()); |
| 217 window->Show(); |
| 218 return window; |
200 } | 219 } |
201 | 220 |
202 void SetUp() override { | 221 void SetUp() override { |
203 fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>(); | 222 fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>(); |
204 uber_dispatcher_ = | 223 uber_dispatcher_ = |
205 base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get()); | 224 base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get()); |
206 dom_agent_ = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); | 225 dom_agent_ = base::MakeUnique<devtools::UIDevToolsDOMAgent>(); |
207 dom_agent_->Init(uber_dispatcher_.get()); | 226 dom_agent_->Init(uber_dispatcher_.get()); |
208 css_agent_ = | 227 css_agent_ = |
209 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_agent_.get()); | 228 base::MakeUnique<devtools::UIDevToolsCSSAgent>(dom_agent_.get()); |
210 css_agent_->Init(uber_dispatcher_.get()); | 229 css_agent_->Init(uber_dispatcher_.get()); |
211 css_agent_->enable(); | 230 css_agent_->enable(); |
| 231 |
212 // We need to create |dom_agent| first to observe creation of | 232 // We need to create |dom_agent| first to observe creation of |
213 // WindowTreeHosts in AshTestBase::SetUp(). | 233 // WindowTreeHosts in ViewTestBase::SetUp(). |
214 AshTestBase::SetUp(); | 234 views::ViewsTestBase::SetUp(); |
| 235 |
| 236 top_window = CreateChildWindow(GetPrimaryRootWindow()); |
| 237 top_default_container_window = CreateChildWindow(GetPrimaryRootWindow()); |
| 238 top_overlay_window = CreateChildWindow(GetPrimaryRootWindow(), |
| 239 aura::client::WINDOW_TYPE_UNKNOWN); |
215 } | 240 } |
216 | 241 |
217 void TearDown() override { | 242 void TearDown() override { |
| 243 top_overlay_window.reset(); |
| 244 top_default_container_window.reset(); |
| 245 top_window.reset(); |
218 css_agent_.reset(); | 246 css_agent_.reset(); |
219 dom_agent_.reset(); | 247 dom_agent_.reset(); |
220 uber_dispatcher_.reset(); | 248 uber_dispatcher_.reset(); |
221 fake_frontend_channel_.reset(); | 249 fake_frontend_channel_.reset(); |
222 AshTestBase::TearDown(); | 250 views::ViewsTestBase::TearDown(); |
223 } | 251 } |
224 | 252 |
225 void ExpectChildNodeInserted(int parent_id, int prev_sibling_id) { | 253 void ExpectChildNodeInserted(int parent_id, int prev_sibling_id) { |
226 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessageStartsWith( | 254 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessageStartsWith( |
227 base::StringPrintf("{\"method\":\"DOM.childNodeInserted\"," | 255 base::StringPrintf("{\"method\":\"DOM.childNodeInserted\"," |
228 "\"params\":{\"parentNodeId\":%d," | 256 "\"params\":{\"parentNodeId\":%d," |
229 "\"previousNodeId\":%d", | 257 "\"previousNodeId\":%d", |
230 parent_id, prev_sibling_id))); | 258 parent_id, prev_sibling_id))); |
231 } | 259 } |
232 | 260 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 320 |
293 FakeFrontendChannel* frontend_channel() { | 321 FakeFrontendChannel* frontend_channel() { |
294 return fake_frontend_channel_.get(); | 322 return fake_frontend_channel_.get(); |
295 } | 323 } |
296 | 324 |
297 aura::Window* GetPrimaryRootWindow() { | 325 aura::Window* GetPrimaryRootWindow() { |
298 DCHECK(dom_agent()->root_windows().size()); | 326 DCHECK(dom_agent()->root_windows().size()); |
299 return dom_agent()->root_windows()[0]; | 327 return dom_agent()->root_windows()[0]; |
300 } | 328 } |
301 | 329 |
302 devtools::AshDevToolsCSSAgent* css_agent() { return css_agent_.get(); } | 330 devtools::UIDevToolsCSSAgent* css_agent() { return css_agent_.get(); } |
303 devtools::AshDevToolsDOMAgent* dom_agent() { return dom_agent_.get(); } | 331 devtools::UIDevToolsDOMAgent* dom_agent() { return dom_agent_.get(); } |
| 332 |
| 333 std::unique_ptr<aura::Window> top_overlay_window; |
| 334 std::unique_ptr<aura::Window> top_window; |
| 335 std::unique_ptr<aura::Window> top_default_container_window; |
304 | 336 |
305 private: | 337 private: |
306 std::unique_ptr<UberDispatcher> uber_dispatcher_; | 338 std::unique_ptr<UberDispatcher> uber_dispatcher_; |
307 std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; | 339 std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; |
308 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; | 340 std::unique_ptr<devtools::UIDevToolsDOMAgent> dom_agent_; |
309 std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_; | 341 std::unique_ptr<devtools::UIDevToolsCSSAgent> css_agent_; |
310 | 342 |
311 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); | 343 DISALLOW_COPY_AND_ASSIGN(UIDevToolsTest); |
312 }; | 344 }; |
313 | 345 |
314 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { | 346 TEST_F(UIDevToolsTest, GetDocumentWithWindowWidgetView) { |
315 std::unique_ptr<views::Widget> widget( | 347 std::unique_ptr<views::Widget> widget( |
316 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 348 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
317 aura::Window* parent_window = widget->GetNativeWindow(); | 349 aura::Window* parent_window = widget->GetNativeWindow(); |
318 parent_window->SetName("parent_window"); | 350 parent_window->SetName("parent_window"); |
319 std::unique_ptr<aura::Window> child_window = CreateChildWindow(parent_window); | 351 std::unique_ptr<aura::Window> child_window = CreateChildWindow(parent_window); |
320 child_window->SetName("child_window"); | 352 child_window->SetName("child_window"); |
321 widget->Show(); | 353 widget->Show(); |
322 views::View* child_view = new TestView("child_view"); | 354 views::View* child_view = new TestView("child_view"); |
323 widget->GetRootView()->AddChildView(child_view); | 355 widget->GetRootView()->AddChildView(child_view); |
324 | 356 |
325 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 357 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
326 dom_agent()->getDocument(&root); | 358 dom_agent()->getDocument(&root); |
327 | 359 |
328 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 360 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
329 ASSERT_TRUE(parent_node); | 361 ASSERT_TRUE(parent_node); |
330 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 362 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
331 ASSERT_TRUE(parent_children); | 363 ASSERT_TRUE(parent_children); |
332 DOM::Node* widget_node = parent_children->get(0); | 364 DOM::Node* widget_node = parent_children->get(0); |
333 Compare(widget.get(), widget_node); | 365 Compare(widget.get(), widget_node); |
334 Compare(child_window.get(), parent_children->get(1)); | 366 Compare(child_window.get(), parent_children->get(1)); |
335 Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr); | 367 Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr); |
336 ASSERT_TRUE(widget_children); | 368 ASSERT_TRUE(widget_children); |
337 Compare(widget->GetRootView(), widget_children->get(0)); | 369 Compare(widget->GetRootView(), widget_children->get(0)); |
338 ASSERT_TRUE(widget_children->get(0)->getChildren(nullptr)); | 370 ASSERT_TRUE(widget_children->get(0)->getChildren(nullptr)); |
339 Compare(child_view, widget_children->get(0)->getChildren(nullptr)->get(1)); | 371 Compare(child_view, widget_children->get(0)->getChildren(nullptr)->get(1)); |
340 } | 372 } |
341 | 373 |
342 TEST_F(AshDevToolsTest, GetDocumentNativeWidgetOwnsWidget) { | 374 TEST_F(UIDevToolsTest, GetDocumentNativeWidgetOwnsWidget) { |
343 views::internal::NativeWidgetPrivate* native_widget_private = | 375 views::internal::NativeWidgetPrivate* native_widget_private = |
344 CreateTestNativeWidget(); | 376 CreateTestNativeWidget(); |
345 views::Widget* widget = native_widget_private->GetWidget(); | 377 views::Widget* widget = native_widget_private->GetWidget(); |
346 aura::Window* parent_window = widget->GetNativeWindow(); | 378 aura::Window* parent_window = widget->GetNativeWindow(); |
347 | 379 |
348 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 380 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
349 dom_agent()->getDocument(&root); | 381 dom_agent()->getDocument(&root); |
350 | 382 |
351 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 383 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
352 ASSERT_TRUE(parent_node); | 384 ASSERT_TRUE(parent_node); |
353 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 385 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); |
354 Compare(widget, widget_node); | 386 Compare(widget, widget_node); |
355 // Destroy NativeWidget followed by |widget| | 387 // Destroy NativeWidget followed by |widget| |
356 widget->CloseNow(); | 388 widget->CloseNow(); |
357 } | 389 } |
358 | 390 |
359 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { | 391 TEST_F(UIDevToolsTest, WindowAddedChildNodeInserted) { |
360 // Initialize DOMAgent | 392 // Initialize DOMAgent |
| 393 std::unique_ptr<aura::Window> window_child = |
| 394 CreateChildWindow(top_window.get()); |
| 395 |
361 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 396 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
362 dom_agent()->getDocument(&root); | 397 dom_agent()->getDocument(&root); |
363 | 398 |
364 aura::Window* root_window = GetPrimaryRootWindow(); | 399 aura::Window* root_window = GetPrimaryRootWindow(); |
365 aura::Window* parent_window = root_window->children()[0]; | 400 aura::Window* parent_window = root_window->children()[0]; |
366 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 401 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
367 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 402 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
368 DOM::Node* sibling_node = | 403 DOM::Node* sibling_node = |
369 parent_node_children->get(parent_node_children->length() - 1); | 404 parent_node_children->get(parent_node_children->length() - 1); |
370 | 405 |
371 std::unique_ptr<aura::Window> child(CreateChildWindow(parent_window)); | 406 std::unique_ptr<aura::Window> child(CreateChildWindow(parent_window)); |
372 ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); | 407 ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); |
373 } | 408 } |
374 | 409 |
375 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { | 410 TEST_F(UIDevToolsTest, WindowDestroyedChildNodeRemoved) { |
| 411 std::unique_ptr<aura::Window> child_1 = CreateChildWindow(top_window.get()); |
| 412 std::unique_ptr<aura::Window> child_2 = CreateChildWindow(child_1.get()); |
| 413 |
376 // Initialize DOMAgent | 414 // Initialize DOMAgent |
377 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 415 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
378 dom_agent()->getDocument(&root); | 416 dom_agent()->getDocument(&root); |
379 | 417 |
380 aura::Window* root_window = GetPrimaryRootWindow(); | 418 aura::Window* root_window = GetPrimaryRootWindow(); |
381 aura::Window* rotation_window = root_window->children()[0]; | 419 aura::Window* rotation_window = root_window->children()[0]; |
382 aura::Window* parent_window = rotation_window->children()[0]; | 420 aura::Window* parent_window = rotation_window->children()[0]; |
383 aura::Window* child_window = parent_window->children()[0]; | 421 aura::Window* child_window = parent_window->children()[0]; |
384 DOM::Node* root_node = | 422 DOM::Node* root_node = |
385 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 423 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); |
386 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 424 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); |
387 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 425 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); |
388 | 426 |
389 Compare(parent_window, parent_node); | 427 Compare(parent_window, parent_node); |
390 Compare(child_window, child_node); | 428 Compare(child_window, child_node); |
391 delete child_window; | 429 child_2.reset(); |
392 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 430 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
393 } | 431 } |
394 | 432 |
395 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { | 433 TEST_F(UIDevToolsTest, WindowReorganizedChildNodeRearranged) { |
| 434 std::unique_ptr<aura::Window> child_1 = CreateChildWindow(top_window.get()); |
| 435 std::unique_ptr<aura::Window> child_2 = CreateChildWindow(top_window.get()); |
| 436 std::unique_ptr<aura::Window> child_11 = CreateChildWindow(child_1.get()); |
| 437 std::unique_ptr<aura::Window> child_21 = CreateChildWindow(child_2.get()); |
| 438 |
396 // Initialize DOMAgent | 439 // Initialize DOMAgent |
397 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 440 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
398 dom_agent()->getDocument(&root); | 441 dom_agent()->getDocument(&root); |
399 | 442 |
400 aura::Window* root_window = GetPrimaryRootWindow(); | 443 aura::Window* root_window = GetPrimaryRootWindow(); |
401 aura::Window* rotation_window = root_window->children()[0]; | 444 aura::Window* rotation_window = root_window->children()[0]; |
402 aura::Window* parent_window = rotation_window->children()[0]; | 445 aura::Window* parent_window = rotation_window->children()[0]; |
403 aura::Window* target_window = rotation_window->children()[1]; | 446 aura::Window* target_window = rotation_window->children()[1]; |
404 aura::Window* child_window = parent_window->children()[0]; | 447 aura::Window* child_window = parent_window->children()[0]; |
405 | 448 |
406 DOM::Node* root_node = | 449 DOM::Node* root_node = |
407 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 450 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); |
408 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 451 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); |
409 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 452 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); |
410 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 453 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); |
411 DOM::Node* sibling_node = | 454 DOM::Node* sibling_node = |
412 target_node_children->get(target_node_children->length() - 1); | 455 target_node_children->get(target_node_children->length() - 1); |
413 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); | 456 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); |
414 | 457 |
415 Compare(parent_window, parent_node); | 458 Compare(parent_window, parent_node); |
416 Compare(target_window, target_node); | 459 Compare(target_window, target_node); |
417 Compare(child_window, child_node); | 460 Compare(child_window, child_node); |
418 target_window->AddChild(child_window); | 461 target_window->AddChild(child_window); |
419 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 462 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
420 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 463 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); |
421 } | 464 } |
422 | 465 |
423 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { | 466 TEST_F(UIDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { |
| 467 std::unique_ptr<aura::Window> child_1 = CreateChildWindow(top_window.get()); |
| 468 std::unique_ptr<aura::Window> child_2 = CreateChildWindow(top_window.get()); |
| 469 std::unique_ptr<aura::Window> child_21 = CreateChildWindow(child_2.get()); |
| 470 std::unique_ptr<aura::Window> child_22 = CreateChildWindow(child_2.get()); |
| 471 |
424 aura::Window* root_window = GetPrimaryRootWindow(); | 472 aura::Window* root_window = GetPrimaryRootWindow(); |
425 aura::Window* rotation_window = root_window->children()[0]; | 473 aura::Window* rotation_window = root_window->children()[0]; |
426 aura::Window* parent_window = rotation_window->children()[0]; | 474 aura::Window* parent_window = rotation_window->children()[0]; |
427 aura::Window* target_window = rotation_window->children()[1]; | 475 aura::Window* target_window = rotation_window->children()[1]; |
428 std::unique_ptr<aura::Window> child_window(CreateChildWindow(parent_window)); | 476 std::unique_ptr<aura::Window> child_window(CreateChildWindow(parent_window)); |
429 | 477 |
430 // Initialize DOMAgent | 478 // Initialize DOMAgent |
431 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 479 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
432 dom_agent()->getDocument(&root); | 480 dom_agent()->getDocument(&root); |
433 DOM::Node* root_node = | 481 DOM::Node* root_node = |
434 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 482 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); |
435 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); | 483 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); |
436 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); | 484 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); |
437 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); | 485 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); |
438 DOM::Node* sibling_node = | 486 DOM::Node* sibling_node = |
439 target_node_children->get(target_node_children->length() - 1); | 487 target_node_children->get(target_node_children->length() - 1); |
440 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 488 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
441 DOM::Node* child_node = | 489 DOM::Node* child_node = |
442 parent_node_children->get(parent_node_children->length() - 1); | 490 parent_node_children->get(parent_node_children->length() - 1); |
443 | 491 |
444 Compare(parent_window, parent_node); | 492 Compare(parent_window, parent_node); |
445 Compare(target_window, target_node); | 493 Compare(target_window, target_node); |
446 Compare(child_window.get(), child_node); | 494 Compare(child_window.get(), child_node); |
447 parent_window->RemoveChild(child_window.get()); | 495 parent_window->RemoveChild(child_window.get()); |
448 target_window->AddChild(child_window.get()); | 496 target_window->AddChild(child_window.get()); |
449 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); | 497 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); |
450 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); | 498 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); |
451 } | 499 } |
452 | 500 |
453 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { | 501 TEST_F(UIDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { |
| 502 std::unique_ptr<aura::Window> child_11 = CreateChildWindow(top_window.get()); |
| 503 std::unique_ptr<aura::Window> child_12 = CreateChildWindow(top_window.get()); |
| 504 std::unique_ptr<aura::Window> child_13 = CreateChildWindow(top_window.get()); |
| 505 |
454 // Initialize DOMAgent | 506 // Initialize DOMAgent |
455 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 507 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
456 dom_agent()->getDocument(&root); | 508 dom_agent()->getDocument(&root); |
457 | 509 |
458 aura::Window* root_window = GetPrimaryRootWindow(); | 510 aura::Window* root_window = GetPrimaryRootWindow(); |
459 aura::Window* parent_window = root_window->children()[0]; | 511 aura::Window* parent_window = root_window->children()[0]; |
460 aura::Window* child_window = parent_window->children()[0]; | 512 aura::Window* child_window = parent_window->children()[0]; |
461 aura::Window* target_window = parent_window->children()[1]; | 513 aura::Window* target_window = parent_window->children()[1]; |
462 | 514 |
463 DOM::Node* parent_node = | 515 DOM::Node* parent_node = |
464 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); | 516 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0); |
465 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); | 517 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
466 DOM::Node* child_node = parent_node_children->get(0); | 518 DOM::Node* child_node = parent_node_children->get(0); |
467 DOM::Node* sibling_node = parent_node_children->get(1); | 519 DOM::Node* sibling_node = parent_node_children->get(1); |
468 int parent_id = parent_node->getNodeId(); | 520 int parent_id = parent_node->getNodeId(); |
469 | 521 |
470 Compare(parent_window, parent_node); | 522 Compare(parent_window, parent_node); |
471 Compare(child_window, child_node); | 523 Compare(child_window, child_node); |
472 parent_window->StackChildAbove(child_window, target_window); | 524 parent_window->StackChildAbove(child_window, target_window); |
473 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); | 525 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); |
474 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); | 526 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); |
475 } | 527 } |
476 | 528 |
477 TEST_F(AshDevToolsTest, ViewInserted) { | 529 TEST_F(UIDevToolsTest, ViewInserted) { |
478 std::unique_ptr<views::Widget> widget( | 530 std::unique_ptr<views::Widget> widget( |
479 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 531 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
480 aura::Window* window = widget->GetNativeWindow(); | 532 aura::Window* window = widget->GetNativeWindow(); |
481 widget->Show(); | 533 widget->Show(); |
482 | 534 |
483 // Initialize DOMAgent | 535 // Initialize DOMAgent |
484 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 536 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
485 dom_agent()->getDocument(&root); | 537 dom_agent()->getDocument(&root); |
486 | 538 |
487 DOM::Node* parent_node = FindInRoot(window, root.get()); | 539 DOM::Node* parent_node = FindInRoot(window, root.get()); |
488 ASSERT_TRUE(parent_node); | 540 ASSERT_TRUE(parent_node); |
489 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 541 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); |
490 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 542 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); |
491 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 543 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); |
492 ASSERT_TRUE(root_view_children); | 544 ASSERT_TRUE(root_view_children); |
493 DOM::Node* sibling_view_node = | 545 DOM::Node* sibling_view_node = |
494 root_view_children->get(root_view_children->length() - 1); | 546 root_view_children->get(root_view_children->length() - 1); |
495 | 547 |
496 widget->GetRootView()->AddChildView(new views::View); | 548 widget->GetRootView()->AddChildView(new views::View); |
497 ExpectChildNodeInserted(root_view_node->getNodeId(), | 549 ExpectChildNodeInserted(root_view_node->getNodeId(), |
498 sibling_view_node->getNodeId()); | 550 sibling_view_node->getNodeId()); |
499 } | 551 } |
500 | 552 |
501 TEST_F(AshDevToolsTest, ViewRemoved) { | 553 TEST_F(UIDevToolsTest, ViewRemoved) { |
502 std::unique_ptr<views::Widget> widget( | 554 std::unique_ptr<views::Widget> widget( |
503 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 555 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
504 // Need to store |view| in unique_ptr because it is removed from the widget | 556 // Need to store |view| in unique_ptr because it is removed from the widget |
505 // and needs to be destroyed independently | 557 // and needs to be destroyed independently |
506 std::unique_ptr<views::View> child_view = base::MakeUnique<views::View>(); | 558 std::unique_ptr<views::View> child_view = base::MakeUnique<views::View>(); |
507 aura::Window* window = widget->GetNativeWindow(); | 559 aura::Window* window = widget->GetNativeWindow(); |
508 widget->Show(); | 560 widget->Show(); |
509 views::View* root_view = widget->GetRootView(); | 561 views::View* root_view = widget->GetRootView(); |
510 root_view->AddChildView(child_view.get()); | 562 root_view->AddChildView(child_view.get()); |
511 | 563 |
512 // Initialize DOMAgent | 564 // Initialize DOMAgent |
513 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 565 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
514 dom_agent()->getDocument(&root); | 566 dom_agent()->getDocument(&root); |
515 | 567 |
516 DOM::Node* parent_node = FindInRoot(window, root.get()); | 568 DOM::Node* parent_node = FindInRoot(window, root.get()); |
517 ASSERT_TRUE(parent_node); | 569 ASSERT_TRUE(parent_node); |
518 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); | 570 DOM::Node* widget_node = parent_node->getChildren(nullptr)->get(0); |
519 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); | 571 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); |
520 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); | 572 Array<DOM::Node>* root_view_children = root_view_node->getChildren(nullptr); |
521 ASSERT_TRUE(root_view_children); | 573 ASSERT_TRUE(root_view_children); |
522 DOM::Node* child_view_node = | 574 DOM::Node* child_view_node = |
523 root_view_children->get(root_view_children->length() - 1); | 575 root_view_children->get(root_view_children->length() - 1); |
524 | 576 |
525 Compare(child_view.get(), child_view_node); | 577 Compare(child_view.get(), child_view_node); |
526 root_view->RemoveChildView(child_view.get()); | 578 root_view->RemoveChildView(child_view.get()); |
527 ExpectChildNodeRemoved(root_view_node->getNodeId(), | 579 ExpectChildNodeRemoved(root_view_node->getNodeId(), |
528 child_view_node->getNodeId()); | 580 child_view_node->getNodeId()); |
529 } | 581 } |
530 | 582 |
531 TEST_F(AshDevToolsTest, ViewRearranged) { | 583 TEST_F(UIDevToolsTest, ViewRearranged) { |
532 std::unique_ptr<views::Widget> widget( | 584 std::unique_ptr<views::Widget> widget( |
533 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 585 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
534 aura::Window* window = widget->GetNativeWindow(); | 586 aura::Window* window = widget->GetNativeWindow(); |
535 widget->Show(); | 587 widget->Show(); |
536 views::View* root_view = widget->GetRootView(); | 588 views::View* root_view = widget->GetRootView(); |
537 views::View* parent_view = new views::View; | 589 views::View* parent_view = new views::View; |
538 views::View* target_view = new views::View; | 590 views::View* target_view = new views::View; |
539 views::View* child_view = new views::View; | 591 views::View* child_view = new views::View; |
540 views::View* child_view_1 = new views::View; | 592 views::View* child_view_1 = new views::View; |
541 | 593 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 626 ExpectChildNodeRemoved(parent_view_node->getNodeId(), |
575 child_view_node_1->getNodeId()); | 627 child_view_node_1->getNodeId()); |
576 ExpectChildNodeInserted(parent_view_node->getNodeId(), 0); | 628 ExpectChildNodeInserted(parent_view_node->getNodeId(), 0); |
577 | 629 |
578 target_view->AddChildView(child_view); | 630 target_view->AddChildView(child_view); |
579 ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 631 ExpectChildNodeRemoved(parent_view_node->getNodeId(), |
580 child_view_node->getNodeId()); | 632 child_view_node->getNodeId()); |
581 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 633 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); |
582 } | 634 } |
583 | 635 |
584 TEST_F(AshDevToolsTest, ViewRearrangedRemovedAndInserted) { | 636 TEST_F(UIDevToolsTest, ViewRearrangedRemovedAndInserted) { |
585 std::unique_ptr<views::Widget> widget( | 637 std::unique_ptr<views::Widget> widget( |
586 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 638 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
587 aura::Window* window = widget->GetNativeWindow(); | 639 aura::Window* window = widget->GetNativeWindow(); |
588 widget->Show(); | 640 widget->Show(); |
589 views::View* root_view = widget->GetRootView(); | 641 views::View* root_view = widget->GetRootView(); |
590 views::View* parent_view = new views::View; | 642 views::View* parent_view = new views::View; |
591 views::View* target_view = new views::View; | 643 views::View* target_view = new views::View; |
592 views::View* child_view = new views::View; | 644 views::View* child_view = new views::View; |
593 root_view->AddChildView(parent_view); | 645 root_view->AddChildView(parent_view); |
594 root_view->AddChildView(target_view); | 646 root_view->AddChildView(target_view); |
(...skipping 18 matching lines...) Expand all Loading... |
613 Compare(parent_view, parent_view_node); | 665 Compare(parent_view, parent_view_node); |
614 Compare(target_view, target_view_node); | 666 Compare(target_view, target_view_node); |
615 Compare(child_view, child_view_node); | 667 Compare(child_view, child_view_node); |
616 parent_view->RemoveChildView(child_view); | 668 parent_view->RemoveChildView(child_view); |
617 target_view->AddChildView(child_view); | 669 target_view->AddChildView(child_view); |
618 ExpectChildNodeRemoved(parent_view_node->getNodeId(), | 670 ExpectChildNodeRemoved(parent_view_node->getNodeId(), |
619 child_view_node->getNodeId()); | 671 child_view_node->getNodeId()); |
620 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); | 672 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); |
621 } | 673 } |
622 | 674 |
623 TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) { | 675 TEST_F(UIDevToolsTest, WindowWidgetViewHighlight) { |
624 std::unique_ptr<views::Widget> widget( | 676 std::unique_ptr<views::Widget> widget( |
625 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 677 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); |
626 aura::Window* parent_window = widget->GetNativeWindow(); | 678 aura::Window* parent_window = widget->GetNativeWindow(); |
627 std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); | 679 std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); |
628 views::View* root_view = widget->GetRootView(); | 680 views::View* root_view = widget->GetRootView(); |
629 | 681 |
630 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 682 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
631 dom_agent()->getDocument(&root); | 683 dom_agent()->getDocument(&root); |
632 | 684 |
633 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 685 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 if (node_id > 0) | 742 if (node_id > 0) |
691 return node_id; | 743 return node_id; |
692 } | 744 } |
693 } | 745 } |
694 return 0; | 746 return 0; |
695 } | 747 } |
696 | 748 |
697 // TODO(thanhph): Make test AshDevToolsTest.MultipleDisplayHighlight work with | 749 // TODO(thanhph): Make test AshDevToolsTest.MultipleDisplayHighlight work with |
698 // multiple displays. https://crbug.com/726831. | 750 // multiple displays. https://crbug.com/726831. |
699 | 751 |
700 TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { | 752 TEST_F(UIDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { |
701 std::unique_ptr<views::Widget> widget( | 753 std::unique_ptr<views::Widget> widget( |
702 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 754 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
703 aura::Window* parent_window = widget->GetNativeWindow(); | 755 aura::Window* parent_window = widget->GetNativeWindow(); |
704 std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); | 756 std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); |
705 gfx::Rect window_bounds(2, 2, 3, 3); | 757 gfx::Rect window_bounds(2, 2, 3, 3); |
706 gfx::Rect widget_bounds(50, 50, 100, 75); | 758 gfx::Rect widget_bounds(50, 50, 100, 75); |
707 gfx::Rect view_bounds(4, 4, 3, 3); | 759 gfx::Rect view_bounds(4, 4, 3, 3); |
708 window->SetBounds(window_bounds); | 760 window->SetBounds(window_bounds); |
709 widget->SetBounds(widget_bounds); | 761 widget->SetBounds(widget_bounds); |
710 widget->GetRootView()->SetBoundsRect(view_bounds); | 762 widget->GetRootView()->SetBoundsRect(view_bounds); |
711 | 763 |
712 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 764 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
713 dom_agent()->getDocument(&root); | 765 dom_agent()->getDocument(&root); |
714 | 766 |
715 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 767 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
716 ASSERT_TRUE(parent_node); | 768 ASSERT_TRUE(parent_node); |
717 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); | 769 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr); |
718 ASSERT_TRUE(parent_children); | 770 ASSERT_TRUE(parent_children); |
719 | 771 |
720 CompareNodeBounds(parent_node, widget_bounds); | 772 CompareNodeBounds(parent_node, widget_bounds); |
721 CompareNodeBounds(parent_children->get(1), window_bounds); | 773 CompareNodeBounds(parent_children->get(1), window_bounds); |
722 CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0), | 774 CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0), |
723 view_bounds); | 775 view_bounds); |
724 } | 776 } |
725 | 777 |
726 TEST_F(AshDevToolsTest, WindowWidgetViewStyleSheetChanged) { | 778 TEST_F(UIDevToolsTest, WindowWidgetViewStyleSheetChanged) { |
727 std::unique_ptr<views::Widget> widget( | 779 std::unique_ptr<views::Widget> widget( |
728 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); | 780 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); |
729 aura::Window* widget_window = widget->GetNativeWindow(); | 781 aura::Window* widget_window = widget->GetNativeWindow(); |
730 std::unique_ptr<aura::Window> child(CreateChildWindow(widget_window)); | 782 std::unique_ptr<aura::Window> child(CreateChildWindow(widget_window)); |
731 | 783 |
732 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 784 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
733 dom_agent()->getDocument(&root); | 785 dom_agent()->getDocument(&root); |
734 | 786 |
735 gfx::Rect child_bounds(2, 2, 3, 3); | 787 gfx::Rect child_bounds(2, 2, 3, 3); |
736 gfx::Rect widget_bounds(10, 10, 150, 160); | 788 gfx::Rect widget_bounds(10, 10, 150, 160); |
737 gfx::Rect view_bounds(4, 4, 3, 3); | 789 gfx::Rect view_bounds(4, 4, 3, 3); |
738 child->SetBounds(child_bounds); | 790 child->SetBounds(child_bounds); |
739 widget->SetBounds(widget_bounds); | 791 widget->SetBounds(widget_bounds); |
740 widget->GetRootView()->SetBoundsRect(view_bounds); | 792 widget->GetRootView()->SetBoundsRect(view_bounds); |
741 | 793 |
742 DOM::Node* widget_node = FindInRoot(widget_window, root.get()); | 794 DOM::Node* widget_node = FindInRoot(widget_window, root.get()); |
743 ASSERT_TRUE(widget_node); | 795 ASSERT_TRUE(widget_node); |
744 Array<DOM::Node>* widget_node_children = widget_node->getChildren(nullptr); | 796 Array<DOM::Node>* widget_node_children = widget_node->getChildren(nullptr); |
745 ASSERT_TRUE(widget_node_children); | 797 ASSERT_TRUE(widget_node_children); |
746 | 798 |
747 EXPECT_EQ(1, GetStyleSheetChangedCount(widget_node->getNodeId())); | 799 EXPECT_EQ(1, GetStyleSheetChangedCount(widget_node->getNodeId())); |
748 EXPECT_EQ( | 800 EXPECT_EQ( |
749 1, GetStyleSheetChangedCount(widget_node_children->get(1)->getNodeId())); | 801 1, GetStyleSheetChangedCount(widget_node_children->get(1)->getNodeId())); |
750 EXPECT_EQ(2, | 802 EXPECT_EQ(2, GetStyleSheetChangedCount(widget_node_children->get(0) |
751 GetStyleSheetChangedCount(widget_node_children->get(0) | 803 ->getChildren(nullptr) |
752 ->getChildren(nullptr) | 804 ->get(0) |
753 ->get(0) | 805 ->getNodeId())); |
754 ->getNodeId())); | |
755 } | 806 } |
756 | 807 |
757 TEST_F(AshDevToolsTest, WindowWidgetViewSetStyleText) { | 808 TEST_F(UIDevToolsTest, WindowWidgetViewSetStyleText) { |
758 std::unique_ptr<views::Widget> widget( | 809 std::unique_ptr<views::Widget> widget( |
759 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); | 810 CreateTestWidget(gfx::Rect(0, 0, 400, 400))); |
760 aura::Window* parent_window = widget->GetNativeWindow(); | 811 aura::Window* parent_window = widget->GetNativeWindow(); |
761 std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); | 812 std::unique_ptr<aura::Window> window(CreateChildWindow(parent_window)); |
762 views::View* root_view = widget->GetRootView(); | 813 views::View* root_view = widget->GetRootView(); |
763 | 814 |
764 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; | 815 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
765 dom_agent()->getDocument(&root); | 816 dom_agent()->getDocument(&root); |
766 | 817 |
767 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); | 818 DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 870 |
820 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); | 871 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); |
821 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); | 872 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); |
822 | 873 |
823 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", | 874 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", |
824 true); | 875 true); |
825 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); | 876 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); |
826 EXPECT_TRUE(root_view->visible()); | 877 EXPECT_TRUE(root_view->visible()); |
827 } | 878 } |
828 | 879 |
829 } // namespace ash | 880 } // namespace ui |
OLD | NEW |