Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: ash/devtools/ash_devtools_unittest.cc

Issue 2786563003: Add a NOT_DRAWN window in between the root_window and its children. (Closed)
Patch Set: Fix nits in patch 5. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/public/cpp/shell_window_ids.h » ('j') | ash/wm/root_window_layout_manager.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/root_window_controller.h" 8 #include "ash/root_window_controller.h"
8 #include "ash/test/ash_test.h" 9 #include "ash/test/ash_test.h"
9 #include "ash/wm/widget_finder.h" 10 #include "ash/wm/widget_finder.h"
10 #include "ash/wm_shell.h" 11 #include "ash/wm_shell.h"
11 #include "ash/wm_window.h" 12 #include "ash/wm_window.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "ui/display/display.h" 15 #include "ui/display/display.h"
15 #include "ui/views/background.h" 16 #include "ui/views/background.h"
16 #include "ui/views/widget/native_widget_private.h" 17 #include "ui/views/widget/native_widget_private.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 WmWindow* highlighting_window = GetHighlightingWindow(root_window_index); 171 WmWindow* highlighting_window = GetHighlightingWindow(root_window_index);
171 EXPECT_TRUE(highlighting_window->IsVisible()); 172 EXPECT_TRUE(highlighting_window->IsVisible());
172 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); 173 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen());
173 EXPECT_EQ(kBackgroundColor, 174 EXPECT_EQ(kBackgroundColor,
174 GetInternalWidgetForWindow(highlighting_window->aura_window()) 175 GetInternalWidgetForWindow(highlighting_window->aura_window())
175 ->GetRootView() 176 ->GetRootView()
176 ->background() 177 ->background()
177 ->get_color()); 178 ->get_color());
178 } 179 }
179 180
181 WmWindow* GetPrimaryRootWindow() {
182 return WmShell::Get()->GetPrimaryRootWindow();
183 }
184
180 } // namespace 185 } // namespace
181 186
182 class AshDevToolsTest : public AshTest { 187 class AshDevToolsTest : public AshTest {
183 public: 188 public:
184 AshDevToolsTest() {} 189 AshDevToolsTest() {}
185 ~AshDevToolsTest() override {} 190 ~AshDevToolsTest() override {}
186 191
187 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { 192 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() {
188 views::Widget* widget = new views::Widget; 193 views::Widget* widget = new views::Widget;
189 views::Widget::InitParams params; 194 views::Widget::InitParams params;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 Compare(widget, widget_node); 345 Compare(widget, widget_node);
341 // Destroy NativeWidget followed by |widget| 346 // Destroy NativeWidget followed by |widget|
342 widget->CloseNow(); 347 widget->CloseNow();
343 } 348 }
344 349
345 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { 350 TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) {
346 // Initialize DOMAgent 351 // Initialize DOMAgent
347 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 352 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
348 dom_agent()->getDocument(&root); 353 dom_agent()->getDocument(&root);
349 354
350 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 355 WmWindow* root_window = GetPrimaryRootWindow();
351 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 356 WmWindow* parent_window = root_window->GetChildren()[0];
357 DOM::Node* parent_node = FindInRoot(parent_window, root.get());
352 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 358 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
353 DOM::Node* sibling_node = 359 DOM::Node* sibling_node =
354 parent_node_children->get(parent_node_children->length() - 1); 360 parent_node_children->get(parent_node_children->length() - 1);
355 361
356 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); 362 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
357 ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId()); 363 ExpectChildNodeInserted(parent_node->getNodeId(), sibling_node->getNodeId());
358 } 364 }
359 365
360 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { 366 TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) {
361 // Initialize DOMAgent 367 // Initialize DOMAgent
362 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 368 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
363 dom_agent()->getDocument(&root); 369 dom_agent()->getDocument(&root);
364 370
365 WmWindow* parent_window = 371 WmWindow* root_window = GetPrimaryRootWindow();
366 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; 372 WmWindow* rotation_window = root_window->GetChildren()[0];
373 WmWindow* parent_window = rotation_window->GetChildren()[0];
367 WmWindow* child_window = parent_window->GetChildren()[0]; 374 WmWindow* child_window = parent_window->GetChildren()[0];
368 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 375 DOM::Node* root_node =
376 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
369 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 377 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
370 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 378 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
371 379
372 Compare(parent_window, parent_node); 380 Compare(parent_window, parent_node);
373 Compare(child_window, child_node); 381 Compare(child_window, child_node);
374 child_window->Destroy(); 382 child_window->Destroy();
375 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 383 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
376 } 384 }
377 385
378 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { 386 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) {
379 // Initialize DOMAgent 387 // Initialize DOMAgent
380 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 388 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
381 dom_agent()->getDocument(&root); 389 dom_agent()->getDocument(&root);
382 390
383 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 391 WmWindow* root_window = GetPrimaryRootWindow();
384 WmWindow* target_window = root_window->GetChildren()[1]; 392 WmWindow* rotation_window = root_window->GetChildren()[0];
385 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; 393 WmWindow* parent_window = rotation_window->GetChildren()[0];
386 394 WmWindow* target_window = rotation_window->GetChildren()[1];
387 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 395 WmWindow* child_window = parent_window->GetChildren()[0];
396 DOM::Node* root_node =
397 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
388 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 398 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
389 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 399 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
390 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 400 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
391 DOM::Node* sibling_node = 401 DOM::Node* sibling_node =
392 target_node_children->get(target_node_children->length() - 1); 402 target_node_children->get(target_node_children->length() - 1);
393 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 403 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
394 404
405 Compare(parent_window, parent_node);
395 Compare(target_window, target_node); 406 Compare(target_window, target_node);
396 Compare(child_window, child_node); 407 Compare(child_window, child_node);
397 target_window->AddChild(child_window); 408 target_window->AddChild(child_window);
398 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 409 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
399 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 410 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
400 } 411 }
401 412
402 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { 413 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
403 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 414 WmWindow* root_window = GetPrimaryRootWindow();
404 WmWindow* target_window = root_window->GetChildren()[1]; 415 WmWindow* rotation_window = root_window->GetChildren()[0];
405 WmWindow* parent_window = root_window->GetChildren()[0]; 416 WmWindow* parent_window = rotation_window->GetChildren()[0];
417 WmWindow* target_window = rotation_window->GetChildren()[1];
406 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); 418 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
407 WmWindow* child_window = child_owner->window(); 419 WmWindow* child_window = child_owner->window();
408 420
409 // Initialize DOMAgent 421 // Initialize DOMAgent
410 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 422 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
411 dom_agent()->getDocument(&root); 423 dom_agent()->getDocument(&root);
412 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 424 DOM::Node* root_node =
413 425 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
414 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 426 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
415 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 427 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
416 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 428 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
417 DOM::Node* sibling_node = 429 DOM::Node* sibling_node =
418 target_node_children->get(target_node_children->length() - 1); 430 target_node_children->get(target_node_children->length() - 1);
419 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 431 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
420 DOM::Node* child_node = 432 DOM::Node* child_node =
421 parent_node_children->get(parent_node_children->length() - 1); 433 parent_node_children->get(parent_node_children->length() - 1);
422 434
435 Compare(parent_window, parent_node);
423 Compare(target_window, target_node); 436 Compare(target_window, target_node);
424 Compare(child_window, child_node); 437 Compare(child_window, child_node);
425 parent_window->RemoveChild(child_window); 438 parent_window->RemoveChild(child_window);
426 target_window->AddChild(child_window); 439 target_window->AddChild(child_window);
427 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 440 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
428 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 441 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
429 } 442 }
430 443
431 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { 444 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
432 // Initialize DOMAgent 445 // Initialize DOMAgent
433 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 446 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
434 dom_agent()->getDocument(&root); 447 dom_agent()->getDocument(&root);
435 448
436 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 449 WmWindow* root_window = GetPrimaryRootWindow();
450 WmWindow* parent_window = root_window->GetChildren()[0];
437 WmWindow* child_window = parent_window->GetChildren()[0]; 451 WmWindow* child_window = parent_window->GetChildren()[0];
438 WmWindow* target_window = parent_window->GetChildren()[1]; 452 WmWindow* target_window = parent_window->GetChildren()[1];
439 453
440 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 454 DOM::Node* parent_node =
455 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
441 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 456 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
442 DOM::Node* child_node = parent_node_children->get(0); 457 DOM::Node* child_node = parent_node_children->get(0);
443 DOM::Node* sibling_node = parent_node_children->get(1); 458 DOM::Node* sibling_node = parent_node_children->get(1);
444 int parent_id = parent_node->getNodeId(); 459 int parent_id = parent_node->getNodeId();
445 460
446 Compare(parent_window, parent_node); 461 Compare(parent_window, parent_node);
447 Compare(child_window, child_node); 462 Compare(child_window, child_node);
448 parent_window->StackChildAbove(child_window, target_window); 463 parent_window->StackChildAbove(child_window, target_window);
449 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); 464 ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
450 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); 465 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId());
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true); 782 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true);
768 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); 783 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds());
769 784
770 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", 785 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n",
771 true); 786 true);
772 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); 787 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds());
773 EXPECT_TRUE(root_view->visible()); 788 EXPECT_TRUE(root_view->visible());
774 } 789 }
775 790
776 } // namespace ash 791 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/public/cpp/shell_window_ids.h » ('j') | ash/wm/root_window_layout_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698