chromium/content/browser/media/fullscreen_video_detection_browsertest.cc

// Copyright 2020 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 <vector>
#include "build/build_config.h"

#include "base/path_service.h"
#include "content/browser/media/media_browsertest.h"
#include "content/browser/media/media_web_contents_observer.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"

namespace content {

namespace {

enum class FullscreenTestEvent {};

class FullscreenEventsRecorder : public WebContentsObserver {};

}  // namespace

class FullscreenDetectionTest : public ContentBrowserTest {};

// The most basic test possible and most obvious case of fullscreeness.
// A <video> itself goes fullscreen, and it's marked as effectively-fullscreen.
// Once the <video> exits fullscreen mode, it's not effectively-fullscreen
// any more.
IN_PROC_BROWSER_TEST_F(FullscreenDetectionTest, RegularVideoTagFullscreen) {}

// A <div>, containing a big <video>, goes fullscreen.
// This div effectively become the viewport.
// Since the <video> occupies most of the <div>, and thus most of the screen,
// it's marked as effectively-fullscreen.
// Once the <div> exits fullscreen mode, <video> is not effectively-fullscreen
// any more.
IN_PROC_BROWSER_TEST_F(FullscreenDetectionTest, EncompassingDivFullscreen) {}

// A <div>, containing a <video>, goes fullscreen.
// But the <video> occupies a small part of <div> (and viewport), and
// it is not enough to be counted as effectively-fullscreen.
IN_PROC_BROWSER_TEST_F(FullscreenDetectionTest, EncompassingDivNotFullscreen) {}

// A <div>, containing a <video>, goes fullscreen.
// The test changes size of the <video> relative to the viewport and observes
// how it gets and looses effectively-fullscreen status.
// This somewhat emulates YT scrolling in the fullscreen mode.
IN_PROC_BROWSER_TEST_F(FullscreenDetectionTest, VideoTagSizeChange) {}

// Test how attaching/detaching the <video> affects its fullscreen status.
IN_PROC_BROWSER_TEST_F(FullscreenDetectionTest, DetachAttachDuringFullscreen) {}

// The test changes visibility of the <video> and observes
// how it gets and loses effectively-fullscreen status.
// TODO(crbug.com/40857652): Re-enable this test
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID)
#define MAYBE_HideVideoTag
#else
#define MAYBE_HideVideoTag
#endif
IN_PROC_BROWSER_TEST_F(FullscreenDetectionTest, MAYBE_HideVideoTag) {}

}  // namespace content