Commit c4ccd274 authored by noamsml@google.com's avatar noamsml@google.com

Revert 243938 "Enable all ESC-Fullscreen tests (Chrome Apps) for..."

> Enable all ESC-Fullscreen tests (Chrome Apps) for all platforms.
> 
> There were three issues:
> 1. a silly bug in the fullscreen change check;
> 2. there was no guarantee that the window would be actually focused;
> 3. changing the fullscreen state might come with an animation during which key events will not be received.
> 
> Note that 2 and 3 are a problem on MacOS only.
> 
> BUG=None
> 
> Review URL: https://codereview.chromium.org/116023002

TBR=mlamouri@chromium.org

Review URL: https://codereview.chromium.org/131343003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243955 0039d316-1c4b-4281-b951-d872f2087c98
parent 4354b996
......@@ -7,7 +7,7 @@
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/test/base/interactive_test_utils.h"
using apps::NativeAppWindow;
using namespace apps;
// Helper class that has to be created in the stack to check if the fullscreen
// setting of a NativeWindow has changed since the creation of the object.
......@@ -18,7 +18,7 @@ class FullscreenChangeWaiter {
initial_fullscreen_state_(window_->IsFullscreen()) {}
void Wait() {
while (initial_fullscreen_state_ == window_->IsFullscreen())
while (initial_fullscreen_state_ != window_->IsFullscreen())
content::RunAllPendingInMessageLoop();
}
......@@ -59,27 +59,38 @@ class AppWindowInteractiveTest : public extensions::PlatformAppBrowserTest {
false,
false);
}
// This method will wait until the application is able to ack a key event.
void WaitUntilKeyFocus() {
ExtensionTestMessageListener key_listener("KeyReceived", false);
while (!key_listener.was_satisfied()) {
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z));
content::RunAllPendingInMessageLoop();
}
}
};
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) {
#if defined(OS_LINUX) && defined(USE_AURA)
// These tests do not work on Linux Aura because when the window is raised, the
// content is not focused thus do not get the key events.
// See http://crbug.com/324346
#define MAYBE_ESCDoesNotLeaveFullscreenWindow \
DISABLED_ESCDoesNotLeaveFullscreenWindow
#define MAYBE_ESCDoesNotLeaveFullscreenDOM DISABLED_ESCDoesNotLeaveFullscreenDOM
// These tests are failing on Linux Aura for unknown reasons.
#define MAYBE_ESCLeavesFullscreenWindow DISABLED_ESCLeavesFullscreenWindow
#define MAYBE_ESCLeavesFullscreenDOM DISABLED_ESCLeavesFullscreenDOM
#elif defined(OS_MACOSX)
// These tests are highly flaky on MacOS.
#define MAYBE_ESCLeavesFullscreenWindow DISABLED_ESCLeavesFullscreenWindow
#define MAYBE_ESCLeavesFullscreenDOM DISABLED_ESCLeavesFullscreenDOM
#define MAYBE_ESCDoesNotLeaveFullscreenWindow \
DISABLED_ESCDoesNotLeaveFullscreenWindow
#define MAYBE_ESCDoesNotLeaveFullscreenDOM DISABLED_ESCDoesNotLeaveFullscreenDOM
#else
#define MAYBE_ESCLeavesFullscreenWindow ESCLeavesFullscreenWindow
#define MAYBE_ESCLeavesFullscreenDOM ESCLeavesFullscreenDOM
#define MAYBE_ESCDoesNotLeaveFullscreenWindow ESCDoesNotLeaveFullscreenWindow
#define MAYBE_ESCDoesNotLeaveFullscreenDOM ESCDoesNotLeaveFullscreenDOM
#endif
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
MAYBE_ESCLeavesFullscreenWindow) {
ExtensionTestMessageListener launched_listener("Launched", true);
LoadAndLaunchPlatformApp("leave_fullscreen");
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
// We start by making sure the window is actually focused.
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
GetFirstShellWindow()->GetNativeWindow()));
// When receiving the reply, the application will try to go fullscreen using
// the Window API but there is no synchronous way to know if that actually
// succeeded. Also, failure will not be notified. A failure case will only be
......@@ -92,12 +103,6 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) {
fs_changed.Wait();
}
// Depending on the platform, going fullscreen might create an animation.
// We want to make sure that the ESC key we will send next is actually going
// to be received and the application might not receive key events during the
// animation so we should wait for the key focus to be back.
WaitUntilKeyFocus();
// Same idea as above but for leaving fullscreen. Fullscreen mode should be
// left when ESC is received.
{
......@@ -109,15 +114,11 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) {
}
}
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) {
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_ESCLeavesFullscreenDOM) {
ExtensionTestMessageListener launched_listener("Launched", true);
LoadAndLaunchPlatformApp("leave_fullscreen");
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
// We start by making sure the window is actually focused.
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
GetFirstShellWindow()->GetNativeWindow()));
launched_listener.Reply("dom");
// Because the DOM way to go fullscreen requires user gesture, we simulate a
......@@ -131,18 +132,11 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) {
{
FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
WaitUntilKeyFocus();
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_A));
fs_changed.Wait();
}
// Depending on the platform, going fullscreen might create an animation.
// We want to make sure that the ESC key we will send next is actually going
// to be received and the application might not receive key events during the
// animation so we should wait for the key focus to be back.
WaitUntilKeyFocus();
// Same idea as above but for leaving fullscreen. Fullscreen mode should be
// left when ESC is received.
{
......@@ -155,15 +149,11 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) {
}
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
ESCDoesNotLeaveFullscreenWindow) {
MAYBE_ESCDoesNotLeaveFullscreenWindow) {
ExtensionTestMessageListener launched_listener("Launched", true);
LoadAndLaunchPlatformApp("prevent_leave_fullscreen");
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
// We start by making sure the window is actually focused.
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
GetFirstShellWindow()->GetNativeWindow()));
// When receiving the reply, the application will try to go fullscreen using
// the Window API but there is no synchronous way to know if that actually
// succeeded. Also, failure will not be notified. A failure case will only be
......@@ -176,12 +166,6 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
fs_changed.Wait();
}
// Depending on the platform, going fullscreen might create an animation.
// We want to make sure that the ESC key we will send next is actually going
// to be received and the application might not receive key events during the
// animation so we should wait for the key focus to be back.
WaitUntilKeyFocus();
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false);
......@@ -198,15 +182,11 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
}
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
ESCDoesNotLeaveFullscreenDOM) {
MAYBE_ESCDoesNotLeaveFullscreenDOM) {
ExtensionTestMessageListener launched_listener("Launched", true);
LoadAndLaunchPlatformApp("prevent_leave_fullscreen");
ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
// We start by making sure the window is actually focused.
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
GetFirstShellWindow()->GetNativeWindow()));
launched_listener.Reply("dom");
// Because the DOM way to go fullscreen requires user gesture, we simulate a
......@@ -220,18 +200,11 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
{
FullscreenChangeWaiter fs_changed(GetFirstShellWindow()->GetBaseWindow());
WaitUntilKeyFocus();
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_A));
fs_changed.Wait();
}
// Depending on the platform, going fullscreen might create an animation.
// We want to make sure that the ESC key we will send next is actually going
// to be received and the application might not receive key events during the
// animation so we should wait for the key focus to be back.
WaitUntilKeyFocus();
ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE));
ExtensionTestMessageListener second_key_listener("B_KEY_RECEIVED", false);
......
......@@ -14,13 +14,6 @@ chrome.app.runtime.onLaunched.addListener(function() {
});
chrome.test.sendMessage('Launched', function(reply) {
win.contentWindow.document.addEventListener('keydown', function(e) {
if (e.keyCode != 90) // 'z'
return;
chrome.test.sendMessage('KeyReceived');
});
switch (reply) {
case 'window':
win.fullscreen();
......
......@@ -15,11 +15,6 @@ chrome.app.runtime.onLaunched.addListener(function() {
chrome.test.sendMessage('Launched', function(reply) {
var doc = win.contentWindow.document;
doc.addEventListener('keydown', function(e) {
if (e.keyCode != 90) // 'z'
return;
chrome.test.sendMessage('KeyReceived');
});
switch (reply) {
case 'window':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment