#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <memory>
#include <string>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/permissions/permission_request_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_base.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/prerender_test_util.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "third_party/blink/public/common/features.h"
#include "ui/gl/gl_switches.h"
#if !BUILDFLAG(IS_CHROMEOS_LACROS)
namespace {
WebContents;
SubCaptureTargetType;
Bool;
Combine;
TestParamInfo;
Values;
WithParamInterface;
MATCHER_P(IsExpectedTarget, expected_target_index, "") { … }
const char kMainPageTitle[] = …;
const char kOtherPageTitle[] = …;
constexpr size_t kMaxIdsPerWebContents = …;
enum { … };
enum Tab { … };
enum class Frame { … };
enum class Track { … };
const char* ToString(Frame frame) { … }
const char* ToString(Track track) { … }
const char* ToString(SubCaptureTargetType type) { … }
struct TabInfo { … };
}
class SubCaptureBrowserTestBase : public WebRtcTestBase { … };
class SubCaptureBrowserTargetElementTest
: public SubCaptureBrowserTestBase,
public WithParamInterface<std::tuple<SubCaptureTargetType, const char*>> { … };
std::string SubCaptureBrowserTargetElementTestParamsToString(
const TestParamInfo<SubCaptureBrowserTargetElementTest::ParamType>& info) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTargetElementTest, ApplyToElement) { … }
class SubCaptureBrowserTest : public SubCaptureBrowserTestBase,
public WithParamInterface<SubCaptureTargetType> { … };
std::string SubCaptureBrowserTestParamsToString(
const TestParamInfo<SubCaptureBrowserTest::ParamType>& info) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest,
FromElementReturnsValidIdInMainPage) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest,
FromElementReturnsValidIdInCrossOriginIframe) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest,
SubCaptureAllowedIfTopLevelAppliesToElementInTopLevel) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest,
SubCaptureAllowedIfTopLevelAppliesToElementInEmbedded) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureBrowserTest,
SubCaptureAllowedIfEmbeddedFrameAppliesToElementInTopLevel) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureBrowserTest,
SubCaptureAllowedIfEmbeddedFrameAppliesToElementInEmbedded) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest, SubCaptureAllowedToUndo) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureBrowserTest,
MayAttemptToUndoSubCaptureOnTracksWhereSubCaptureHasNotBeenApplied) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest,
SubCaptureOfInvisibleElementResolvesInTimelyFashion) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest, MaxIdsInTopLevelDocument) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest, MaxIdsInEmbeddedFrame) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureBrowserTest, MaxIdsSharedBetweenFramesInTab) { … }
class SubCaptureClonesBrowserTestBase : public SubCaptureBrowserTestBase { … };
class SubCaptureClonesBrowserTest
: public SubCaptureClonesBrowserTestBase,
public WithParamInterface<SubCaptureTargetType> { … };
std::string SubCaptureClonesBrowserTestParamsToString(
const TestParamInfo<SubCaptureClonesBrowserTest::ParamType>& info) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CanCloneTracksWhichHadNoSubCaptureApplied) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CanCloneTrackWhichHaveSubCaptureApplied) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CannotApplySubCaptureOnClones) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CannotReapplySubCaptureOnClones) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CannotUndoSubCaptureOnClones) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CannotApplySubCaptureOnTracksThatHaveClones) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CannotReapplySubCaptureOnTracksThatHaveClones) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureClonesBrowserTest,
CannotUndoSubCaptureOnTracksThatHaveClones) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureClonesBrowserTest,
DISABLED_CanApplySubCaptureOnOriginalTrackAfterCloneIsGarbageCollected) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureClonesBrowserTest,
DISABLED_CanReapplySubCaptureOnOriginalTrackAfterCloneIsGarbageCollected) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureClonesBrowserTest,
DISABLED_CanUndoSubCaptureOnOriginalTrackAfterCloneIsGarbageCollected) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureClonesBrowserTest,
DISABLED_CanApplySubCaptureOnCloneAfterOriginalTrackIsGarbageCollected) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureClonesBrowserTest,
DISABLED_CanReapplySubCaptureOnCloneAfterOriginalTrackIsGarbageCollected) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureClonesBrowserTest,
DISABLED_CanUndoSubCaptureOnCloneAfterOriginalTrackIsGarbageCollected) { … }
class SubCaptureMultiCaptureBrowserTest
: public SubCaptureClonesBrowserTestBase,
public WithParamInterface<std::tuple<SubCaptureTargetType, Frame>> { … };
std::string SubCaptureMultiCaptureBrowserTestParamsToString(
const TestParamInfo<SubCaptureMultiCaptureBrowserTest::ParamType>& info) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(SubCaptureMultiCaptureBrowserTest,
CanSelfCaptureAgainIfNeverAppliedSubCapture) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureMultiCaptureBrowserTest,
CannotSelfCaptureAgainIfAppliedSubCapture) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureMultiCaptureBrowserTest,
CannotSelfCaptureAgainIfSubCapturedAppliedAndUnapplied) { … }
IN_PROC_BROWSER_TEST_P(SubCaptureMultiCaptureBrowserTest,
CanSelfCaptureAgainIfSubCaptureSessionStopped) { … }
IN_PROC_BROWSER_TEST_P(
SubCaptureMultiCaptureBrowserTest,
CannotApplySubCaptureIfMultipleSelfCaptureSessionsExist) { … }
class SubCaptureSelfCaptureOnlyBrowserTest
: public SubCaptureBrowserTestBase,
public WithParamInterface<
std::tuple<SubCaptureTargetType, Frame, bool, Tab, Frame>> { … };
std::string SubCaptureSelfCaptureOnlyBrowserTestParamsToString(
const TestParamInfo<SubCaptureSelfCaptureOnlyBrowserTest::ParamType>&
info) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(SubCaptureSelfCaptureOnlyBrowserTest, ApplySubCapture) { … }
#endif