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
3 // found in the LICENSE file.
5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
7 #include "ui/aura/root_window.h"
8 #include "ui/views/test/views_test_base.h"
9 #include "ui/views/widget/widget.h"
13 typedef ViewsTestBase DesktopNativeWidgetAuraTest;
15 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't
17 TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) {
18 scoped_ptr<aura::Window> window(new aura::Window(NULL));
20 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
21 params.bounds = gfx::Rect(0, 0, 200, 200);
22 params.parent = window.get();
23 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
24 params.native_widget = new DesktopNativeWidgetAura(&widget);
28 // Verifies that the AURA windows making up a widget instance have the correct
29 // bounds after the widget is resized.
30 TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowSizeTest) {
32 Widget::InitParams init_params =
33 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
34 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
35 init_params.native_widget = new DesktopNativeWidgetAura(&widget);
36 widget.Init(init_params);
38 gfx::Rect bounds(0, 0, 100, 100);
39 widget.SetBounds(bounds);
42 EXPECT_EQ(bounds.ToString(),
43 widget.GetNativeView()->GetRootWindow()->bounds().ToString());
44 EXPECT_EQ(bounds.ToString(), widget.GetNativeView()->bounds().ToString());
45 EXPECT_EQ(bounds.ToString(),
46 widget.GetNativeView()->parent()->bounds().ToString());
48 gfx::Rect new_bounds(0, 0, 200, 200);
49 widget.SetBounds(new_bounds);
50 EXPECT_EQ(new_bounds.ToString(),
51 widget.GetNativeView()->GetRootWindow()->bounds().ToString());
52 EXPECT_EQ(new_bounds.ToString(), widget.GetNativeView()->bounds().ToString());
53 EXPECT_EQ(new_bounds.ToString(),
54 widget.GetNativeView()->parent()->bounds().ToString());
57 // Verifies GetNativeView() is initially hidden. If the native view is initially
58 // shown then animations can not be disabled.
59 TEST_F(DesktopNativeWidgetAuraTest, NativeViewInitiallyHidden) {
61 Widget::InitParams init_params =
62 CreateParams(Widget::InitParams::TYPE_WINDOW);
63 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
64 init_params.native_widget = new DesktopNativeWidgetAura(&widget);
65 widget.Init(init_params);
66 EXPECT_FALSE(widget.GetNativeView()->IsVisible());