chromium/content/browser/webrtc/webrtc_capture_from_element_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 "base/command_line.h"
#include "build/build_config.h"
#include "content/browser/webrtc/webrtc_content_browsertest_base.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/shell/common/shell_switches.h"
#include "media/base/media_switches.h"
#include "media/base/test_data_util.h"
#include "media/mojo/buildflags.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#include "base/system/sys_info.h"
#endif

#if BUILDFLAG(ENABLE_MOJO_RENDERER)
// Remote mojo renderer does not send audio/video frames back to the renderer
// process and hence does not support capture: https://crbug.com/641559.
#define MAYBE_CaptureFromMediaElement
#else
#define MAYBE_CaptureFromMediaElement
#endif

namespace {

static const char kCanvasCaptureTestHtmlFile[] =;
static const char kCanvasCaptureColorTestHtmlFile[] =;
static const char kVideoAudioHtmlFile[] =;

static struct FileAndTypeParameters {} const kFileAndTypeParameters[] =;

}  // namespace

namespace content {

// This class is the browser tests for Media Capture from DOM Elements API,
// which allows for creation of a MediaStream out of a <canvas>, <video> or
// <audio> element.
class WebRtcCaptureFromElementBrowserTest
    : public WebRtcContentBrowserTestBase,
      public testing::WithParamInterface<struct FileAndTypeParameters> {};

IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       VerifyCanvas2DCaptureColor) {}

#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_ARM64)
#define MAYBE_VerifyCanvasWebGLCaptureOpaqueColor
#else
#define MAYBE_VerifyCanvasWebGLCaptureOpaqueColor
#endif  // BUILDFLAG(IS_WIN) && defined(ARCH_CPU_ARM64)
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       MAYBE_VerifyCanvasWebGLCaptureOpaqueColor) {}

#if BUILDFLAG(IS_WIN) && defined(ARCH_CPU_ARM64)
#define MAYBE_VerifyCanvasWebGLCaptureAlphaColor
#else
#define MAYBE_VerifyCanvasWebGLCaptureAlphaColor
#endif  // BUILDFLAG(IS_WIN) && defined(ARCH_CPU_ARM64)
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       MAYBE_VerifyCanvasWebGLCaptureAlphaColor) {}

// TODO(crbug.com/40856408): Flaky.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID)
#define MAYBE_VerifyCanvasCapture2DFrames
#else
#define MAYBE_VerifyCanvasCapture2DFrames
#endif
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       MAYBE_VerifyCanvasCapture2DFrames) {}

// TODO(crbug.com/40846825): Flaky.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
#define MAYBE_VerifyCanvasCaptureWebGLFrames
#else
#define MAYBE_VerifyCanvasCaptureWebGLFrames
#endif
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       MAYBE_VerifyCanvasCaptureWebGLFrames) {}

// https://crbug.com/869723
// Flaky on Windows 10 with Viz (i.e. in viz_content_browsertests).
// https://crbug.com/989759
// Flaky on other platforms due to frame delivery for offscreen canvases.
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       DISABLED_VerifyCanvasCaptureOffscreenCanvasFrames) {}

// TODO(crbug.com/40846743): Fix and re-enable.
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       DISABLED_VerifyCanvasCaptureBitmapRendererFrames) {}

IN_PROC_BROWSER_TEST_P(WebRtcCaptureFromElementBrowserTest,
                       MAYBE_CaptureFromMediaElement) {}

// https://crbug.com/986020.
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       DISABLED_CaptureFromCanvas2DHandlesContextLoss) {}

// Not supported on android https://crbug.com/898286.
// Not supported on accelerated canvases https://crbug.com/954142.
IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
                       DISABLED_CaptureFromOpaqueCanvas2DHandlesContextLoss) {}

INSTANTIATE_TEST_SUITE_P();
}  // namespace content