Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: trunk/src/chrome/browser/apps/app_window_interactive_uitest.cc

Issue 131343003: Revert 243938 "Enable all ESC-Fullscreen tests (Chrome Apps) for..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/src/chrome/test/data/extensions/platform_apps/leave_fullscreen/main.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "apps/ui/native_app_window.h" 5 #include "apps/ui/native_app_window.h"
6 #include "chrome/browser/apps/app_browsertest_util.h" 6 #include "chrome/browser/apps/app_browsertest_util.h"
7 #include "chrome/browser/extensions/extension_test_message_listener.h" 7 #include "chrome/browser/extensions/extension_test_message_listener.h"
8 #include "chrome/test/base/interactive_test_utils.h" 8 #include "chrome/test/base/interactive_test_utils.h"
9 9
10 using apps::NativeAppWindow; 10 using namespace apps;
11 11
12 // Helper class that has to be created in the stack to check if the fullscreen 12 // Helper class that has to be created in the stack to check if the fullscreen
13 // setting of a NativeWindow has changed since the creation of the object. 13 // setting of a NativeWindow has changed since the creation of the object.
14 class FullscreenChangeWaiter { 14 class FullscreenChangeWaiter {
15 public: 15 public:
16 explicit FullscreenChangeWaiter(NativeAppWindow* window) 16 explicit FullscreenChangeWaiter(NativeAppWindow* window)
17 : window_(window), 17 : window_(window),
18 initial_fullscreen_state_(window_->IsFullscreen()) {} 18 initial_fullscreen_state_(window_->IsFullscreen()) {}
19 19
20 void Wait() { 20 void Wait() {
21 while (initial_fullscreen_state_ == window_->IsFullscreen()) 21 while (initial_fullscreen_state_ != window_->IsFullscreen())
22 content::RunAllPendingInMessageLoop(); 22 content::RunAllPendingInMessageLoop();
23 } 23 }
24 24
25 private: 25 private:
26 NativeAppWindow* window_; 26 NativeAppWindow* window_;
27 bool initial_fullscreen_state_; 27 bool initial_fullscreen_state_;
28 28
29 DISALLOW_COPY_AND_ASSIGN(FullscreenChangeWaiter); 29 DISALLOW_COPY_AND_ASSIGN(FullscreenChangeWaiter);
30 }; 30 };
31 31
(...skipping 20 matching lines...) Expand all
52 52
53 bool SimulateKeyPress(ui::KeyboardCode key) { 53 bool SimulateKeyPress(ui::KeyboardCode key) {
54 return ui_test_utils::SendKeyPressToWindowSync( 54 return ui_test_utils::SendKeyPressToWindowSync(
55 GetFirstShellWindow()->GetNativeWindow(), 55 GetFirstShellWindow()->GetNativeWindow(),
56 key, 56 key,
57 false, 57 false,
58 false, 58 false,
59 false, 59 false,
60 false); 60 false);
61 } 61 }
62
63 // This method will wait until the application is able to ack a key event.
64 void WaitUntilKeyFocus() {
65 ExtensionTestMessageListener key_listener("KeyReceived", false);
66
67 while (!key_listener.was_satisfied()) {
68 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z));
69 content::RunAllPendingInMessageLoop();
70 }
71 }
72 }; 62 };
73 63
74 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) { 64 #if defined(OS_LINUX) && defined(USE_AURA)
65 // These tests do not work on Linux Aura because when the window is raised, the
66 // content is not focused thus do not get the key events.
67 // See http://crbug.com/324346
68 #define MAYBE_ESCDoesNotLeaveFullscreenWindow \
69 DISABLED_ESCDoesNotLeaveFullscreenWindow
70 #define MAYBE_ESCDoesNotLeaveFullscreenDOM DISABLED_ESCDoesNotLeaveFullscreenDOM
71 // These tests are failing on Linux Aura for unknown reasons.
72 #define MAYBE_ESCLeavesFullscreenWindow DISABLED_ESCLeavesFullscreenWindow
73 #define MAYBE_ESCLeavesFullscreenDOM DISABLED_ESCLeavesFullscreenDOM
74 #elif defined(OS_MACOSX)
75 // These tests are highly flaky on MacOS.
76 #define MAYBE_ESCLeavesFullscreenWindow DISABLED_ESCLeavesFullscreenWindow
77 #define MAYBE_ESCLeavesFullscreenDOM DISABLED_ESCLeavesFullscreenDOM
78 #define MAYBE_ESCDoesNotLeaveFullscreenWindow \
79 DISABLED_ESCDoesNotLeaveFullscreenWindow
80 #define MAYBE_ESCDoesNotLeaveFullscreenDOM DISABLED_ESCDoesNotLeaveFullscreenDOM
81 #else
82 #define MAYBE_ESCLeavesFullscreenWindow ESCLeavesFullscreenWindow
83 #define MAYBE_ESCLeavesFullscreenDOM ESCLeavesFullscreenDOM
84 #define MAYBE_ESCDoesNotLeaveFullscreenWindow ESCDoesNotLeaveFullscreenWindow
85 #define MAYBE_ESCDoesNotLeaveFullscreenDOM ESCDoesNotLeaveFullscreenDOM
86 #endif
87
88 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
89 MAYBE_ESCLeavesFullscreenWindow) {
75 ExtensionTestMessageListener launched_listener("Launched", true); 90 ExtensionTestMessageListener launched_listener("Launched", true);
76 LoadAndLaunchPlatformApp("leave_fullscreen"); 91 LoadAndLaunchPlatformApp("leave_fullscreen");
77 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 92 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
78 93
79 // We start by making sure the window is actually focused.
80 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
81 GetFirstShellWindow()->GetNativeWindow()));
82
83 // When receiving the reply, the application will try to go fullscreen using 94 // When receiving the reply, the application will try to go fullscreen using
84 // the Window API but there is no synchronous way to know if that actually 95 // the Window API but there is no synchronous way to know if that actually
85 // succeeded. Also, failure will not be notified. A failure case will only be 96 // succeeded. Also, failure will not be notified. A failure case will only be
86 // known with a timeout. 97 // known with a timeout.
87 { 98 {
88 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow()); 99 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
89 100
90 launched_listener.Reply("window"); 101 launched_listener.Reply("window");
91 102
92 fs_changed.Wait(); 103 fs_changed.Wait();
93 } 104 }
94 105
95 // Depending on the platform, going fullscreen might create an animation.
96 // We want to make sure that the ESC key we will send next is actually going
97 // to be received and the application might not receive key events during the
98 // animation so we should wait for the key focus to be back.
99 WaitUntilKeyFocus();
100
101 // Same idea as above but for leaving fullscreen. Fullscreen mode should be 106 // Same idea as above but for leaving fullscreen. Fullscreen mode should be
102 // left when ESC is received. 107 // left when ESC is received.
103 { 108 {
104 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow()); 109 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
105 110
106 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); 111 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
107 112
108 fs_changed.Wait(); 113 fs_changed.Wait();
109 } 114 }
110 } 115 }
111 116
112 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) { 117 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_ESCLeavesFullscreenDOM) {
113 ExtensionTestMessageListener launched_listener("Launched", true); 118 ExtensionTestMessageListener launched_listener("Launched", true);
114 LoadAndLaunchPlatformApp("leave_fullscreen"); 119 LoadAndLaunchPlatformApp("leave_fullscreen");
115 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 120 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
116 121
117 // We start by making sure the window is actually focused.
118 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
119 GetFirstShellWindow()->GetNativeWindow()));
120
121 launched_listener.Reply("dom"); 122 launched_listener.Reply("dom");
122 123
123 // Because the DOM way to go fullscreen requires user gesture, we simulate a 124 // Because the DOM way to go fullscreen requires user gesture, we simulate a
124 // key event to get the window entering in fullscreen mode. The reply will 125 // key event to get the window entering in fullscreen mode. The reply will
125 // make the window listen for the key event. The reply will be sent to the 126 // make the window listen for the key event. The reply will be sent to the
126 // renderer process before the keypress and should be received in that order. 127 // renderer process before the keypress and should be received in that order.
127 // When receiving the key event, the application will try to go fullscreen 128 // When receiving the key event, the application will try to go fullscreen
128 // using the Window API but there is no synchronous way to know if that 129 // using the Window API but there is no synchronous way to know if that
129 // actually succeeded. Also, failure will not be notified. A failure case will 130 // actually succeeded. Also, failure will not be notified. A failure case will
130 // only be known with a timeout. 131 // only be known with a timeout.
131 { 132 {
132 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow()); 133 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
133 134
134 WaitUntilKeyFocus();
135 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_A)); 135 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_A));
136 136
137 fs_changed.Wait(); 137 fs_changed.Wait();
138 } 138 }
139 139
140 // Depending on the platform, going fullscreen might create an animation.
141 // We want to make sure that the ESC key we will send next is actually going
142 // to be received and the application might not receive key events during the
143 // animation so we should wait for the key focus to be back.
144 WaitUntilKeyFocus();
145
146 // Same idea as above but for leaving fullscreen. Fullscreen mode should be 140 // Same idea as above but for leaving fullscreen. Fullscreen mode should be
147 // left when ESC is received. 141 // left when ESC is received.
148 { 142 {
149 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow()); 143 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
150 144
151 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); 145 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
152 146
153 fs_changed.Wait(); 147 fs_changed.Wait();
154 } 148 }
155 } 149 }
156 150
157 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, 151 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
158 ESCDoesNotLeaveFullscreenWindow) { 152 MAYBE_ESCDoesNotLeaveFullscreenWindow) {
159 ExtensionTestMessageListener launched_listener("Launched", true); 153 ExtensionTestMessageListener launched_listener("Launched", true);
160 LoadAndLaunchPlatformApp("prevent_leave_fullscreen"); 154 LoadAndLaunchPlatformApp("prevent_leave_fullscreen");
161 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 155 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
162 156
163 // We start by making sure the window is actually focused.
164 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
165 GetFirstShellWindow()->GetNativeWindow()));
166
167 // When receiving the reply, the application will try to go fullscreen using 157 // When receiving the reply, the application will try to go fullscreen using
168 // the Window API but there is no synchronous way to know if that actually 158 // the Window API but there is no synchronous way to know if that actually
169 // succeeded. Also, failure will not be notified. A failure case will only be 159 // succeeded. Also, failure will not be notified. A failure case will only be
170 // known with a timeout. 160 // known with a timeout.
171 { 161 {
172 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow()); 162 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
173 163
174 launched_listener.Reply("window"); 164 launched_listener.Reply("window");
175 165
176 fs_changed.Wait(); 166 fs_changed.Wait();
177 } 167 }
178 168
179 // Depending on the platform, going fullscreen might create an animation.
180 // We want to make sure that the ESC key we will send next is actually going
181 // to be received and the application might not receive key events during the
182 // animation so we should wait for the key focus to be back.
183 WaitUntilKeyFocus();
184
185 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); 169 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
186 170
187 ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false); 171 ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false);
188 172
189 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B)); 173 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B));
190 174
191 ASSERT_TRUE(second_key_listener.WaitUntilSatisfied()); 175 ASSERT_TRUE(second_key_listener.WaitUntilSatisfied());
192 176
193 // We assume that at that point, if we had to leave fullscreen, we should be. 177 // We assume that at that point, if we had to leave fullscreen, we should be.
194 // However, by nature, we can not guarantee that and given that we do test 178 // However, by nature, we can not guarantee that and given that we do test
195 // that nothing happens, we might end up with random-success when the feature 179 // that nothing happens, we might end up with random-success when the feature
196 // is broken. 180 // is broken.
197 EXPECT_TRUE(GetFirstShellWindow()->GetBaseWindow()->IsFullscreen()); 181 EXPECT_TRUE(GetFirstShellWindow()->GetBaseWindow()->IsFullscreen());
198 } 182 }
199 183
200 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, 184 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
201 ESCDoesNotLeaveFullscreenDOM) { 185 MAYBE_ESCDoesNotLeaveFullscreenDOM) {
202 ExtensionTestMessageListener launched_listener("Launched", true); 186 ExtensionTestMessageListener launched_listener("Launched", true);
203 LoadAndLaunchPlatformApp("prevent_leave_fullscreen"); 187 LoadAndLaunchPlatformApp("prevent_leave_fullscreen");
204 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 188 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
205 189
206 // We start by making sure the window is actually focused.
207 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
208 GetFirstShellWindow()->GetNativeWindow()));
209
210 launched_listener.Reply("dom"); 190 launched_listener.Reply("dom");
211 191
212 // Because the DOM way to go fullscreen requires user gesture, we simulate a 192 // Because the DOM way to go fullscreen requires user gesture, we simulate a
213 // key event to get the window entering in fullscreen mode. The reply will 193 // key event to get the window entering in fullscreen mode. The reply will
214 // make the window listen for the key event. The reply will be sent to the 194 // make the window listen for the key event. The reply will be sent to the
215 // renderer process before the keypress and should be received in that order. 195 // renderer process before the keypress and should be received in that order.
216 // When receiving the key event, the application will try to go fullscreen 196 // When receiving the key event, the application will try to go fullscreen
217 // using the Window API but there is no synchronous way to know if that 197 // using the Window API but there is no synchronous way to know if that
218 // actually succeeded. Also, failure will not be notified. A failure case will 198 // actually succeeded. Also, failure will not be notified. A failure case will
219 // only be known with a timeout. 199 // only be known with a timeout.
220 { 200 {
221 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow()); 201 FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
222 202
223 WaitUntilKeyFocus();
224 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_A)); 203 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_A));
225 204
226 fs_changed.Wait(); 205 fs_changed.Wait();
227 } 206 }
228 207
229 // Depending on the platform, going fullscreen might create an animation.
230 // We want to make sure that the ESC key we will send next is actually going
231 // to be received and the application might not receive key events during the
232 // animation so we should wait for the key focus to be back.
233 WaitUntilKeyFocus();
234
235 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); 208 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
236 209
237 ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false); 210 ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false);
238 211
239 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B)); 212 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_B));
240 213
241 ASSERT_TRUE(second_key_listener.WaitUntilSatisfied()); 214 ASSERT_TRUE(second_key_listener.WaitUntilSatisfied());
242 215
243 // We assume that at that point, if we had to leave fullscreen, we should be. 216 // We assume that at that point, if we had to leave fullscreen, we should be.
244 // However, by nature, we can not guarantee that and given that we do test 217 // However, by nature, we can not guarantee that and given that we do test
(...skipping 19 matching lines...) Expand all
264 #define MAYBE_TestShow TestShow 237 #define MAYBE_TestShow TestShow
265 #endif 238 #endif
266 239
267 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestCreate) { 240 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestCreate) {
268 ASSERT_TRUE(RunAppWindowInteractiveTest("testCreate")) << message_; 241 ASSERT_TRUE(RunAppWindowInteractiveTest("testCreate")) << message_;
269 } 242 }
270 243
271 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestShow) { 244 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestShow) {
272 ASSERT_TRUE(RunAppWindowInteractiveTest("testShow")) << message_; 245 ASSERT_TRUE(RunAppWindowInteractiveTest("testShow")) << message_;
273 } 246 }
OLDNEW
« no previous file with comments | « no previous file | trunk/src/chrome/test/data/extensions/platform_apps/leave_fullscreen/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698