#include "chrome/browser/media/router/providers/cast/cast_media_route_provider.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/test_simple_task_runner.h"
#include "chrome/browser/media/router/providers/cast/cast_activity_manager.h"
#include "chrome/browser/media/router/providers/cast/cast_session_tracker.h"
#include "chrome/browser/media/router/providers/cast/mock_mirroring_activity.h"
#include "chrome/browser/media/router/providers/cast/mock_mirroring_service_host.h"
#include "chrome/browser/media/router/test/mock_mojo_media_router.h"
#include "chrome/browser/media/router/test/provider_test_helpers.h"
#include "components/media_router/common/media_route.h"
#include "components/media_router/common/providers/cast/channel/cast_test_util.h"
#include "components/media_router/common/test/test_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
Mock;
NiceMock;
WithArg;
namespace media_router {
namespace {
static constexpr char kAppId[] = …;
constexpr char kCastSource[] = …;
static constexpr char kPresentationId[] = …;
static constexpr char kOrigin[] = …;
static constexpr int kFrameTreeNodeId = …;
static constexpr base::TimeDelta kRouteTimeout = …;
base::Value::Dict MakeReceiverStatus() { … }
MediaSinkInternal CreateCastSinkWithModelName(const std::string model_name) { … }
}
class CastMediaRouteProviderTest : public testing::Test { … };
TEST_F(CastMediaRouteProviderTest, StartObservingMediaSinks) { … }
TEST_F(CastMediaRouteProviderTest, CreateRouteFailsInvalidSink) { … }
TEST_F(CastMediaRouteProviderTest, CreateRouteFailsInvalidSource) { … }
TEST_F(CastMediaRouteProviderTest, CreateRoute) { … }
TEST_F(CastMediaRouteProviderTest, TerminateRoute) { … }
TEST_F(CastMediaRouteProviderTest, GetState) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
TEST_F(CastMediaRouteProviderTest, GetRemotePlaybackCompatibleSinks) { … }
#else
TEST_F(CastMediaRouteProviderTest, GetRemotePlaybackCompatibleSinks) {
EXPECT_CALL(mock_router_, OnSinksReceived(_, _, _, _)).Times(0);
provider_->OnSinkQueryUpdated(
"remote-playback:media-session?tab_id=1&video_codec=vp8&audio_codec=aac",
{CreateCastSinkWithModelName("Chromecast")});
base::RunLoop().RunUntilIdle();
Mock::VerifyAndClearExpectations(&mock_router_);
}
#endif
}