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

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: Add helper function to get WmWindow by Shell Id. 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/public/cpp/shell_window_ids.h » ('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* GetWindowByShellId(int id) {
182 return WmShell::Get()->GetPrimaryRootWindow()->GetChildByShellWindowId(id);
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* parent_window =
351 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 356 GetWindowByShellId(kShellWindowId_ScreenRotationContainer);
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* parent_window =
366 WmShell::Get()->GetPrimaryRootWindow()->GetChildren()[0]; 372 GetWindowByShellId(kShellWindowId_WallpaperContainer);
367 WmWindow* child_window = parent_window->GetChildren()[0]; 373 WmWindow* child_window = parent_window->GetChildren()[0];
368 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 374 DOM::Node* root_node =
375 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
369 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 376 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
370 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 377 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
371 378
372 Compare(parent_window, parent_node); 379 Compare(parent_window, parent_node);
373 Compare(child_window, child_node); 380 Compare(child_window, child_node);
374 child_window->Destroy(); 381 child_window->Destroy();
375 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 382 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
376 } 383 }
377 384
378 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { 385 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) {
379 // Initialize DOMAgent 386 // Initialize DOMAgent
380 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 387 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
381 dom_agent()->getDocument(&root); 388 dom_agent()->getDocument(&root);
382 389
383 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 390 WmWindow* target_window =
384 WmWindow* target_window = root_window->GetChildren()[1]; 391 GetWindowByShellId(kShellWindowId_NonLockScreenContainersContainer);
sadrul 2017/04/13 17:09:42 These look ... weird. Can you do: WmWindow* root_
wutao 2017/04/13 18:09:39 Done.
385 WmWindow* child_window = root_window->GetChildren()[0]->GetChildren()[0]; 392 WmWindow* parent_window =
386 393 GetWindowByShellId(kShellWindowId_WallpaperContainer);
387 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 394 WmWindow* child_window = parent_window->GetChildren()[0];
395 DOM::Node* root_node =
396 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
388 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 397 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
389 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 398 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
390 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 399 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
391 DOM::Node* sibling_node = 400 DOM::Node* sibling_node =
392 target_node_children->get(target_node_children->length() - 1); 401 target_node_children->get(target_node_children->length() - 1);
393 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0); 402 DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
394 403
404 Compare(parent_window, parent_node);
395 Compare(target_window, target_node); 405 Compare(target_window, target_node);
396 Compare(child_window, child_node); 406 Compare(child_window, child_node);
397 target_window->AddChild(child_window); 407 target_window->AddChild(child_window);
398 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 408 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
399 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 409 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
400 } 410 }
401 411
402 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { 412 TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
403 WmWindow* root_window = WmShell::Get()->GetPrimaryRootWindow(); 413 WmWindow* target_window =
404 WmWindow* target_window = root_window->GetChildren()[1]; 414 GetWindowByShellId(kShellWindowId_NonLockScreenContainersContainer);
405 WmWindow* parent_window = root_window->GetChildren()[0]; 415 WmWindow* parent_window =
416 GetWindowByShellId(kShellWindowId_WallpaperContainer);
sadrul 2017/04/13 17:09:42 As above, go to target_window and parent_window th
wutao 2017/04/13 18:09:39 Done.
406 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); 417 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
407 WmWindow* child_window = child_owner->window(); 418 WmWindow* child_window = child_owner->window();
408 419
409 // Initialize DOMAgent 420 // Initialize DOMAgent
410 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 421 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
411 dom_agent()->getDocument(&root); 422 dom_agent()->getDocument(&root);
412 DOM::Node* root_node = root->getChildren(nullptr)->get(0); 423 DOM::Node* root_node =
413 424 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
414 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0); 425 DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
415 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1); 426 DOM::Node* target_node = root_node->getChildren(nullptr)->get(1);
416 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr); 427 Array<DOM::Node>* target_node_children = target_node->getChildren(nullptr);
417 DOM::Node* sibling_node = 428 DOM::Node* sibling_node =
418 target_node_children->get(target_node_children->length() - 1); 429 target_node_children->get(target_node_children->length() - 1);
419 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 430 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
420 DOM::Node* child_node = 431 DOM::Node* child_node =
421 parent_node_children->get(parent_node_children->length() - 1); 432 parent_node_children->get(parent_node_children->length() - 1);
422 433
434 Compare(parent_window, parent_node);
423 Compare(target_window, target_node); 435 Compare(target_window, target_node);
424 Compare(child_window, child_node); 436 Compare(child_window, child_node);
425 parent_window->RemoveChild(child_window); 437 parent_window->RemoveChild(child_window);
426 target_window->AddChild(child_window); 438 target_window->AddChild(child_window);
427 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId()); 439 ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
428 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId()); 440 ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
429 } 441 }
430 442
431 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { 443 TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
432 // Initialize DOMAgent 444 // Initialize DOMAgent
433 std::unique_ptr<ui::devtools::protocol::DOM::Node> root; 445 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
434 dom_agent()->getDocument(&root); 446 dom_agent()->getDocument(&root);
435 447
436 WmWindow* parent_window = WmShell::Get()->GetPrimaryRootWindow(); 448 WmWindow* parent_window =
449 GetWindowByShellId(kShellWindowId_ScreenRotationContainer);
437 WmWindow* child_window = parent_window->GetChildren()[0]; 450 WmWindow* child_window = parent_window->GetChildren()[0];
438 WmWindow* target_window = parent_window->GetChildren()[1]; 451 WmWindow* target_window = parent_window->GetChildren()[1];
439 452
440 DOM::Node* parent_node = root->getChildren(nullptr)->get(0); 453 DOM::Node* parent_node =
454 root->getChildren(nullptr)->get(0)->getChildren(nullptr)->get(0);
441 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); 455 Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr);
442 DOM::Node* child_node = parent_node_children->get(0); 456 DOM::Node* child_node = parent_node_children->get(0);
443 DOM::Node* sibling_node = parent_node_children->get(1); 457 DOM::Node* sibling_node = parent_node_children->get(1);
444 int parent_id = parent_node->getNodeId(); 458 int parent_id = parent_node->getNodeId();
445 459
446 Compare(parent_window, parent_node); 460 Compare(parent_window, parent_node);
447 Compare(child_window, child_node); 461 Compare(child_window, child_node);
448 parent_window->StackChildAbove(child_window, target_window); 462 parent_window->StackChildAbove(child_window, target_window);
449 ExpectChildNodeRemoved(parent_id, child_node->getNodeId()); 463 ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
450 ExpectChildNodeInserted(parent_id, sibling_node->getNodeId()); 464 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); 781 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true);
768 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds()); 782 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds());
769 783
770 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n", 784 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\nvisibility: 1;\n",
771 true); 785 true);
772 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds()); 786 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds());
773 EXPECT_TRUE(root_view->visible()); 787 EXPECT_TRUE(root_view->visible());
774 } 788 }
775 789
776 } // namespace ash 790 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/public/cpp/shell_window_ids.h » ('j') | ash/public/cpp/shell_window_ids.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698