chromium/content/browser/renderer_host/media/media_devices_manager_unittest.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 "content/browser/renderer_host/media/media_devices_manager.h"

#include <memory>
#include <string>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/system/system_monitor.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "content/browser/media/media_devices_permission_checker.h"
#include "content/browser/renderer_host/media/mock_video_capture_provider.h"
#include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/test/test_web_contents.h"
#include "media/audio/audio_device_name.h"
#include "media/audio/audio_system_impl.h"
#include "media/audio/fake_audio_log_factory.h"
#include "media/audio/fake_audio_manager.h"
#include "media/audio/test_audio_thread.h"
#include "media/base/video_facing.h"
#include "media/base/video_types.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "media/capture/video/fake_video_capture_device_factory.h"
#include "media/capture/video/video_capture_device_descriptor.h"
#include "media/capture/video/video_capture_system_impl.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/media/capture_handle_config.mojom.h"
#include "third_party/blink/public/mojom/mediastream/media_devices.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"

HistogramTester;
MediaDeviceType;
DeviceEnumerationResult;
SubCaptureTargetType;
_;
Invoke;
SaveArg;

namespace content {

namespace {

const int kRenderProcessId =;
const int kRenderFrameId =;
const GlobalRenderFrameHostId kRenderFrameHostId{};

// Number of client enumerations to simulate on each test run.
// This allows testing that a single call to low-level enumeration functions
// is performed when cache is enabled, regardless of the number of client calls.
const int kNumCalls =;

const size_t kNumAudioInputDevices =;

const auto kIgnoreLogMessageCB =;

std::string salt =;
void GetSaltAndOrigin(GlobalRenderFrameHostId,
                      MediaDeviceSaltAndOriginCallback callback) {}

std::string GetAudioDeviceName(size_t suffix) {}

std::string GetAudioDeviceId(size_t suffix) {}

std::string GetVideoDeviceName(size_t suffix) {}

std::string GetVideoDeviceId(size_t suffix) {}

// This class mocks the audio manager and overrides some methods to ensure that
// we can run simulate device changes.
class MockAudioManager : public media::FakeAudioManager {};

// This class mocks the video capture device factory and overrides some methods
// to ensure that we can simulate device changes.
class MockVideoCaptureDeviceFactory
    : public media::FakeVideoCaptureDeviceFactory {};

class MockMediaDevicesListener : public blink::mojom::MediaDevicesListener {};

class MockMediaDevicesManagerClient {};

void VerifyDeviceAndGroupID(
    const std::vector<blink::WebMediaDeviceInfoArray>& array) {}

class MockMediaDevicesDispatcherHost
    : public blink::mojom::MediaDevicesDispatcherHost {};

class MockBrowserClient : public ContentBrowserClient {};

}  // namespace

class MediaDevicesManagerTest : public ::testing::Test {};

TEST_F(MediaDevicesManagerTest, EnumerateNoCacheAudioInput) {}

TEST_F(MediaDevicesManagerTest, EnumerateNoCacheVideoInput) {}

TEST_F(MediaDevicesManagerTest, EnumerateNoCacheAudioOutput) {}

TEST_F(MediaDevicesManagerTest, EnumerateNoCacheAudio) {}

TEST_F(MediaDevicesManagerTest, EnumerateNoCacheAudioInputRanked) {}

TEST_F(MediaDevicesManagerTest, EnumerateNoCacheVideoInputRanked) {}

TEST_F(MediaDevicesManagerTest, EnumerateCacheAudio) {}

TEST_F(MediaDevicesManagerTest, EnumerateCacheVideo) {}

TEST_F(MediaDevicesManagerTest, EnumerateCacheAudioWithDeviceChanges) {}

TEST_F(MediaDevicesManagerTest, EnumerateCacheVideoWithDeviceChanges) {}

TEST_F(MediaDevicesManagerTest, EnumerateCacheAllWithDeviceChanges) {}

TEST_F(MediaDevicesManagerTest, SubscribeDeviceChanges) {}

TEST_F(MediaDevicesManagerTest, EnumerateDevicesWithCapabilities) {}

TEST_F(MediaDevicesManagerTest, EnumerateDevicesUnplugDefaultDevice) {}

TEST_F(MediaDevicesManagerTest, EnumerateDevicesUnplugCommunicationsDevice) {}

TEST_F(MediaDevicesManagerTest,
       EnumerateDevicesUnplugDefaultAndCommunicationsDevice) {}

TEST_F(MediaDevicesManagerTest, GuessVideoGroupID) {}

TEST_F(MediaDevicesManagerTest, DeviceIdSaltReset) {}

TEST_F(MediaDevicesManagerTest, EnumerateVideoInputFailsOnce) {}

TEST_F(MediaDevicesManagerTest, RegisterUnregisterDispatcherHosts) {}

TEST_F(MediaDevicesManagerTest, DevicePropertyChanges) {}

}  // namespace content