#include "chrome/browser/media/router/mojo/media_router_desktop.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "base/base64.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/string_escape.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h"
#include "chrome/browser/media/router/test/media_router_mojo_test.h"
#include "chrome/browser/media/router/test/provider_test_helpers.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/media_router/browser/presentation_connection_message_observer.h"
#include "components/media_router/browser/route_message_util.h"
#include "components/media_router/browser/test/mock_media_router.h"
#include "components/media_router/common/issue.h"
#include "components/media_router/common/media_route.h"
#include "components/media_router/common/media_source.h"
#include "components/media_router/common/test/test_helper.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
PresentationConnectionCloseReason;
PresentationConnectionState;
RouteMessagePtr;
_;
Eq;
Invoke;
InvokeWithoutArgs;
IsEmpty;
Mock;
NiceMock;
Not;
Return;
SaveArg;
Sequence;
SizeIs;
StrictMock;
UnorderedElementsAre;
WithArg;
namespace media_router {
namespace {
const char kDescription[] = …;
const char kError[] = …;
const char kSource[] = …;
const char kSource2[] = …;
const char kTabSourceOne[] = …;
const char kTabSourceTwo[] = …;
const char kRouteId[] = …;
const char kRouteId2[] = …;
const char kSinkId[] = …;
const char kSinkId2[] = …;
const char kSinkName[] = …;
const char kPresentationId[] = …;
const char kOrigin[] = …;
const int kInvalidFrameNodeId = …;
const int kTimeoutMillis = …;
IssueInfo CreateIssueInfo(const std::string& title) { … }
MediaRoute CreateMediaRoute() { … }
MediaRoute CreateMediaRoute2() { … }
std::string RouteMessageToString(const RouteMessagePtr& message) { … }
std::vector<MediaSinkInternal> ToInternalSinks(
const std::vector<MediaSink>& sinks) { … }
class StubMediaRouterDesktop : public MediaRouterDesktop { … };
}
class MediaRouterDesktopTest : public MediaRouterMojoTest { … };
TEST_F(MediaRouterDesktopTest, CreateRoute) { … }
TEST_F(MediaRouterDesktopTest, RouteRecognizedAfterCreation) { … }
TEST_F(MediaRouterDesktopTest, CreateRouteFails) { … }
TEST_F(MediaRouterDesktopTest, JoinRoute) { … }
TEST_F(MediaRouterDesktopTest, JoinRouteNotFoundFails) { … }
TEST_F(MediaRouterDesktopTest, JoinRouteTimedOutFails) { … }
TEST_F(MediaRouterDesktopTest, DetachRoute) { … }
TEST_F(MediaRouterDesktopTest, TerminateRoute) { … }
TEST_F(MediaRouterDesktopTest, TerminateRouteFails) { … }
#if !BUILDFLAG(IS_ANDROID)
TEST_F(MediaRouterDesktopTest, HandleIssue) { … }
TEST_F(MediaRouterDesktopTest, HandlePermissionIssue) { … }
#endif
TEST_F(MediaRouterDesktopTest, RegisterAndUnregisterMediaSinksObserver) { … }
TEST_F(MediaRouterDesktopTest, TabSinksObserverIsShared) { … }
TEST_F(MediaRouterDesktopTest, RegisterAndUnregisterMediaRoutesObserver) { … }
TEST_F(MediaRouterDesktopTest, UnregisterBeforeNotificationDoesntCrash) { … }
TEST_F(MediaRouterDesktopTest, RegisteredObserversGetMediaRouteUpdates) { … }
TEST_F(MediaRouterDesktopTest, SendRouteMessage) { … }
TEST_F(MediaRouterDesktopTest, SendRouteBinaryMessage) { … }
namespace {
void PopulateRouteMessages(std::vector<RouteMessagePtr>* batch1,
std::vector<RouteMessagePtr>* batch2,
std::vector<RouteMessagePtr>* batch3,
std::vector<RouteMessagePtr>* all_messages) { … }
class ExpectedMessagesObserver final
: public PresentationConnectionMessageObserver { … };
}
TEST_F(MediaRouterDesktopTest, RouteMessagesSingleObserver) { … }
TEST_F(MediaRouterDesktopTest, RouteMessagesMultipleObservers) { … }
TEST_F(MediaRouterDesktopTest, PresentationConnectionStateChangedCallback) { … }
TEST_F(MediaRouterDesktopTest,
PresentationConnectionStateChangedCallbackRemoved) { … }
TEST_F(MediaRouterDesktopTest, GetMediaController) { … }
TEST_F(MediaRouterDesktopTest, SendSinkRequestsToMultipleProviders) { … }
TEST_F(MediaRouterDesktopTest, SendRouteRequestsToMultipleProviders) { … }
TEST_F(MediaRouterDesktopTest, ObserveSinksFromMultipleProviders) { … }
TEST_F(MediaRouterDesktopTest, ObserveRoutesFromMultipleProviders) { … }
TEST_F(MediaRouterDesktopTest, TestRecordPresentationRequestUrlBySink) { … }
TEST_F(MediaRouterDesktopTest, TestGetCurrentRoutes) { … }
TEST_F(MediaRouterDesktopTest, GetMirroringMediaControllerHost) { … }
TEST_F(MediaRouterDesktopTest, OnUserGesture) { … }
}