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

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

Issue 2552913002: Add tests for highlighting, editing and updating CSS styles for UI DevTools (Closed)
Patch Set: Add tests for highlighting, editing and updating CSS styles for UI DevTools Created 4 years 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 | no next file » | no next file with comments »
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/common/devtools/ash_devtools_css_agent.h"
5 #include "ash/common/devtools/ash_devtools_dom_agent.h" 6 #include "ash/common/devtools/ash_devtools_dom_agent.h"
sadrul 2016/12/07 17:47:57 I think you can move all #includes in the same blo
Sarmad Hashmi 2016/12/07 17:57:44 Done.
6 7
7 #include "ash/common/test/ash_test.h" 8 #include "ash/common/test/ash_test.h"
8 #include "ash/common/wm_lookup.h" 9 #include "ash/common/wm_lookup.h"
9 #include "ash/common/wm_root_window_controller.h" 10 #include "ash/common/wm_root_window_controller.h"
10 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 12 #include "ash/common/wm_window.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "ui/display/display.h"
15 #include "ui/views/background.h"
13 #include "ui/views/widget/native_widget_private.h" 16 #include "ui/views/widget/native_widget_private.h"
14 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
15 18
16 namespace ash { 19 namespace ash {
17 namespace { 20 namespace {
18 using namespace ui::devtools::protocol; 21 using namespace ui::devtools::protocol;
19 const int kDefaultChildNodeCount = -1; 22 const int kDefaultChildNodeCount = -1;
23 const SkColor background_color = SK_ColorRED;
sadrul 2016/12/07 17:47:57 kBackgroundColor kBorderColor
Sarmad Hashmi 2016/12/07 17:57:44 Done.
24 const SkColor border_color = SK_ColorBLUE;
20 25
21 class TestView : public views::View { 26 class TestView : public views::View {
22 public: 27 public:
23 TestView(const char* name) : views::View(), name_(name) {} 28 TestView(const char* name) : views::View(), name_(name) {}
24 29
25 const char* GetClassName() const override { return name_; } 30 const char* GetClassName() const override { return name_; }
26 31
27 private: 32 private:
28 const char* name_; 33 const char* name_;
29 34
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Array<DOM::Node>* children = root->getChildren(nullptr); 113 Array<DOM::Node>* children = root->getChildren(nullptr);
109 DOM::Node* window_node = nullptr; 114 DOM::Node* window_node = nullptr;
110 for (size_t i = 0; i < children->length(); i++) { 115 for (size_t i = 0; i < children->length(); i++) {
111 window_node = FindInRoot(window, children->get(i)); 116 window_node = FindInRoot(window, children->get(i));
112 if (window_node) 117 if (window_node)
113 return window_node; 118 return window_node;
114 } 119 }
115 return window_node; 120 return window_node;
116 } 121 }
117 122
123 int GetPropertyByName(const std::string& name,
124 Array<CSS::CSSProperty>* properties) {
125 for (size_t i = 0; i < properties->length(); i++) {
126 CSS::CSSProperty* property = properties->get(i);
127 if (property->getName() == name) {
128 int value;
129 EXPECT_TRUE(base::StringToInt(property->getValue(), &value));
130 return value;
131 }
132 }
133 NOTREACHED();
134 return -1;
135 }
136
137 WmWindow* GetHighlightingWindow(int root_window_index) {
138 WmWindow::Windows overlay_windows =
139 WmShell::Get()
140 ->GetAllRootWindows()[root_window_index]
141 ->GetChildByShellWindowId(kShellWindowId_OverlayContainer)
142 ->GetChildren();
143 for (WmWindow* window : overlay_windows) {
144 if (window->GetName() == "HighlightingWidget")
145 return window;
146 }
147 NOTREACHED();
148 return nullptr;
149 }
150
151 std::unique_ptr<DOM::RGBA> SkColorToRGBA(const SkColor& color) {
152 return DOM::RGBA::create()
153 .setA(SkColorGetA(color) / 255)
154 .setB(SkColorGetB(color))
155 .setG(SkColorGetG(color))
156 .setR(SkColorGetR(color))
157 .build();
158 }
159
160 std::unique_ptr<DOM::HighlightConfig> CreateHighlightConfig(
161 const SkColor& background_color,
162 const SkColor& border_color) {
163 return DOM::HighlightConfig::create()
164 .setContentColor(SkColorToRGBA(background_color))
165 .setBorderColor(SkColorToRGBA(border_color))
166 .build();
167 }
168
169 void ExpectHighlighted(const gfx::Rect& bounds, int root_window_index) {
170 WmWindow* highlighting_window = GetHighlightingWindow(root_window_index);
171 EXPECT_TRUE(highlighting_window->IsVisible());
172 EXPECT_EQ(bounds, highlighting_window->GetBoundsInScreen());
173 EXPECT_EQ(background_color, highlighting_window->GetInternalWidget()
174 ->GetRootView()
175 ->background()
176 ->get_color());
177 }
178
118 } // namespace 179 } // namespace
119 180
120 class AshDevToolsTest : public AshTest { 181 class AshDevToolsTest : public AshTest {
121 public: 182 public:
122 AshDevToolsTest() {} 183 AshDevToolsTest() {}
123 ~AshDevToolsTest() override {} 184 ~AshDevToolsTest() override {}
124 185
125 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() { 186 views::internal::NativeWidgetPrivate* CreateTestNativeWidget() {
126 views::Widget* widget = new views::Widget; 187 views::Widget* widget = new views::Widget;
127 views::Widget::InitParams params; 188 views::Widget::InitParams params;
128 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; 189 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET;
129 WmShell::Get() 190 WmShell::Get()
130 ->GetPrimaryRootWindow() 191 ->GetPrimaryRootWindowController()
131 ->GetRootWindowController()
132 ->ConfigureWidgetInitParamsForContainer( 192 ->ConfigureWidgetInitParamsForContainer(
133 widget, kShellWindowId_DefaultContainer, &params); 193 widget, kShellWindowId_DefaultContainer, &params);
134 widget->Init(params); 194 widget->Init(params);
135 return widget->native_widget_private(); 195 return widget->native_widget_private();
136 } 196 }
137 197
138 void SetUp() override { 198 void SetUp() override {
139 AshTest::SetUp(); 199 AshTest::SetUp();
140 fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>(); 200 fake_frontend_channel_ = base::MakeUnique<FakeFrontendChannel>();
141 uber_dispatcher_ = 201 uber_dispatcher_ =
142 base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get()); 202 base::MakeUnique<UberDispatcher>(fake_frontend_channel_.get());
143 dom_agent_ = 203 dom_agent_ =
144 base::MakeUnique<devtools::AshDevToolsDOMAgent>(WmShell::Get()); 204 base::MakeUnique<devtools::AshDevToolsDOMAgent>(WmShell::Get());
145 dom_agent_->Init(uber_dispatcher_.get()); 205 dom_agent_->Init(uber_dispatcher_.get());
206 css_agent_ =
207 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_agent_.get());
208 css_agent_->Init(uber_dispatcher_.get());
209 css_agent_->enable();
146 } 210 }
147 211
148 void TearDown() override { 212 void TearDown() override {
213 css_agent_.reset();
149 dom_agent_.reset(); 214 dom_agent_.reset();
150 uber_dispatcher_.reset(); 215 uber_dispatcher_.reset();
151 fake_frontend_channel_.reset(); 216 fake_frontend_channel_.reset();
152 AshTest::TearDown(); 217 AshTest::TearDown();
153 } 218 }
154 219
155 void ExpectChildNodeInserted(int parent_id, int prev_sibling_id) { 220 void ExpectChildNodeInserted(int parent_id, int prev_sibling_id) {
156 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessageStartsWith( 221 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessageStartsWith(
157 base::StringPrintf("{\"method\":\"DOM.childNodeInserted\"," 222 base::StringPrintf("{\"method\":\"DOM.childNodeInserted\","
158 "\"params\":{\"parentNodeId\":%d," 223 "\"params\":{\"parentNodeId\":%d,"
159 "\"previousNodeId\":%d", 224 "\"previousNodeId\":%d",
160 parent_id, prev_sibling_id))); 225 parent_id, prev_sibling_id)));
161 } 226 }
162 227
163 void ExpectChildNodeRemoved(int parent_id, int node_id) { 228 void ExpectChildNodeRemoved(int parent_id, int node_id) {
164 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessage( 229 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessage(
165 base::StringPrintf( 230 base::StringPrintf(
166 "{\"method\":\"DOM.childNodeRemoved\",\"params\":{" 231 "{\"method\":\"DOM.childNodeRemoved\",\"params\":{"
167 "\"parentNodeId\":%d,\"nodeId\":%d}}", 232 "\"parentNodeId\":%d,\"nodeId\":%d}}",
168 parent_id, node_id))); 233 parent_id, node_id)));
169 } 234 }
170 235
236 void ExpectStyleSheetChanged(int node_id) {
237 EXPECT_EQ(1, frontend_channel()->CountProtocolNotificationMessage(
238 base::StringPrintf(
239 "{\"method\":\"CSS.styleSheetChanged\",\"params\":{"
240 "\"styleSheetId\":\"%d\"}}",
241 node_id)));
242 }
243
244 void CompareNodeBounds(DOM::Node* node, const gfx::Rect& bounds) {
245 Maybe<CSS::CSSStyle> styles;
246 css_agent_->getMatchedStylesForNode(node->getNodeId(), &styles);
247 ASSERT_TRUE(styles.isJust());
248 Array<CSS::CSSProperty>* properties = styles.fromJust()->getCssProperties();
249 EXPECT_EQ(bounds.height(), GetPropertyByName("height", properties));
250 EXPECT_EQ(bounds.width(), GetPropertyByName("width", properties));
251 EXPECT_EQ(bounds.x(), GetPropertyByName("x", properties));
252 EXPECT_EQ(bounds.y(), GetPropertyByName("y", properties));
253 }
254
255 void SetStyleTexts(DOM::Node* node,
256 const std::string& style_text,
257 bool success) {
258 auto edits = Array<CSS::StyleDeclarationEdit>::create();
259 auto edit = CSS::StyleDeclarationEdit::create()
260 .setStyleSheetId(base::IntToString(node->getNodeId()))
261 .setText(style_text)
262 .build();
263 edits->addItem(std::move(edit));
264 std::unique_ptr<Array<CSS::CSSStyle>> output;
265 EXPECT_EQ(success,
266 css_agent_->setStyleTexts(std::move(edits), &output).isSuccess());
267
268 if (success)
269 ASSERT_TRUE(output);
270 else
271 ASSERT_FALSE(output);
272 }
273
274 void HighlightNode(int node_id) {
275 dom_agent_->highlightNode(
276 CreateHighlightConfig(background_color, border_color), node_id);
277 }
278
279 void HideHighlight(int root_window_index) {
280 dom_agent_->hideHighlight();
281 ASSERT_FALSE(GetHighlightingWindow(root_window_index)->IsVisible());
282 }
283
171 FakeFrontendChannel* frontend_channel() { 284 FakeFrontendChannel* frontend_channel() {
172 return fake_frontend_channel_.get(); 285 return fake_frontend_channel_.get();
173 } 286 }
174 287
288 devtools::AshDevToolsCSSAgent* css_agent() { return css_agent_.get(); }
175 devtools::AshDevToolsDOMAgent* dom_agent() { return dom_agent_.get(); } 289 devtools::AshDevToolsDOMAgent* dom_agent() { return dom_agent_.get(); }
176 290
177 private: 291 private:
178 std::unique_ptr<UberDispatcher> uber_dispatcher_; 292 std::unique_ptr<UberDispatcher> uber_dispatcher_;
179 std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_; 293 std::unique_ptr<FakeFrontendChannel> fake_frontend_channel_;
180 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_; 294 std::unique_ptr<devtools::AshDevToolsDOMAgent> dom_agent_;
295 std::unique_ptr<devtools::AshDevToolsCSSAgent> css_agent_;
181 296
182 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest); 297 DISALLOW_COPY_AND_ASSIGN(AshDevToolsTest);
183 }; 298 };
184 299
185 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) { 300 TEST_F(AshDevToolsTest, GetDocumentWithWindowWidgetView) {
186 std::unique_ptr<views::Widget> widget( 301 std::unique_ptr<views::Widget> widget(
187 CreateTestWidget(gfx::Rect(1, 1, 1, 1))); 302 CreateTestWidget(gfx::Rect(1, 1, 1, 1)));
188 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get()); 303 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get());
189 parent_window->SetName("parent_window"); 304 parent_window->SetName("parent_window");
190 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window)); 305 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 Compare(parent_view, parent_view_node); 582 Compare(parent_view, parent_view_node);
468 Compare(target_view, target_view_node); 583 Compare(target_view, target_view_node);
469 Compare(child_view, child_view_node); 584 Compare(child_view, child_view_node);
470 parent_view->RemoveChildView(child_view); 585 parent_view->RemoveChildView(child_view);
471 target_view->AddChildView(child_view); 586 target_view->AddChildView(child_view);
472 ExpectChildNodeRemoved(parent_view_node->getNodeId(), 587 ExpectChildNodeRemoved(parent_view_node->getNodeId(),
473 child_view_node->getNodeId()); 588 child_view_node->getNodeId());
474 ExpectChildNodeInserted(target_view_node->getNodeId(), 0); 589 ExpectChildNodeInserted(target_view_node->getNodeId(), 0);
475 } 590 }
476 591
592 TEST_F(AshDevToolsTest, WindowWidgetViewHighlight) {
593 std::unique_ptr<views::Widget> widget(
594 CreateTestWidget(gfx::Rect(0, 0, 400, 400)));
595 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get());
596 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
597 WmWindow* window = child_owner->window();
598 views::View* root_view = widget->GetRootView();
599
600 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
601 dom_agent()->getDocument(&root);
602
603 DOM::Node* parent_node = FindInRoot(parent_window, root.get());
604 ASSERT_TRUE(parent_node);
605 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr);
606 ASSERT_TRUE(parent_children);
607 DOM::Node* window_node = parent_children->get(1);
608 DOM::Node* widget_node = parent_children->get(0);
609 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0);
610
611 HighlightNode(window_node->getNodeId());
612 ExpectHighlighted(window->GetBoundsInScreen(), 0);
613
614 HideHighlight(0);
sadrul 2016/12/07 17:47:57 What does higlighting 'node 0' mean?
Sarmad Hashmi 2016/12/07 17:57:44 It hides the highlight on display 0 (aka primary d
615
616 HighlightNode(widget_node->getNodeId());
617 ExpectHighlighted(widget->GetWindowBoundsInScreen(), 0);
618
619 HideHighlight(0);
620
621 HighlightNode(root_view_node->getNodeId());
622 ExpectHighlighted(root_view->GetBoundsInScreen(), 0);
623
624 HideHighlight(0);
625
626 // Highlight non-existent node
627 HighlightNode(10000);
628 EXPECT_FALSE(GetHighlightingWindow(0)->IsVisible());
629 }
630
631 TEST_F(AshDevToolsTest, MultipleDisplayHighlight) {
632 if (!SupportsMultipleDisplays())
633 return;
634 UpdateDisplay("300x400,500x500");
635
636 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows();
637 std::unique_ptr<WindowOwner> window_owner(
638 CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
639 WmWindow* window = window_owner->window();
640
641 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
642 dom_agent()->getDocument(&root);
643
644 EXPECT_EQ(root_windows[0], window->GetRootWindow());
645 HighlightNode(dom_agent()->GetNodeIdFromWindow(window));
646 ExpectHighlighted(window->GetBoundsInScreen(), 0);
647
648 window->SetBoundsInScreen(gfx::Rect(500, 0, 50, 50), GetSecondaryDisplay());
649 EXPECT_EQ(root_windows[1], window->GetRootWindow());
650 HighlightNode(dom_agent()->GetNodeIdFromWindow(window));
651 ExpectHighlighted(window->GetBoundsInScreen(), 1);
sadrul 2016/12/07 17:47:57 Cool!
652 }
653
654 TEST_F(AshDevToolsTest, WindowWidgetViewGetMatchedStylesForNode) {
655 std::unique_ptr<views::Widget> widget(
656 CreateTestWidget(gfx::Rect(1, 1, 1, 1)));
657 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get());
658 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
659 WmWindow* window = child_owner->window();
660 gfx::Rect window_bounds(2, 2, 3, 3);
661 gfx::Rect widget_bounds(50, 50, 100, 75);
662 gfx::Rect view_bounds(4, 4, 3, 3);
663 window->SetBounds(window_bounds);
664 widget->SetBounds(widget_bounds);
665 widget->GetRootView()->SetBoundsRect(view_bounds);
666
667 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
668 dom_agent()->getDocument(&root);
669
670 DOM::Node* parent_node = FindInRoot(parent_window, root.get());
671 ASSERT_TRUE(parent_node);
672 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr);
673 ASSERT_TRUE(parent_children);
674
675 CompareNodeBounds(parent_node, widget_bounds);
676 CompareNodeBounds(parent_children->get(1), window_bounds);
677 CompareNodeBounds(parent_children->get(0)->getChildren(nullptr)->get(0),
678 view_bounds);
679 }
680
681 TEST_F(AshDevToolsTest, WindowWidgetViewStyleSheetChanged) {
682 std::unique_ptr<views::Widget> widget(
683 CreateTestWidget(gfx::Rect(1, 1, 1, 1)));
684 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get());
685 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
686 WmWindow* window = child_owner->window();
687
688 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
689 dom_agent()->getDocument(&root);
690
691 gfx::Rect window_bounds(2, 2, 3, 3);
692 gfx::Rect widget_bounds(10, 10, 5, 6);
693 gfx::Rect view_bounds(4, 4, 3, 3);
694 window->SetBounds(window_bounds);
695 widget->SetBounds(widget_bounds);
696 widget->GetRootView()->SetBoundsRect(view_bounds);
697
698 DOM::Node* parent_node = FindInRoot(parent_window, root.get());
699 ASSERT_TRUE(parent_node);
700 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr);
701 ASSERT_TRUE(parent_children);
702
703 ExpectStyleSheetChanged(parent_node->getNodeId());
704 ExpectStyleSheetChanged(parent_children->get(1)->getNodeId());
705 ExpectStyleSheetChanged(
706 parent_children->get(0)->getChildren(nullptr)->get(0)->getNodeId());
707 }
708
709 TEST_F(AshDevToolsTest, WindowWidgetViewSetStyleText) {
710 std::unique_ptr<views::Widget> widget(
711 CreateTestWidget(gfx::Rect(0, 0, 400, 400)));
712 WmWindow* parent_window = WmLookup::Get()->GetWindowForWidget(widget.get());
713 std::unique_ptr<WindowOwner> child_owner(CreateChildWindow(parent_window));
714 WmWindow* window = child_owner->window();
715 views::View* root_view = widget->GetRootView();
716
717 std::unique_ptr<ui::devtools::protocol::DOM::Node> root;
718 dom_agent()->getDocument(&root);
719
720 DOM::Node* parent_node = FindInRoot(parent_window, root.get());
721 ASSERT_TRUE(parent_node);
722 Array<DOM::Node>* parent_children = parent_node->getChildren(nullptr);
723 ASSERT_TRUE(parent_children);
724
725 // Test different combinations on window node
726 DOM::Node* window_node = parent_children->get(1);
727
728 SetStyleTexts(window_node, "x: 25; y:35; width: 5; height: 20;", true);
729 EXPECT_EQ(gfx::Rect(25, 35, 5, 20), window->GetBounds());
730
731 SetStyleTexts(window_node, "test_nothing_happens:1;", false);
732 EXPECT_EQ(gfx::Rect(25, 35, 5, 20), window->GetBounds()); // Not changed
733
734 SetStyleTexts(window_node, "\nheight: 10;\n ", true);
735 EXPECT_EQ(gfx::Rect(25, 35, 5, 10), window->GetBounds());
736
737 SetStyleTexts(window_node, "\nx: 10; y: 23; width: 52;\n ", true);
738 EXPECT_EQ(gfx::Rect(10, 23, 52, 10), window->GetBounds());
739
740 // Test different combinations on widget node
741 DOM::Node* widget_node = parent_children->get(0);
742
743 SetStyleTexts(widget_node, "x: 25; y:35; width: 53; height: 64;", true);
744 EXPECT_EQ(gfx::Rect(25, 35, 53, 64), widget->GetRestoredBounds());
745
746 SetStyleTexts(widget_node, "test_nothing_happens:1;", false);
747 EXPECT_EQ(gfx::Rect(25, 35, 53, 64),
748 widget->GetRestoredBounds()); // Not changed
749
750 SetStyleTexts(widget_node, "\nheight: 123;\n ", true);
751 EXPECT_EQ(gfx::Rect(25, 35, 53, 123), widget->GetRestoredBounds());
752
753 SetStyleTexts(widget_node, "\nx: 10; y: 23; width: 98;\n ", true);
754 EXPECT_EQ(gfx::Rect(10, 23, 98, 123), widget->GetRestoredBounds());
755
756 // Test different combinations on view node
757 DOM::Node* root_view_node = widget_node->getChildren(nullptr)->get(0);
758
759 SetStyleTexts(root_view_node, "x: 25; y:35; width: 45; height: 20;", true);
760 EXPECT_EQ(gfx::Rect(25, 35, 45, 20), root_view->bounds());
761
762 SetStyleTexts(root_view_node, "test_nothing_happens:1;", false);
763 EXPECT_EQ(gfx::Rect(25, 35, 45, 20), root_view->bounds()); // Not changed
764
765 SetStyleTexts(root_view_node, "\nheight: 73;\n ", true);
766 EXPECT_EQ(gfx::Rect(25, 35, 45, 73), root_view->bounds());
767
768 SetStyleTexts(root_view_node, "\nx: 10; y: 23; width: 52;\n ", true);
769 EXPECT_EQ(gfx::Rect(10, 23, 52, 73), root_view->bounds());
770 }
771
477 } // namespace ash 772 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698