#include "components/media_router/common/providers/cast/channel/cast_message_handler.h"
#include <string>
#include <string_view>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/test/test_simple_task_runner.h"
#include "base/test/values_test_util.h"
#include "components/media_router/common/providers/cast/channel/cast_channel_enum.h"
#include "components/media_router/common/providers/cast/channel/cast_channel_metrics.h"
#include "components/media_router/common/providers/cast/channel/cast_message_util.h"
#include "components/media_router/common/providers/cast/channel/cast_test_util.h"
#include "content/public/test/browser_task_environment.h"
#include "services/data_decoder/public/cpp/data_decoder.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"
IsJson;
ParseJson;
ParseJsonDict;
_;
AnyNumber;
InSequence;
Return;
SaveArg;
WithArg;
namespace cast_channel {
namespace {
constexpr char kAppId1[] = …;
constexpr char kAppId2[] = …;
constexpr char kTestUserAgentString[] = …;
constexpr char kSessionId[] = …;
constexpr char kSourceId[] = …;
constexpr char kDestinationId[] = …;
constexpr char kAppParams[] = …;
constexpr int kMaxProtocolMessageSize = …;
data_decoder::DataDecoder::ValueOrError ParseJsonLikeDataDecoder(
std::string_view json) { … }
std::optional<base::Value::Dict> GetDictionaryFromCastMessage(
const CastMessage& message) { … }
CastMessageType GetMessageType(const CastMessage& message) { … }
MATCHER_P(HasMessageType, type, "") { … }
MATCHER_P(HasPayloadUtf8, payload, "") { … }
}
class CastMessageHandlerTest : public testing::Test { … };
TEST_F(CastMessageHandlerTest, VirtualConnectionCreatedOnlyOnce) { … }
TEST_F(CastMessageHandlerTest, RecreateVirtualConnectionAfterError) { … }
TEST_F(CastMessageHandlerTest, RequestAppAvailability) { … }
TEST_F(CastMessageHandlerTest, RequestAppAvailabilityTimesOut) { … }
TEST_F(CastMessageHandlerTest, AppAvailabilitySentOnlyOnceWhilePending) { … }
TEST_F(CastMessageHandlerTest, EnsureConnection) { … }
TEST_F(CastMessageHandlerTest, CloseConnection) { … }
TEST_F(CastMessageHandlerTest, CloseConnectionFromReceiver) { … }
TEST_F(CastMessageHandlerTest, RemoveConnection) { … }
TEST_F(CastMessageHandlerTest, LaunchSession) { … }
TEST_F(CastMessageHandlerTest, LaunchSessionTimedOut) { … }
TEST_F(CastMessageHandlerTest, LaunchSessionMessageExceedsSizeLimit) { … }
TEST_F(CastMessageHandlerTest, SendAppMessage) { … }
TEST_F(CastMessageHandlerTest, SendMessageOnInvisibleConnection) { … }
TEST_F(CastMessageHandlerTest, SendMessageToPlatformReceiver) { … }
TEST_F(CastMessageHandlerTest, SendAppMessageExceedsSizeLimit) { … }
TEST_F(CastMessageHandlerTest, SendMediaRequest) { … }
TEST_F(CastMessageHandlerTest, SendVolumeCommand) { … }
TEST_F(CastMessageHandlerTest, PendingRequestsDestructor) { … }
TEST_F(CastMessageHandlerTest, HandlePendingRequest) { … }
TEST_F(CastMessageHandlerTest, SetVolumeTimedOut) { … }
TEST_F(CastMessageHandlerTest, SendMultipleLaunchRequests) { … }
TEST_F(CastMessageHandlerTest, SendMultipleStopRequests) { … }
TEST_F(CastMessageHandlerTest, LaunchSessionWithPromptUserAllowed) { … }
TEST_F(CastMessageHandlerTest, LaunchSessionWithPromptUserNotAllowed) { … }
TEST_F(CastMessageHandlerTest,
LaunchSessionWithPromptUserNotificationDisabled) { … }
}