[Mac] Make app window backgrounds white.
[chromium-blink-merge.git] / apps / app_window_interactive_uitest.cc
blob4433ca93053684375a14608298d9306f109929bd
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.
5 #include "apps/ui/native_app_window.h"
6 #include "chrome/browser/apps/app_browsertest_util.h"
8 using extensions::PlatformAppBrowserTest;
9 using extensions::Extension;
11 namespace apps {
13 namespace {
15 class AppWindowTest : public PlatformAppBrowserTest {
16 protected:
17 void CheckAlwaysOnTopToFullscreen(AppWindow* window) {
18 ASSERT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
20 // The always-on-top property should be temporarily disabled when the window
21 // enters fullscreen.
22 window->Fullscreen();
23 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
25 // From the API's point of view, the always-on-top property is enabled.
26 EXPECT_TRUE(window->IsAlwaysOnTop());
28 // The always-on-top property is restored when the window exits fullscreen.
29 window->Restore();
30 EXPECT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
33 void CheckNormalToFullscreen(AppWindow* window) {
34 // If the always-on-top property is false, it should remain this way when
35 // entering and exiting fullscreen mode.
36 ASSERT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
37 window->Fullscreen();
38 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
39 window->Restore();
40 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
43 void CheckFullscreenToAlwaysOnTop(AppWindow* window) {
44 ASSERT_TRUE(window->GetBaseWindow()->IsFullscreenOrPending());
46 // Now enable always-on-top at runtime and ensure the property does not get
47 // applied immediately because the window is in fullscreen mode.
48 window->SetAlwaysOnTop(true);
49 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
51 // From the API's point of view, the always-on-top property is enabled.
52 EXPECT_TRUE(window->IsAlwaysOnTop());
54 // Ensure the always-on-top property is applied when exiting fullscreen.
55 window->Restore();
56 EXPECT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
60 } // namespace
62 // Tests are flaky on Mac as transitioning to fullscreen is not instantaneous
63 // and throws errors when entering/exiting fullscreen too quickly.
64 #if defined(OS_MACOSX)
65 #define MAYBE_InitAlwaysOnTopToFullscreen DISABLED_InitAlwaysOnTopToFullscreen
66 #else
67 #define MAYBE_InitAlwaysOnTopToFullscreen InitAlwaysOnTopToFullscreen
68 #endif
70 // Tests a window created with always-on-top enabled and ensures that the
71 // property is temporarily switched off when entering fullscreen mode.
72 IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_InitAlwaysOnTopToFullscreen) {
73 AppWindow* window = CreateTestAppWindow("{ \"alwaysOnTop\": true }");
74 ASSERT_TRUE(window);
75 CheckAlwaysOnTopToFullscreen(window);
77 window->SetAlwaysOnTop(false);
78 CheckNormalToFullscreen(window);
80 CloseAppWindow(window);
83 #if defined(OS_MACOSX)
84 #define MAYBE_RuntimeAlwaysOnTopToFullscreen \
85 DISABLED_RuntimeAlwaysOnTopToFullscreen
86 #else
87 #define MAYBE_RuntimeAlwaysOnTopToFullscreen RuntimeAlwaysOnTopToFullscreen
88 #endif
90 // Tests a window with always-on-top enabled at runtime and ensures that the
91 // property is temporarily switched off when entering fullscreen mode.
92 IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_RuntimeAlwaysOnTopToFullscreen) {
93 AppWindow* window = CreateTestAppWindow("{}");
94 ASSERT_TRUE(window);
95 CheckNormalToFullscreen(window);
97 window->SetAlwaysOnTop(true);
98 CheckAlwaysOnTopToFullscreen(window);
100 CloseAppWindow(window);
103 #if defined(OS_MACOSX)
104 #define MAYBE_InitFullscreenToAlwaysOnTop DISABLED_InitFullscreenToAlwaysOnTop
105 #else
106 #define MAYBE_InitFullscreenToAlwaysOnTop InitFullscreenToAlwaysOnTop
107 #endif
109 // Tests a window created initially in fullscreen mode and ensures that the
110 // always-on-top property does not get applied until it exits fullscreen.
111 IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_InitFullscreenToAlwaysOnTop) {
112 AppWindow* window = CreateTestAppWindow("{ \"state\": \"fullscreen\" }");
113 ASSERT_TRUE(window);
114 CheckFullscreenToAlwaysOnTop(window);
116 CloseAppWindow(window);
119 #if defined(OS_MACOSX)
120 #define MAYBE_RuntimeFullscreenToAlwaysOnTop \
121 DISABLED_RuntimeFullscreenToAlwaysOnTop
122 #else
123 #define MAYBE_RuntimeFullscreenToAlwaysOnTop RuntimeFullscreenToAlwaysOnTop
124 #endif
126 // Tests a window that enters fullscreen mode at runtime and ensures that the
127 // always-on-top property does not get applied until it exits fullscreen.
128 IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_RuntimeFullscreenToAlwaysOnTop) {
129 AppWindow* window = CreateTestAppWindow("{}");
130 ASSERT_TRUE(window);
132 window->Fullscreen();
133 CheckFullscreenToAlwaysOnTop(window);
135 CloseAppWindow(window);
138 #if defined(OS_MACOSX)
139 #define MAYBE_InitFullscreenAndAlwaysOnTop DISABLED_InitFullscreenAndAlwaysOnTop
140 #else
141 #define MAYBE_InitFullscreenAndAlwaysOnTop InitFullscreenAndAlwaysOnTop
142 #endif
144 // Tests a window created with both fullscreen and always-on-top enabled. Ensure
145 // that always-on-top is only applied when the window exits fullscreen.
146 IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_InitFullscreenAndAlwaysOnTop) {
147 AppWindow* window = CreateTestAppWindow(
148 "{ \"alwaysOnTop\": true, \"state\": \"fullscreen\" }");
149 ASSERT_TRUE(window);
151 EXPECT_TRUE(window->GetBaseWindow()->IsFullscreenOrPending());
152 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
154 // From the API's point of view, the always-on-top property is enabled.
155 EXPECT_TRUE(window->IsAlwaysOnTop());
157 window->Restore();
158 EXPECT_TRUE(window->GetBaseWindow()->IsAlwaysOnTop());
160 CloseAppWindow(window);
163 #if defined(OS_MACOSX)
164 #define MAYBE_DisableAlwaysOnTopInFullscreen \
165 DISABLED_DisableAlwaysOnTopInFullscreen
166 #else
167 #define MAYBE_DisableAlwaysOnTopInFullscreen DisableAlwaysOnTopInFullscreen
168 #endif
170 // Tests a window created with always-on-top enabled, but then disabled while
171 // in fullscreen mode. After exiting fullscreen, always-on-top should remain
172 // disabled.
173 IN_PROC_BROWSER_TEST_F(AppWindowTest, MAYBE_DisableAlwaysOnTopInFullscreen) {
174 AppWindow* window = CreateTestAppWindow("{ \"alwaysOnTop\": true }");
175 ASSERT_TRUE(window);
177 // Disable always-on-top while in fullscreen mode.
178 window->Fullscreen();
179 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
180 window->SetAlwaysOnTop(false);
181 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
183 // Ensure that always-on-top remains disabled.
184 window->Restore();
185 EXPECT_FALSE(window->GetBaseWindow()->IsAlwaysOnTop());
187 CloseAppWindow(window);
190 } // namespace apps