| Index: ash/common/devtools/ash_devtools_unittest.cc
|
| diff --git a/ash/common/devtools/ash_devtools_unittest.cc b/ash/common/devtools/ash_devtools_unittest.cc
|
| index 7e450f5ef09607f0053c1ad2cf515f6302371b85..1a79c07dc2cf5032503b3a7dfaf9103bde2a898a 100644
|
| --- a/ash/common/devtools/ash_devtools_unittest.cc
|
| +++ b/ash/common/devtools/ash_devtools_unittest.cc
|
| @@ -68,18 +68,20 @@ std::string GetAttributeValue(const std::string& attribute, DOM::Node* node) {
|
| return nullptr;
|
| }
|
|
|
| -bool Equals(views::Widget* widget, DOM::Node* node) {
|
| - return "Widget" == node->getNodeName() &&
|
| - widget->GetName() == GetAttributeValue("name", node) &&
|
| - (widget->GetRootView() ? 1 : 0) ==
|
| - node->getChildNodeCount(kDefaultChildNodeCount);
|
| -}
|
| -
|
| bool Equals(WmWindow* window, DOM::Node* node) {
|
| + int children_count = static_cast<int>(window->GetChildren().size());
|
| + if (window->GetInternalWidget())
|
| + children_count++;
|
| return "Window" == node->getNodeName() &&
|
| window->GetName() == GetAttributeValue("name", node) &&
|
| - static_cast<int>(window->GetChildren().size()) ==
|
| - node->getChildNodeCount(kDefaultChildNodeCount);
|
| + children_count == node->getChildNodeCount(kDefaultChildNodeCount);
|
| +}
|
| +
|
| +void Compare(views::Widget* widget, DOM::Node* node) {
|
| + EXPECT_EQ("Widget", node->getNodeName());
|
| + EXPECT_EQ(widget->GetName(), GetAttributeValue("name", node));
|
| + EXPECT_EQ(widget->GetRootView() ? 1 : 0,
|
| + node->getChildNodeCount(kDefaultChildNodeCount));
|
| }
|
|
|
| void Compare(views::View* view, DOM::Node* node) {
|
| @@ -107,20 +109,6 @@ DOM::Node* FindInRoot(WmWindow* window, DOM::Node* root) {
|
| return window_node;
|
| }
|
|
|
| -DOM::Node* FindInRoot(views::Widget* widget, DOM::Node* root) {
|
| - if (Equals(widget, root))
|
| - return root;
|
| -
|
| - Array<DOM::Node>* children = root->getChildren(nullptr);
|
| - DOM::Node* widget_node = nullptr;
|
| - for (size_t i = 0; i < children->length(); i++) {
|
| - widget_node = FindInRoot(widget, children->get(i));
|
| - if (widget_node)
|
| - return widget_node;
|
| - }
|
| - return widget_node;
|
| -}
|
| -
|
| } // namespace
|
|
|
| class AshDevToolsTest : public AshTest {
|
| @@ -191,11 +179,12 @@ TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) {
|
| dom_agent()->getDocument(&root);
|
|
|
| DOM::Node* parent_node = FindInRoot(parent_window, root.get());
|
| - DOM::Node* widget_node = FindInRoot(widget.get(), root.get());
|
| ASSERT_TRUE(parent_node);
|
| - ASSERT_TRUE(widget_node);
|
| - ASSERT_TRUE(parent_node->getChildren(nullptr));
|
| - Compare(child_window, parent_node->getChildren(nullptr)->get(0));
|
| + Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr);
|
| + ASSERT_TRUE(parent_children);
|
| + DOM::Node* widget_node = parent_children->get(0);
|
| + Compare(widget.get(), widget_node);
|
| + Compare(child_window, parent_children->get(1));
|
| Array<DOM::Node>* widget_children = widget_node->getChildren(nullptr);
|
| ASSERT_TRUE(widget_children);
|
| Compare(widget->GetRootView(), widget_children->get(0));
|
| @@ -230,6 +219,8 @@ TEST_F(AshDevToolsTest, WindowDestroyedChildNodeRemoved) {
|
| DOM::Node* parent_node = root_node->getChildren(nullptr)->get(0);
|
| DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
|
|
|
| + Compare(parent_window, parent_node);
|
| + Compare(child_window, child_node);
|
| child_window->Destroy();
|
| ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
|
| }
|
| @@ -251,6 +242,8 @@ TEST_F(AshDevToolsTest, WindowReorganizedChildNodeRemovedAndInserted) {
|
| target_node_children->get(target_node_children->length() - 1);
|
| DOM::Node* child_node = parent_node->getChildren(nullptr)->get(0);
|
|
|
| + Compare(target_window, target_node);
|
| + Compare(child_window, child_node);
|
| target_window->AddChild(child_window);
|
| ExpectChildNodeRemoved(parent_node->getNodeId(), child_node->getNodeId());
|
| ExpectChildNodeInserted(target_node->getNodeId(), sibling_node->getNodeId());
|
| @@ -271,6 +264,8 @@ TEST_F(AshDevToolsTest, WindowStackingChangedChildNodeRemovedAndInserted) {
|
| DOM::Node* sibling_node = parent_node_children->get(1);
|
| int parent_id = parent_node->getNodeId();
|
|
|
| + Compare(parent_window, parent_node);
|
| + Compare(child_window, child_node);
|
| parent_window->StackChildAbove(child_window, target_window);
|
| ExpectChildNodeRemoved(parent_id, child_node->getNodeId());
|
| ExpectChildNodeInserted(parent_id, sibling_node->getNodeId());
|
|
|