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

Unified Diff: ash/devtools/ash_devtools_unittest.cc

Issue 2776543002: Create a unified UIElement interface for Widget, View and Window. (Closed)
Patch Set: nits Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/devtools/ash_devtools_unittest.cc
diff --git a/ash/devtools/ash_devtools_unittest.cc b/ash/devtools/ash_devtools_unittest.cc
index 53b01c3293767091f0c282cf04fbae6d487af1a8..7dd22a0d2cea0989f238e3bb67fb23e3ded529e7 100644
--- a/ash/devtools/ash_devtools_unittest.cc
+++ b/ash/devtools/ash_devtools_unittest.cc
@@ -4,6 +4,8 @@
#include "ash/devtools/ash_devtools_css_agent.h"
#include "ash/devtools/ash_devtools_dom_agent.h"
+#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"
@@ -19,6 +21,7 @@
namespace ash {
namespace {
using namespace ui::devtools::protocol;
+
const int kDefaultChildNodeCount = -1;
const SkColor kBackgroundColor = SK_ColorRED;
const SkColor kBorderColor = SK_ColorBLUE;
@@ -634,6 +637,23 @@ TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) {
EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible());
}
+int GetNodeIdFromWindow(devtools::UIElement* ui_element, aura::Window* window) {
+ for (auto* child : ui_element->children()) {
+ if (child->type() == devtools::UIElementType::WINDOW &&
+ static_cast<devtools::WindowElement*>(child)->window() == window) {
+ return child->node_id();
+ }
+ }
+ for (auto* child : ui_element->children()) {
+ if (child->type() == devtools::UIElementType::WINDOW) {
+ int node_id = GetNodeIdFromWindow(child, window);
+ if (node_id > 0)
+ return node_id;
+ }
+ }
+ return 0;
+}
+
TEST_F(AshDevToolsTest, MultipleDisplayHighlight) {
UpdateDisplay("300x400,500x500");
@@ -645,12 +665,14 @@ TEST_F(AshDevToolsTest, MultipleDisplayHighlight) {
dom_agent()->getDocument(&root);
EXPECT_EQ(root_windows[0], window->GetRootWindow());
- HighlightNode(dom_agent()->GetNodeIdFromWindow(window.get()));
+ HighlightNode(
+ GetNodeIdFromWindow(dom_agent()->window_element_root(), window.get()));
ExpectHighlighted(window->GetBoundsInScreen(), 0);
window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay());
EXPECT_EQ(root_windows[1], window->GetRootWindow());
- HighlightNode(dom_agent()->GetNodeIdFromWindow(window.get()));
+ HighlightNode(
+ GetNodeIdFromWindow(dom_agent()->window_element_root(), window.get()));
ExpectHighlighted(window->GetBoundsInScreen(), 1);
}

Powered by Google App Engine
This is Rietveld 408576698