Mac/Linux: Ensure window size constraints propagate to the window server during Init
commitc07049637a2deb72869370136c85d70ac608a91a
authortapted <tapted@chromium.org>
Thu, 16 Apr 2015 23:10:23 +0000 (16 16:10 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 16 Apr 2015 23:10:42 +0000 (16 23:10 +0000)
tree8f02a26e6a057c7816155d7beebe4600cbae3650
parent8d1bac7f28a0eb9651cbe3dd962334e3f920a6e1
Mac/Linux: Ensure window size constraints propagate to the window server during Init

Currently fixed-size views dialogs on Mac don't initialize properly.
(And, e.g., WebDialogBrowserTest.SizeWindow fails because of it).
Desktop Linux has a similar issue.

On desktop Linux, NativeWidgetPrivate::OnRootViewLayout triggers a call
to UpdateMinAndMaxSize. OnRootViewLayout happens during Widget::Init()
but the X11 window is not yet mapped, so this was resulting in a no-op.
For Linux, fix by explicitly calling UpdateMinAndMaxSize after the
window is mapped.

Mac needs to do a similar thing during Init. However, Mac was calling
OnSizeConstraintsChanged() before Widget::Init() had set the non-client
view, so Widget::GetMinimumSize() returned invalid sizes. For Mac, move
the OnSizeConstraintsChanged() call to OnRootViewLayout(), similar to
Linux.

Then, add a cross-platform test. Mac was not clamping to the size
constraints in SetBounds(), so do that.

For the test itself, collapse the testing WidgetDelegates in
widget_unittest.cc into one helper class rather than adding yet another
WidgetDelegate. Then, provide a way to query the OS for the minimum
window size to fill the gaps required for testing the propagation of
size constraints to the window server.

BUG=454698, 447086

Review URL: https://codereview.chromium.org/1059853007

Cr-Commit-Position: refs/heads/master@{#325538}
ui/views/cocoa/bridged_native_widget.h
ui/views/cocoa/bridged_native_widget.mm
ui/views/test/widget_test.h
ui/views/test/widget_test_aura.cc
ui/views/test/widget_test_mac.mm
ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
ui/views/widget/native_widget_mac.mm
ui/views/widget/widget_unittest.cc