#include "chrome/browser/media/router/providers/test/test_media_route_provider.h"
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "components/media_router/common/media_source.h"
#include "components/media_router/common/mojom/media_router.mojom.h"
#include "components/media_router/common/route_request_result.h"
#include "components/media_router/common/test/test_helper.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media_router {
namespace {
const char kPresentationURL2UATestOrigin[] = …;
bool IsValidSource(const std::string& source_urn) { … }
bool Is1UAPresentationSource(const std::string& source_urn) { … }
}
const mojom::MediaRouteProviderId TestMediaRouteProvider::kProviderId = …;
TestMediaRouteProvider::TestMediaRouteProvider(
mojo::PendingReceiver<mojom::MediaRouteProvider> receiver,
mojo::PendingRemote<mojom::MediaRouter> media_router)
: … { … }
TestMediaRouteProvider::~TestMediaRouteProvider() = default;
void TestMediaRouteProvider::SetSinks() { … }
void TestMediaRouteProvider::CreateRoute(const std::string& media_source,
const std::string& sink_id,
const std::string& presentation_id,
const url::Origin& origin,
int32_t frame_tree_node_id,
base::TimeDelta timeout,
CreateRouteCallback callback) { … }
void TestMediaRouteProvider::CreateRouteTimeOut(CreateRouteCallback callback) { … }
void TestMediaRouteProvider::JoinRoute(const std::string& media_source,
const std::string& presentation_id,
const url::Origin& origin,
int32_t frame_tree_node_id,
base::TimeDelta timeout,
JoinRouteCallback callback) { … }
void TestMediaRouteProvider::TerminateRoute(const std::string& route_id,
TerminateRouteCallback callback) { … }
void TestMediaRouteProvider::SendRouteMessage(const std::string& media_route_id,
const std::string& message) { … }
void TestMediaRouteProvider::SendRouteBinaryMessage(
const std::string& media_route_id,
const std::vector<uint8_t>& data) { … }
void TestMediaRouteProvider::StartObservingMediaSinks(
const std::string& media_source) { … }
void TestMediaRouteProvider::StopObservingMediaSinks(
const std::string& media_source) { … }
void TestMediaRouteProvider::StartObservingMediaRoutes() { … }
void TestMediaRouteProvider::DetachRoute(const std::string& route_id) { … }
void TestMediaRouteProvider::EnableMdnsDiscovery() { … }
void TestMediaRouteProvider::DiscoverSinksNow() { … }
void TestMediaRouteProvider::BindMediaController(
const std::string& route_id,
mojo::PendingReceiver<mojom::MediaController> media_controller,
mojo::PendingRemote<mojom::MediaStatusObserver> observer,
BindMediaControllerCallback callback) { … }
void TestMediaRouteProvider::GetState(GetStateCallback callback) { … }
std::vector<MediaRoute> TestMediaRouteProvider::GetMediaRoutes() { … }
void TestMediaRouteProvider::CaptureOffScreenTab(
content::WebContents* web_contents,
GURL source_urn,
std::string& presentation_id) { … }
bool TestMediaRouteProvider::HasRoutes() const { … }
void TestMediaRouteProvider::TearDown() { … }
void TestMediaRouteProvider::DestroyTab(OffscreenTab* tab) { … }
}