Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/cursor_client.h" | 8 #include "ui/aura/client/cursor_client.h" |
| 9 #include "ui/aura/test/test_window_delegate.h" | 9 #include "ui/aura/test/test_window_delegate.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 params.parent = window.get(); | 27 params.parent = window.get(); |
| 28 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 28 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 29 params.native_widget = new DesktopNativeWidgetAura(&widget); | 29 params.native_widget = new DesktopNativeWidgetAura(&widget); |
| 30 widget.Init(params); | 30 widget.Init(params); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Verifies that the AURA windows making up a widget instance have the correct | 33 // Verifies that the AURA windows making up a widget instance have the correct |
| 34 // bounds after the widget is resized. | 34 // bounds after the widget is resized. |
| 35 TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowSizeTest) { | 35 TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowSizeTest) { |
| 36 Widget widget; | 36 Widget widget; |
| 37 | |
| 38 // On Linux we test this with popup windows because the WM may ignore the size | |
| 39 // suggestion for normal windows. | |
| 40 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 41 Widget::InitParams init_params = | |
| 42 CreateParams(Widget::InitParams::TYPE_POPUP); | |
| 43 #else | |
| 37 Widget::InitParams init_params = | 44 Widget::InitParams init_params = |
| 38 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 45 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 46 #endif | |
| 47 | |
| 39 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 48 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 40 init_params.native_widget = new DesktopNativeWidgetAura(&widget); | 49 init_params.native_widget = new DesktopNativeWidgetAura(&widget); |
| 41 widget.Init(init_params); | 50 widget.Init(init_params); |
| 51 | |
| 52 gfx::Rect bounds(0, 0, 100, 100); | |
| 53 widget.SetBounds(bounds); | |
| 54 widget.Show(); | |
| 55 | |
| 56 EXPECT_EQ(bounds.ToString(), | |
| 57 widget.GetNativeView()->GetRootWindow()->bounds().ToString()); | |
| 58 EXPECT_EQ(bounds.ToString(), widget.GetNativeView()->bounds().ToString()); | |
| 59 EXPECT_EQ(bounds.ToString(), | |
| 60 widget.GetNativeView()->parent()->bounds().ToString()); | |
| 61 | |
| 62 gfx::Rect new_bounds(0, 0, 200, 200); | |
| 63 widget.SetBounds(new_bounds); | |
| 64 EXPECT_EQ(new_bounds.ToString(), | |
| 65 widget.GetNativeView()->GetRootWindow()->bounds().ToString()); | |
| 66 EXPECT_EQ(new_bounds.ToString(), widget.GetNativeView()->bounds().ToString()); | |
| 67 EXPECT_EQ(new_bounds.ToString(), | |
| 68 widget.GetNativeView()->parent()->bounds().ToString()); | |
| 69 } | |
| 70 | |
| 71 // Verifies that the AURA windows making up a widget instance have the correct | |
|
Daniel Erat
2014/05/23 14:53:59
nit: s/AURA/Aura/
Evan Stade
2014/05/23 15:30:32
oh whoops, I meant to remove this test which is a
| |
| 72 // bounds after the widget is resized. | |
| 73 TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowSizeTestPopup) { | |
| 74 Widget widget; | |
| 75 Widget::InitParams init_params = | |
| 76 CreateParams(Widget::InitParams::TYPE_POPUP); | |
| 77 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 78 init_params.native_widget = new DesktopNativeWidgetAura(&widget); | |
| 79 widget.Init(init_params); | |
| 42 | 80 |
| 43 gfx::Rect bounds(0, 0, 100, 100); | 81 gfx::Rect bounds(0, 0, 100, 100); |
| 44 widget.SetBounds(bounds); | 82 widget.SetBounds(bounds); |
| 45 widget.Show(); | 83 widget.Show(); |
| 46 | 84 |
| 47 EXPECT_EQ(bounds.ToString(), | 85 EXPECT_EQ(bounds.ToString(), |
| 48 widget.GetNativeView()->GetRootWindow()->bounds().ToString()); | 86 widget.GetNativeView()->GetRootWindow()->bounds().ToString()); |
| 49 EXPECT_EQ(bounds.ToString(), widget.GetNativeView()->bounds().ToString()); | 87 EXPECT_EQ(bounds.ToString(), widget.GetNativeView()->bounds().ToString()); |
| 50 EXPECT_EQ(bounds.ToString(), | 88 EXPECT_EQ(bounds.ToString(), |
| 51 widget.GetNativeView()->parent()->bounds().ToString()); | 89 widget.GetNativeView()->parent()->bounds().ToString()); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 | 248 |
| 211 // Post a task that terminates the nested loop and destroyes the widget. This | 249 // Post a task that terminates the nested loop and destroyes the widget. This |
| 212 // task will be executed from the nested loop initiated with the call to | 250 // task will be executed from the nested loop initiated with the call to |
| 213 // |RunWithDispatcher()| below. | 251 // |RunWithDispatcher()| below. |
| 214 message_loop()->PostTask(FROM_HERE, | 252 message_loop()->PostTask(FROM_HERE, |
| 215 base::Bind(&QuitNestedLoopAndCloseWidget, base::Passed(&widget), client)); | 253 base::Bind(&QuitNestedLoopAndCloseWidget, base::Passed(&widget), client)); |
| 216 client->RunWithDispatcher(NULL); | 254 client->RunWithDispatcher(NULL); |
| 217 } | 255 } |
| 218 | 256 |
| 219 } // namespace views | 257 } // namespace views |
| OLD | NEW |