Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / app_window / app_window_browsertest.cc
1 // Copyright 2014 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 "chrome/browser/apps/app_browsertest_util.h"
6 #include "extensions/browser/app_window/native_app_window.h"
7
8 namespace extensions {
9
10 namespace {
11
12 typedef PlatformAppBrowserTest AppWindowBrowserTest;
13
14 // This test is disabled on Linux because of the unpredictable nature of native
15 // windows. We cannot assume that the window manager will insert any title bar
16 // at all, so the test may fail on certain window managers.
17 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
18 #define MAYBE_FrameInsetsForDefaultFrame DISABLED_FrameInsetsForDefaultFrame
19 #else
20 #define MAYBE_FrameInsetsForDefaultFrame FrameInsetsForDefaultFrame
21 #endif
22
23 // Verifies that the NativeAppWindows implement GetFrameInsets() correctly.
24 // See http://crbug.com/346115
25 IN_PROC_BROWSER_TEST_F(AppWindowBrowserTest, MAYBE_FrameInsetsForDefaultFrame) {
26   AppWindow* app_window = CreateTestAppWindow("{}");
27   NativeAppWindow* native_window = app_window->GetBaseWindow();
28   gfx::Insets insets = native_window->GetFrameInsets();
29
30   // It is a reasonable assumption that the top padding must be greater than
31   // the bottom padding due to the title bar.
32   EXPECT_GT(insets.top(), insets.bottom());
33
34   CloseAppWindow(app_window);
35 }
36
37 // Verifies that the NativeAppWindows implement GetFrameInsets() correctly.
38 // See http://crbug.com/346115
39 IN_PROC_BROWSER_TEST_F(AppWindowBrowserTest, FrameInsetsForColoredFrame) {
40   AppWindow* app_window =
41       CreateTestAppWindow("{ \"frame\": { \"color\": \"#ffffff\" } }");
42   NativeAppWindow* native_window = app_window->GetBaseWindow();
43   gfx::Insets insets = native_window->GetFrameInsets();
44
45   // It is a reasonable assumption that the top padding must be greater than
46   // the bottom padding due to the title bar.
47   EXPECT_GT(insets.top(), insets.bottom());
48
49   CloseAppWindow(app_window);
50 }
51
52 // Verifies that the NativeAppWindows implement GetFrameInsets() correctly for
53 // frameless windows.
54 IN_PROC_BROWSER_TEST_F(AppWindowBrowserTest, FrameInsetsForNoFrame) {
55   AppWindow* app_window = CreateTestAppWindow("{ \"frame\": \"none\" }");
56   NativeAppWindow* native_window = app_window->GetBaseWindow();
57   gfx::Insets insets = native_window->GetFrameInsets();
58
59   // All insets must be zero.
60   EXPECT_EQ(0, insets.top());
61   EXPECT_EQ(0, insets.bottom());
62   EXPECT_EQ(0, insets.left());
63   EXPECT_EQ(0, insets.right());
64
65   CloseAppWindow(app_window);
66 }
67
68 }  // namespace
69
70 }  // namespace extensions