- add sources.
[platform/framework/web/crosswalk.git] / src / ui / views / widget / desktop_aura / desktop_native_widget_aura_unittest.cc
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.
4
5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
6
7 #include "ui/aura/root_window.h"
8 #include "ui/views/test/views_test_base.h"
9 #include "ui/views/widget/widget.h"
10
11 namespace views {
12
13 typedef ViewsTestBase DesktopNativeWidgetAuraTest;
14
15 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't
16 // crash.
17 TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) {
18   scoped_ptr<aura::Window> window(new aura::Window(NULL));
19   Widget widget;
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);
25   widget.Init(params);
26 }
27
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) {
31   Widget widget;
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);
37
38   gfx::Rect bounds(0, 0, 100, 100);
39   widget.SetBounds(bounds);
40   widget.Show();
41
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());
47
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());
55 }
56
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) {
60   Widget widget;
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());
67 }
68
69 }  // namespace views