chromium/content/browser/webrtc/webrtc_media_recorder_browsertest.cc

// Copyright 2015 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 "base/strings/stringprintf.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/public/test/content_browser_test_utils.h"
#include "media/base/media_switches.h"

namespace {

static const char kMediaRecorderHtmlFile[] =;

static struct EncodingParameters {} const kEncodingParameters[] =;

static const EncodingParameters kProprietaryEncodingParameters[] =;

}  // namespace

namespace content {

// This class tests the recording of a media stream.
class WebRtcMediaRecorderTest
    : public WebRtcContentBrowserTestBase,
      public testing::WithParamInterface<struct EncodingParameters> {};

// TODO(crbug/361123384): Re-enable.
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Start
#else
#define MAYBE_Start
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_Start) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, StartAndStop) {}

#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// https://crbug.com/1222675
#define MAYBE_StartAndDataAvailable
#else
#define MAYBE_StartAndDataAvailable
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_StartAndDataAvailable) {}

// TODO(crbug.com/40559669): It seems to be flaky on Android. More details in
// the bug.
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_StartWithTimeSlice
#else
#define MAYBE_StartWithTimeSlice
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_StartWithTimeSlice) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, Resume) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, NoResumeWhenRecorderInactive) {}

// TODO(crbug.com/40903193): Seems the test is not working quite well on
// android-12l-x64-dbg-tests.
#if (BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)) || BUILDFLAG(IS_ANDROID)
// https://crbug.com/1222675
#define MAYBE_ResumeAndDataAvailable
#else
#define MAYBE_ResumeAndDataAvailable
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_ResumeAndDataAvailable) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, Pause) {}

// TODO(crbug.com/40450139): Flaky on TSAN bots.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_PauseStop
#else
#define MAYBE_PauseStop
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_PauseStop) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       PausePreventsDataavailableFromBeingFired) {}

// TODO (crbug.com/736268): Flaky on Linux TSan bots.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_IllegalPauseThrowsDOMError
#else
#define MAYBE_IllegalPauseThrowsDOMError
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       MAYBE_IllegalPauseThrowsDOMError) {}

#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// https://crbug.com/1222675
#define MAYBE_TwoChannelAudioRecording
#else
#define MAYBE_TwoChannelAudioRecording
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       MAYBE_TwoChannelAudioRecording) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, RecordWithTransparency) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       IllegalStartWhileRecordingThrowsDOMError) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       IllegalStartWhilePausedThrowsDOMError) {}

// Flaky on Linux Tsan (crbug.com/736268)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_IllegalRequestDataThrowsDOMError
#else
#define MAYBE_IllegalRequestDataThrowsDOMError
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       MAYBE_IllegalRequestDataThrowsDOMError) {}

#if BUILDFLAG(IS_ANDROID)
// These tests are flakily timing out on emulators (https://crbug.com/716691)
// and/or under Android ASAN (https://crbug.com/693565);
#define MAYBE_PeerConnection
#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
    defined(THREAD_SANITIZER)
// Flaky on Linux TSan, https://crbug.com/694373.
#define MAYBE_PeerConnection
#elif BUILDFLAG(IS_WIN) && !defined(NDEBUG)
// Fails on Win7 debug, https://crbug.com/703844.
#define MAYBE_PeerConnection
#elif BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// Fails on Mac/Arm, https://crbug.com/1222675
#define MAYBE_PeerConnection
#elif BUILDFLAG(IS_FUCHSIA) && defined(ARCH_CPU_X86_64)
// Flaky on Fuchsia-x64, https://crbug.com/1408820
#define MAYBE_PeerConnection
#else
#define MAYBE_PeerConnection
#endif

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_PeerConnection) {}

// Flaky on Linux Tsan (crbug.com/736268)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_AddingTrackToMediaStreamFiresErrorEvent
#elif BUILDFLAG(IS_ANDROID)
// Flaky on Android (crbug.com/1174634).
#define MAYBE_AddingTrackToMediaStreamFiresErrorEvent
#else
#define MAYBE_AddingTrackToMediaStreamFiresErrorEvent
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       MAYBE_AddingTrackToMediaStreamFiresErrorEvent) {}

IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
                       RemovingTrackFromMediaStreamFiresErrorEvent) {}

INSTANTIATE_TEST_SUITE_P();

#if BUILDFLAG(USE_PROPRIETARY_CODECS)

INSTANTIATE_TEST_SUITE_P(ProprietaryCodec,
                         WebRtcMediaRecorderTest,
                         testing::ValuesIn(kProprietaryEncodingParameters));

#endif  // BUILDFLAG(USE_PROPRIETARY_CODECS)

}  // namespace content