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

Unified Diff: ui/views/mus/native_widget_mus_unittest.cc

Issue 2009853002: Finish eliminating PlatformWindowMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean-up and add TODO to WTHM Created 4 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: ui/views/mus/native_widget_mus_unittest.cc
diff --git a/ui/views/mus/native_widget_mus_unittest.cc b/ui/views/mus/native_widget_mus_unittest.cc
index 53f9338ed07a43a59f9bef8da44da03cd0c4e074..a460a4d6fb757042a86315ea19f37fec450bc273 100644
--- a/ui/views/mus/native_widget_mus_unittest.cc
+++ b/ui/views/mus/native_widget_mus_unittest.cc
@@ -154,7 +154,7 @@ class NativeWidgetMusTest : public ViewsTestBase {
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
params.delegate = delegate;
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.bounds = gfx::Rect(10, 20, 100, 200);
+ params.bounds = initial_bounds();
widget->Init(params);
return widget;
}
@@ -185,6 +185,11 @@ class NativeWidgetMusTest : public ViewsTestBase {
ack_callback);
}
+ protected:
+ gfx::Rect initial_bounds() {
+ return gfx::Rect(10, 20, 100, 200);
+ }
+
private:
int ack_callback_count_ = 0;
@@ -491,4 +496,31 @@ TEST_F(NativeWidgetMusTest, SetAndReleaseCapture) {
EXPECT_FALSE(mus_window->HasCapture());
}
+// Ensure that manually setting NativeWidgetMus's mus::Window bounds also
+// updates its WindowTreeHost bounds.
+TEST_F(NativeWidgetMusTest, SetMusWindowBounds) {
+ std::unique_ptr<Widget> widget(CreateWidget(nullptr));
+ widget->Show();
+ View* content = new View;
+ widget->GetContentsView()->AddChildView(content);
+ NativeWidgetMus* native_widget =
+ static_cast<NativeWidgetMus*>(widget->native_widget_private());
+ mus::Window* mus_window = native_widget->window();
+
+ gfx::Rect start_bounds = initial_bounds();
+ gfx::Rect end_bounds = gfx::Rect(40, 50, 60, 70);
+ EXPECT_NE(start_bounds, end_bounds);
+
+ EXPECT_EQ(start_bounds, mus_window->bounds());
+ EXPECT_EQ(start_bounds, native_widget->window_tree_host()->GetBounds());
+
+ mus_window->SetBounds(end_bounds);
+
+ EXPECT_EQ(end_bounds, mus_window->bounds());
+
+ // Main check for this test: Setting |mus_window| bounds while bypassing
+ // |native_widget| must update window_tree_host bounds.
+ EXPECT_EQ(end_bounds, native_widget->window_tree_host()->GetBounds());
+}
+
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698