chromium/chrome/browser/ui/exclusive_access/fullscreen_controller_browsertest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"

#include "base/functional/bind.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/input/native_web_keyboard_event.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes.h"

WebContents;
PAGE_TRANSITION_TYPED;
FullscreenControllerTest;

namespace {

// In some environments (Lacros, Linux, Mac) the operation is finished
// asynchronously and we have to wait until the state change has occurred.
void WaitForDisplayed(Browser* browser) {}

}  // namespace

//
// Fullscreen tests.
//
#if BUILDFLAG(IS_MAC)
#define MAYBE_FullscreenOnFileURL
#else
#define MAYBE_FullscreenOnFileURL
#endif
// TODO(https://crbug.com/330729275): Re-enable when fixed on macOS 14.
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, MAYBE_FullscreenOnFileURL) {}

//
// KeyboardLock fullscreen tests.
//
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, KeyboardLockWithEscLocked) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, KeyboardLockWithEscUnlocked) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockOnFileURLWithEscLocked) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockOnFileURLWithEscUnlocked) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockNotLockedInWindowMode) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockExitsOnEscPressWhenEscNotLocked) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockDoesNotExitOnEscPressWhenEscIsLocked) {}

// Disabled for flaky SEGFAULTs on Lacros: crbug.com/1340114
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_KeyboardLockNotLockedInExtensionFullscreenMode
#else
#define MAYBE_KeyboardLockNotLockedInExtensionFullscreenMode
#endif  // IS_CHROMEOS_LACROS
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       MAYBE_KeyboardLockNotLockedInExtensionFullscreenMode) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockNotLockedAfterFullscreenTransition) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockBubbleHideCallbackUnlock) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FastKeyboardLockUnlockRelock) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, SlowKeyboardLockUnlockRelock) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       RepeatedEscEventsWithinWindowReshowsExitBubble) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       RepeatedEscEventsOutsideWindowDoesNotShowExitBubble) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, KeyboardLockAfterPointerLock) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockAfterPointerLockWithEscLocked) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       KeyboardLockCycleWithMixedEscLockStates) {}

// Test whether the top view's status is correct during various transitions
// among normal state, browser fullscreen mode, and tab fullscreen mode.
// Sheriff: http://crbug.com/925928
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, DISABLED_TopViewStatusChange) {}

// The controller must |CanEnterFullscreenModeForTab| while in fullscreen.
// While an element is in fullscreen, requesting fullscreen for a different
// element in the tab is handled in the renderer process if both elements are in
// the same process. But the request will come to the browser when the element
// is in a different process, such as OOPIF, because the renderer doesn't know
// if an element in other renderer process is in fullscreen. crbug.com/1298081
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
                       EnterFullscreenWhenInFullscreen) {}

class FullscreenControllerPressAndHoldEscTest
    : public FullscreenControllerTest {};

IN_PROC_BROWSER_TEST_F(FullscreenControllerPressAndHoldEscTest,
                       ExitBrowserFullscreenOnPressAndHoldEsc) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerPressAndHoldEscTest,
                       ExitBrowserFullscreenOnMultipleEscKeyDown) {}

IN_PROC_BROWSER_TEST_F(FullscreenControllerPressAndHoldEscTest,
                       ExitBrowserAndTabFullscreenOnPressAndHoldEsc) {}

IN_PROC_BROWSER_TEST_F(
    FullscreenControllerPressAndHoldEscTest,
    ExitBrowserFullscreenAndUnlockKeyboardOnPressAndHoldEsc) {}