#include "third_party/blink/renderer/modules/mediastream/user_media_client.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "media/audio/audio_device_description.h"
#include "media/capture/mojom/video_capture_types.mojom-blink.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/mediastream/media_device_id.h"
#include "third_party/blink/public/common/mediastream/media_devices.h"
#include "third_party/blink/public/mojom/media/capture_handle_config.mojom-blink.h"
#include "third_party/blink/public/mojom/mediastream/media_devices.mojom-blink.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom-blink.h"
#include "third_party/blink/public/platform/modules/mediastream/web_media_stream_source.h"
#include "third_party/blink/public/platform/modules/mediastream/web_media_stream_track.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/modules/mediastream/web_media_stream_device_observer.h"
#include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util_video_content.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_track_impl.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/renderer/modules/mediastream/mock_constraint_factory.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_video_source.h"
#include "third_party/blink/renderer/modules/mediastream/mock_mojo_media_stream_dispatcher_host.h"
#include "third_party/blink/renderer/modules/mediastream/user_media_request.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_source.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_track.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_descriptor.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_track_platform.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "ui/display/screen_info.h"
SubCaptureTargetType;
_;
Mock;
namespace blink {
EchoCancellationType;
namespace {
MediaConstraints CreateDefaultConstraints() { … }
MediaConstraints CreateDeviceConstraints(
const String& basic_exact_value,
const String& basic_ideal_value = g_empty_string,
const String& advanced_exact_value = g_empty_string) { … }
MediaConstraints CreateFacingModeConstraints(
const char* basic_exact_value,
const char* basic_ideal_value = nullptr,
const char* advanced_exact_value = nullptr) { … }
void CheckVideoSource(blink::MediaStreamVideoSource* source,
int expected_source_width,
int expected_source_height,
double expected_source_frame_rate) { … }
void CheckVideoSourceAndTrack(blink::MediaStreamVideoSource* source,
int expected_source_width,
int expected_source_height,
double expected_source_frame_rate,
MediaStreamComponent* component,
int expected_track_width,
int expected_track_height,
double expected_track_frame_rate) { … }
class MockLocalMediaStreamAudioSource : public blink::MediaStreamAudioSource { … };
class MockMediaStreamVideoCapturerSource
: public blink::MockMediaStreamVideoSource { … };
String MakeValidDeviceId(std::string_view id) { … }
class FakeDeviceIds { … };
class MediaDevicesDispatcherHostMock
: public mojom::blink::MediaDevicesDispatcherHost { … };
class MockMediaDevicesDispatcherHost
: public mojom::blink::MediaDevicesDispatcherHost { … };
enum RequestState { … };
class UserMediaProcessorUnderTest : public UserMediaProcessor { … };
class UserMediaClientUnderTest : public UserMediaClient { … };
class UserMediaChromeClient : public EmptyChromeClient { … };
}
class UserMediaClientTest : public ::testing::Test { … };
TEST_F(UserMediaClientTest, GenerateMediaStream) { … }
TEST_F(UserMediaClientTest, GenerateTwoMediaStreamsWithSameSource) { … }
TEST_F(UserMediaClientTest, GenerateTwoMediaStreamsWithDifferentSources) { … }
TEST_F(UserMediaClientTest, StopLocalTracks) { … }
TEST_F(UserMediaClientTest, StopLocalTracksWhenTwoStreamUseSameDevices) { … }
TEST_F(UserMediaClientTest, StopSourceWhenMediaStreamGoesOutOfScope) { … }
TEST_F(UserMediaClientTest, LoadNewDocumentInFrame) { … }
TEST_F(UserMediaClientTest, MediaVideoSourceFailToStart) { … }
TEST_F(UserMediaClientTest, MediaAudioSourceFailToInitialize) { … }
TEST_F(UserMediaClientTest, MediaStreamImplShutDown) { … }
TEST_F(UserMediaClientTest, ReloadFrameWhileGeneratingStream) { … }
TEST_F(UserMediaClientTest, ReloadFrameWhileGeneratingSources) { … }
TEST_F(UserMediaClientTest, StopTrackAfterReload) { … }
TEST_F(UserMediaClientTest, DefaultConstraintsPropagate) { … }
TEST_F(UserMediaClientTest, DefaultTabCapturePropagate) { … }
TEST_F(UserMediaClientTest, DefaultDesktopCapturePropagate) { … }
TEST_F(UserMediaClientTest, NonDefaultAudioConstraintsPropagate) { … }
TEST_F(UserMediaClientTest, CreateWithMandatoryInvalidAudioDeviceId) { … }
TEST_F(UserMediaClientTest, CreateWithMandatoryInvalidVideoDeviceId) { … }
TEST_F(UserMediaClientTest, CreateWithMandatoryValidDeviceIds) { … }
TEST_F(UserMediaClientTest, CreateWithBasicIdealValidDeviceId) { … }
TEST_F(UserMediaClientTest, CreateWithAdvancedExactValidDeviceId) { … }
TEST_F(UserMediaClientTest, CreateWithAllOptionalInvalidDeviceId) { … }
TEST_F(UserMediaClientTest, CreateWithFacingModeUser) { … }
TEST_F(UserMediaClientTest, CreateWithFacingModeEnvironment) { … }
TEST_F(UserMediaClientTest, ApplyConstraintsVideoDeviceSingleTrack) { … }
TEST_F(UserMediaClientTest, ApplyConstraintsVideoDeviceTwoTracks) { … }
TEST_F(UserMediaClientTest, ApplyConstraintsVideoDeviceFailsToStopForRestart) { … }
TEST_F(UserMediaClientTest,
ApplyConstraintsVideoDeviceFailsToRestartAfterStop) { … }
TEST_F(UserMediaClientTest, ApplyConstraintsVideoDeviceStopped) { … }
TEST_F(UserMediaClientTest,
RenderToAssociatedSinkTrueAssociatedOutputDeviceId) { … }
TEST_F(UserMediaClientTest,
RenderToAssociatedSinkFalseAssociatedOutputDeviceId) { … }
TEST_F(UserMediaClientTest, IsCapturing) { … }
TEST_F(UserMediaClientTest, DesktopCaptureChangeSource) { … }
TEST_F(UserMediaClientTest, DesktopCaptureChangeSourceWithoutAudio) { … }
TEST_F(UserMediaClientTest, PanConstraintRequestPanTiltZoomPermission) { … }
TEST_F(UserMediaClientTest, TiltConstraintRequestPanTiltZoomPermission) { … }
TEST_F(UserMediaClientTest, ZoomConstraintRequestPanTiltZoomPermission) { … }
TEST_F(UserMediaClientTest, MultiDeviceOnStreamsGenerated) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_FUCHSIA)
class UserMediaClientDeferredDeviceSelectionTest : public UserMediaClientTest { … };
TEST_F(UserMediaClientDeferredDeviceSelectionTest, GenerateMediaStream) { … }
TEST_F(UserMediaClientDeferredDeviceSelectionTest,
CreateWithMandatoryInvalidAudioDeviceId) { … }
TEST_F(UserMediaClientDeferredDeviceSelectionTest,
CreateWithMandatoryInvalidVideoDeviceId) { … }
TEST_F(UserMediaClientDeferredDeviceSelectionTest,
CreateWithMandatoryValidDeviceIds) { … }
#endif
}