chromium/headless/test/headless_devtools_client_browsertest.cc

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

#include <memory>

#include "base/base_paths.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/devtools/simple_devtools_protocol_client/simple_devtools_protocol_client.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/no_renderer_crashes_assertion.h"
#include "headless/lib/browser/headless_web_contents_impl.h"
#include "headless/public/switches.h"
#include "headless/test/headless_browser_test.h"
#include "headless/test/headless_browser_test_utils.h"
#include "headless/test/headless_devtooled_browsertest.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "third_party/inspector_protocol/crdtp/dispatch.h"
#include "url/gurl.h"

#define EXPECT_SIZE_EQ(expected, actual)

SimpleDevToolsProtocolClient;

ElementsAre;
NotNull;
UnorderedElementsAre;

namespace headless {

class HeadlessDevToolsClientNavigationTest
    : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientNavigationTest);

class HeadlessDevToolsClientWindowManagementTest
    : public HeadlessDevTooledBrowserTest {};

class HeadlessDevToolsClientChangeWindowBoundsTest
    : public HeadlessDevToolsClientWindowManagementTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientChangeWindowBoundsTest);

class HeadlessDevToolsClientOuterSizeTest
    : public HeadlessDevToolsClientWindowManagementTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientOuterSizeTest);

class HeadlessDevToolsClientChangeWindowStateTest
    : public HeadlessDevToolsClientWindowManagementTest {};

class HeadlessDevToolsClientMinimizeWindowTest
    : public HeadlessDevToolsClientChangeWindowStateTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientMinimizeWindowTest);

class HeadlessDevToolsClientMaximizeWindowTest
    : public HeadlessDevToolsClientChangeWindowStateTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientMaximizeWindowTest);

class HeadlessDevToolsClientFullscreenWindowTest
    : public HeadlessDevToolsClientChangeWindowStateTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientFullscreenWindowTest);

class HeadlessDevToolsClientEvalTest : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsClientEvalTest);

class HeadlessDevToolsNavigationControlTest
    : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsNavigationControlTest);

class HeadlessCrashObserverTest : public HeadlessDevTooledBrowserTest {};

// TODO(crbug.com/40206073): HeadlessCrashObserverTest.RunAsyncTest is flaky on
// Win debug.
#if BUILDFLAG(IS_WIN) && !defined(NDEBUG)
DISABLED_HEADLESS_DEVTOOLED_TEST_F(HeadlessCrashObserverTest);
#else
HEADLESS_DEVTOOLED_TEST_F(HeadlessCrashObserverTest);
#endif

class HeadlessDevToolsNetworkBlockedUrlTest
    : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(HeadlessDevToolsNetworkBlockedUrlTest);

class DevToolsNetworkOfflineEmulationTest
    : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(DevToolsNetworkOfflineEmulationTest);

class DomTreeExtractionBrowserTest : public HeadlessDevTooledBrowserTest {};

// TODO(crbug.com/40697467): Fix this test on Fuchsia and re-enable.
// NOTE: These macros expand to: DomTreeExtractionBrowserTest.RunAsyncTest
#if BUILDFLAG(IS_FUCHSIA)
DISABLED_HEADLESS_DEVTOOLED_TEST_F(DomTreeExtractionBrowserTest);
#else
HEADLESS_DEVTOOLED_TEST_F(DomTreeExtractionBrowserTest);
#endif

class BlockedByClient_NetworkObserver_Test
    : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(BlockedByClient_NetworkObserver_Test);

class DevtoolsInterceptionWithAuthProxyTest
    : public HeadlessDevTooledBrowserTest {};

#if BUILDFLAG(IS_FUCHSIA)
// TODO(crbug.com/40697469): Reenable on Fuchsia when fixed.
// NOTE: This macro expands to:
//   DevtoolsInterceptionWithAuthProxyTest.RunAsyncTest
DISABLED_HEADLESS_DEVTOOLED_TEST_F(DevtoolsInterceptionWithAuthProxyTest);
#else
HEADLESS_DEVTOOLED_TEST_F(DevtoolsInterceptionWithAuthProxyTest);
#endif

class NavigatorLanguages : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(NavigatorLanguages);

class AcceptLanguagesSwitch : public HeadlessDevTooledBrowserTest {};

HEADLESS_DEVTOOLED_TEST_F(AcceptLanguagesSwitch);

}  // namespace headless