This source file includes following definitions.
- TEST_F
- TEST_F
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
namespace views {
typedef ViewsTestBase DesktopScreenPositionClientTest;
TEST_F(DesktopScreenPositionClientTest, PositionDialog) {
Widget parent_widget;
Widget::InitParams init_params =
CreateParams(Widget::InitParams::TYPE_WINDOW);
init_params.bounds = gfx::Rect(10, 11, 200, 200);
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
init_params.native_widget = new DesktopNativeWidgetAura(&parent_widget);
parent_widget.Init(init_params);
DialogDelegateView* dialog_delegate_view = new DialogDelegateView;
Widget* dialog = DialogDelegate::CreateDialogWidget(
dialog_delegate_view,
NULL,
parent_widget.GetNativeView());
dialog->SetBounds(gfx::Rect(11, 12, 200, 200));
EXPECT_EQ("11,12", dialog->GetWindowBoundsInScreen().origin().ToString());
}
TEST_F(DesktopScreenPositionClientTest, PositionControlWithNonRootParent) {
Widget widget1;
Widget widget2;
Widget widget3;
gfx::Point origin = gfx::Point(16, 16);
widget1.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM);
widget2.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM);
widget3.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM);
Widget::InitParams params1 =
CreateParams(Widget::InitParams::TYPE_WINDOW);
params1.bounds = gfx::Rect(origin, gfx::Size(700, 600));
params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params1.native_widget = new DesktopNativeWidgetAura(&widget1);
widget1.Init(params1);
Widget::InitParams params2 =
CreateParams(Widget::InitParams::TYPE_WINDOW);
params2.bounds = gfx::Rect(origin, gfx::Size(600, 500));
params2.parent = widget1.GetNativeView();
params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params2.child = true;
widget2.Init(params2);
Widget::InitParams params3 =
CreateParams(Widget::InitParams::TYPE_CONTROL);
params3.parent = widget2.GetNativeView();
params3.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params3.child = true;
params3.bounds = gfx::Rect(origin, gfx::Size(500, 400));
widget3.Init(params3);
gfx::Point expected_origin(origin.x() * 3, origin.y() * 3);
gfx::Rect expected_bounds(expected_origin, gfx::Size(500, 400));
gfx::Rect actual_bounds(widget3.GetWindowBoundsInScreen());
EXPECT_EQ(expected_bounds.ToString(), actual_bounds.ToString());
}
}