Index: ash/devtools/ash_devtools_unittest.cc |
diff --git a/ash/devtools/ash_devtools_unittest.cc b/ash/devtools/ash_devtools_unittest.cc |
index a1ecc40126c8b139172f36b413355bd1f2e49b9a..89de77da5ddfc314f1d14595ef6340f5c451c266 100644 |
--- a/ash/devtools/ash_devtools_unittest.cc |
+++ b/ash/devtools/ash_devtools_unittest.cc |
@@ -7,12 +7,12 @@ |
#include "ash/devtools/ui_element.h" |
#include "ash/devtools/window_element.h" |
#include "ash/public/cpp/shell_window_ids.h" |
-#include "ash/root_window_controller.h" |
#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
#include "ash/wm/widget_finder.h" |
#include "base/memory/ptr_util.h" |
#include "base/strings/stringprintf.h" |
+#include "ui/aura/window_tree_host.h" |
#include "ui/display/display.h" |
#include "ui/views/background.h" |
#include "ui/views/widget/native_widget_private.h" |
@@ -138,11 +138,9 @@ int GetPropertyByName(const std::string& name, |
return -1; |
} |
-aura::Window* GetHighlightingWindow(int root_window_index) { |
+aura::Window* GetHighlightingWindow(aura::Window* root_window) { |
const aura::Window::Windows& overlay_windows = |
- Shell::GetAllRootWindows()[root_window_index] |
- ->GetChildById(kShellWindowId_OverlayContainer) |
- ->children(); |
+ root_window->GetChildById(kShellWindowId_OverlayContainer)->children(); |
for (aura::Window* window : overlay_windows) { |
if (window->GetName() == "HighlightingWidget") |
return window; |
@@ -169,8 +167,8 @@ std::unique_ptr<DOM::HighlightConfig> CreateHighlightConfig( |
.build(); |
} |
-void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) { |
- aura::Window* highlighting_window = GetHighlightingWindow(root_window_index); |
+void ExpectHighlighted(const gfx::Rect& bounds, aura::Window* root_window) { |
+ aura::Window* highlighting_window = GetHighlightingWindow(root_window); |
EXPECT_TRUE(highlighting_window->IsVisible()); |
EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen()); |
EXPECT_EQ(kBackgroundColor, GetInternalWidgetForWindow(highlighting_window) |
@@ -179,10 +177,6 @@ void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) { |
->get_color()); |
} |
-aura::Window* GetPrimaryRootWindow() { |
- return Shell::Get()->GetPrimaryRootWindow(); |
-} |
- |
} // namespace |
class AshDevToolsTest : public test::AshTestBase { |
@@ -194,9 +188,11 @@ class AshDevToolsTest : public test::AshTestBase { |
views::Widget* widget = new views::Widget; |
views::Widget::InitParams params; |
params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; |
- Shell::GetPrimaryRootWindowController() |
- ->ConfigureWidgetInitParamsForContainer( |
- widget, kShellWindowId_DefaultContainer, ¶ms); |
+ params.parent = nullptr; |
+ if (!dom_agent()->root_windows().empty()) { |
+ params.parent = dom_agent()->root_windows()[0]->GetChildById( |
+ kShellWindowId_DefaultContainer); |
+ } |
widget->Init(params); |
return widget->native_widget_private(); |
} |
@@ -207,7 +203,6 @@ class AshDevToolsTest : public test::AshTestBase { |
} |
void SetUp() override { |
- AshTestBase::SetUp(); |
fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>(); |
uber_dispatcher_ = |
base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get()); |
@@ -217,6 +212,7 @@ class AshDevToolsTest : public test::AshTestBase { |
base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_agent_.get()); |
css_agent_->Init(uber_dispatcher_.get()); |
css_agent_->enable(); |
+ AshTestBase::SetUp(); |
} |
void TearDown() override { |
@@ -287,7 +283,9 @@ class AshDevToolsTest : public test::AshTestBase { |
void HideHighlight(int root_window_index) { |
dom_agent_->hideHighlight(); |
- ASSERT_FALSE(GetHighlightingWindow(root_window_index)->IsVisible()); |
+ ASSERT_FALSE( |
+ GetHighlightingWindow(dom_agent()->root_windows()[root_window_index]) |
sadrul
2017/05/23 17:32:47
First assert that |root_window_index| is valid.
thanhph
2017/05/24 15:15:21
Done.
|
+ ->IsVisible()); |
} |
FakeFrontendChannel* frontend_channel() { |
@@ -356,7 +354,7 @@ TEST_F(AshDevToolsTest, WindowAddedChildNodeInserted) { |
std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
dom_agent()->getDocument(&root); |
- aura::Window* root_window = GetPrimaryRootWindow(); |
+ aura::Window* root_window = dom_agent()->root_windows()[0]; |
sadrul
2017/05/23 17:32:47
Can we move GetPrimaryRootWindow() as a function i
thanhph
2017/05/24 15:15:21
Done.
|
aura::Window* parent_window = root_window->children()[0]; |
DOM::Node* parent_node = FindInRoot(parent_window, root.get()); |
Array<DOM::Node>* parent_node_children = parent_node->getChildren(nullptr); |
@@ -372,7 +370,7 @@ TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) { |
std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
dom_agent()->getDocument(&root); |
- aura::Window* root_window = GetPrimaryRootWindow(); |
+ aura::Window* root_window = dom_agent()->root_windows()[0]; |
aura::Window* rotation_window = root_window->children()[0]; |
aura::Window* parent_window = rotation_window->children()[0]; |
aura::Window* child_window = parent_window->children()[0]; |
@@ -392,7 +390,7 @@ TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { |
std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
dom_agent()->getDocument(&root); |
- aura::Window* root_window = GetPrimaryRootWindow(); |
+ aura::Window* root_window = dom_agent()->root_windows()[0]; |
aura::Window* rotation_window = root_window->children()[0]; |
aura::Window* parent_window = rotation_window->children()[0]; |
aura::Window* target_window = rotation_window->children()[1]; |
@@ -416,7 +414,7 @@ TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRearranged) { |
} |
TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) { |
- aura::Window* root_window = GetPrimaryRootWindow(); |
+ aura::Window* root_window = dom_agent()->root_windows()[0]; |
aura::Window* rotation_window = root_window->children()[0]; |
aura::Window* parent_window = rotation_window->children()[0]; |
aura::Window* target_window = rotation_window->children()[1]; |
@@ -450,7 +448,7 @@ TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) { |
std::unique_ptr<ui::devtools::protocol::DOM::Node> root; |
dom_agent()->getDocument(&root); |
- aura::Window* root_window = GetPrimaryRootWindow(); |
+ aura::Window* root_window = dom_agent()->root_windows()[0]; |
aura::Window* parent_window = root_window->children()[0]; |
aura::Window* child_window = parent_window->children()[0]; |
aura::Window* target_window = parent_window->children()[1]; |
@@ -634,23 +632,27 @@ TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) { |
DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0); |
HighlightNode(window_node->getNodeId()); |
- ExpectHighlighted(window->GetBoundsInScreen(), 0); |
+ ExpectHighlighted(window->GetBoundsInScreen(), |
+ dom_agent()->root_windows()[0]); |
HideHighlight(0); |
HighlightNode(widget_node->getNodeId()); |
- ExpectHighlighted(widget->GetWindowBoundsInScreen(), 0); |
+ ExpectHighlighted(widget->GetWindowBoundsInScreen(), |
+ dom_agent()->root_windows()[0]); |
HideHighlight(0); |
HighlightNode(root_view_node->getNodeId()); |
- ExpectHighlighted(root_view->GetBoundsInScreen(), 0); |
+ ExpectHighlighted(root_view->GetBoundsInScreen(), |
+ dom_agent()->root_windows()[0]); |
HideHighlight(0); |
// Highlight non-existent node |
HighlightNode(10000); |
- EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible()); |
+ EXPECT_FALSE( |
+ GetHighlightingWindow(dom_agent()->root_windows()[0])->IsVisible()); |
} |
int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) { |
@@ -673,7 +675,7 @@ int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) { |
TEST_F(AshDevToolsTest, MultipleDisplayHighlight) { |
UpdateDisplay("300x400,500x500"); |
- aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
+ aura::Window::Windows root_windows = dom_agent()->root_windows(); |
sadrul
2017/05/23 17:32:47
const auto& root_windows = dom_agent()->root_windo
thanhph
2017/05/24 15:15:21
I removed this test for now as we discussed. Added
|
std::unique_ptr<aura::Window> window( |
CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40))); |
@@ -683,13 +685,15 @@ TEST_F(AshDevToolsTest, MultipleDisplayHighlight) { |
EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
HighlightNode( |
GetNodeIdFromWindow(dom_agent()->window_element_root(), window.get())); |
- ExpectHighlighted(window->GetBoundsInScreen(), 0); |
+ ExpectHighlighted(window->GetBoundsInScreen(), |
+ dom_agent()->root_windows()[0]); |
window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay()); |
EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
HighlightNode( |
GetNodeIdFromWindow(dom_agent()->window_element_root(), window.get())); |
- ExpectHighlighted(window->GetBoundsInScreen(), 1); |
+ ExpectHighlighted(window->GetBoundsInScreen(), |
+ dom_agent()->root_windows()[1]); |
} |
TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) { |