#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/fullscreen_keyboard_browsertest_base.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/safe_browsing/core/common/features.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/features.h"
#include "ui/base/ui_base_features.h"
#if BUILDFLAG(IS_MAC)
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
#endif
namespace {
constexpr char kKeyboardLockMethodExistanceCheck[] = …;
constexpr char kKeyboardLockMethodCallWithAllKeys[] = …;
constexpr char kKeyboardLockMethodCallWithSomeKeys[] = …;
constexpr char kKeyboardLockMethodCallWithEscapeKey[] = …;
constexpr char kKeyboardUnlockMethodCall[] = …;
constexpr char kSimplePageHTML[] = …;
constexpr char kDownloadFolder[] = …;
constexpr char kDownloadFile[] = …;
}
class KeyboardLockInteractiveBrowserTest
: public FullscreenKeyboardBrowserTestBase { … };
KeyboardLockInteractiveBrowserTest::KeyboardLockInteractiveBrowserTest()
: … { … }
KeyboardLockInteractiveBrowserTest::~KeyboardLockInteractiveBrowserTest() =
default;
void KeyboardLockInteractiveBrowserTest::SetUpCommandLine(
base::CommandLine* command_line) { … }
void KeyboardLockInteractiveBrowserTest::SetUpOnMainThread() { … }
net::EmbeddedTestServer*
KeyboardLockInteractiveBrowserTest::GetEmbeddedTestServer() { … }
bool KeyboardLockInteractiveBrowserTest::KeyboardLockApiExists() { … }
bool KeyboardLockInteractiveBrowserTest::IsKeyboardLockActive() { … }
bool KeyboardLockInteractiveBrowserTest::IsKeyboardLockRequestRegistered() { … }
bool KeyboardLockInteractiveBrowserTest::RequestKeyboardLock(
bool lock_all_keys ) { … }
bool KeyboardLockInteractiveBrowserTest::CancelKeyboardLock() { … }
#if BUILDFLAG(IS_MAC)
void KeyboardLockInteractiveBrowserTest::ExitFullscreen() {
fake_fullscreen_.reset();
}
#endif
bool KeyboardLockInteractiveBrowserTest::DisablePreventDefaultOnTestPage() { … }
#if BUILDFLAG(IS_LINUX)
#define MAYBE_RequestedButNotActive …
#else
#define MAYBE_RequestedButNotActive …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_RequestedButNotActive) { … }
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
ActiveWithAllKeysLocked) { … }
#if BUILDFLAG(IS_LINUX)
#define MAYBE_ActiveWithSomeKeysLocked …
#else
#define MAYBE_ActiveWithSomeKeysLocked …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_ActiveWithSomeKeysLocked) { … }
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC)
#define MAYBE_SubsequentLockCallSupersedesPreviousCall …
#else
#define MAYBE_SubsequentLockCallSupersedesPreviousCall …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_SubsequentLockCallSupersedesPreviousCall) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_RequestedButNotActiveInBrowserFullscreen …
#else
#define MAYBE_RequestedButNotActiveInBrowserFullscreen …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_RequestedButNotActiveInBrowserFullscreen) { … }
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
CancelActiveKeyboardLockInFullscreen) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_CancelActiveKeyboardLockBeforeFullscreen …
#else
#define MAYBE_CancelActiveKeyboardLockBeforeFullscreen …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_CancelActiveKeyboardLockBeforeFullscreen) { … }
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
PressEscapeExitsFullscreenWhenEscNotLocked) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_GainAndLoseFocusInWindowMode …
#else
#define MAYBE_GainAndLoseFocusInWindowMode …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_GainAndLoseFocusInWindowMode) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_GainAndLoseFocusInFullscreen …
#else
#define MAYBE_GainAndLoseFocusInFullscreen …
#endif
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
MAYBE_GainAndLoseFocusInFullscreen) { … }
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
KeyboardUnlockedWhenNavigatingToSameUrl) { … }
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
KeyboardUnlockedWhenNavigatingAway) { … }
IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest,
DownloadNavigationDoesNotUnlock) { … }