#include "chrome/browser/media/router/providers/cast/cast_activity_manager.h"
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#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/strcat.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/media/router/providers/cast/cast_session_client.h"
#include "chrome/browser/media/router/providers/cast/mirroring_activity.h"
#include "chrome/browser/media/router/providers/cast/mock_app_activity.h"
#include "chrome/browser/media/router/providers/cast/mock_mirroring_activity.h"
#include "chrome/browser/media/router/providers/cast/test_util.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_source.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 "components/media_router/common/test/mock_logger.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 "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"
#include "third_party/openscreen/src/cast/common/public/cast_streaming_app_ids.h"
IsJson;
ParseJsonDict;
_;
AnyNumber;
ByRef;
ElementsAre;
Invoke;
IsEmpty;
NiceMock;
Not;
Return;
WithArg;
namespace media_router {
namespace {
constexpr int kChannelId = …;
constexpr int kChannelId2 = …;
constexpr char kClientId[] = …;
constexpr char kOrigin[] = …;
constexpr int kFrameTreeNodeId = …;
constexpr int kFrameTreeNodeId2 = …;
constexpr char kAppId1[] = …;
constexpr char kAppId2[] = …;
constexpr char kAppParams[] = …;
constexpr char kPresentationId[] = …;
constexpr char kPresentationId2[] = …;
constexpr char histogram[] = …;
std::string MakeSourceId(const std::string& app_id = kAppId1,
const std::string& app_params = "",
const std::string& client_id = kClientId) { … }
base::Value::Dict MakeReceiverStatus(const std::string& app_id,
bool update_display_name = false) { … }
class MockLaunchSessionCallback { … };
MockAppActivityCallback;
MockMirroringActivityCallback;
}
class CastActivityManagerTest : public testing::Test,
public CastActivityFactoryForTest { … };
TEST_F(CastActivityManagerTest, LaunchAppSession) { … }
TEST_F(CastActivityManagerTest, LaunchAppSessionWithAppParams) { … }
TEST_F(CastActivityManagerTest, LaunchSessionSuccessWhenUserAllowed) { … }
TEST_F(CastActivityManagerTest, LaunchMirroringSession) { … }
TEST_F(CastActivityManagerTest, LaunchMirroringSessionViaCastSdk) { … }
TEST_F(CastActivityManagerTest, LaunchSiteInitiatedMirroringSession) { … }
TEST_F(CastActivityManagerTest, MirroringSessionStopped) { … }
TEST_F(CastActivityManagerTest, LaunchSessionFails) { … }
TEST_F(CastActivityManagerTest, LaunchSessionFailsWhenUserNotAllowed) { … }
TEST_F(CastActivityManagerTest,
LaunchSessionFailsWhenNotificationsAreDisabledOnReceiver) { … }
TEST_F(CastActivityManagerTest, LaunchSessionFailsWhenSessionIsRemoved) { … }
TEST_F(CastActivityManagerTest, LaunchAppSessionFailsWithAppParams) { … }
TEST_F(CastActivityManagerTest, LaunchSessionTerminatesExistingSessionFromTab) { … }
TEST_F(CastActivityManagerTest, LaunchSessionTerminatesPendingLaunchFromTab) { … }
TEST_F(CastActivityManagerTest, AddRemoveNonLocalActivity) { … }
TEST_F(CastActivityManagerTest, UpdateNewlyCreatedSession) { … }
TEST_F(CastActivityManagerTest, UpdateNewlyCreatedMirroringSession) { … }
TEST_F(CastActivityManagerTest, OnSessionAddedOrUpdated) { … }
TEST_F(CastActivityManagerTest, TerminateSession) { … }
TEST_F(CastActivityManagerTest, TerminateSessionFails) { … }
TEST_F(CastActivityManagerTest, DestructorClosesLocalMirroringSession) { … }
TEST_F(CastActivityManagerTest, DestructorIgnoresNonlocalMirroringSession) { … }
TEST_F(CastActivityManagerTest, DestructorIgnoresAppSession) { … }
TEST_F(CastActivityManagerTest, TerminateSessionBeforeLaunchResponse) { … }
TEST_F(CastActivityManagerTest, AppMessageFromReceiver) { … }
TEST_F(CastActivityManagerTest, OnMediaStatusUpdated) { … }
TEST_F(CastActivityManagerTest, OnSourceChanged) { … }
TEST_F(CastActivityManagerTest, StartSessionAndRemoveExistingSessionOnSink) { … }
TEST_F(CastActivityManagerTest, FindMirroringActivityByRouteIdNonMirroring) { … }
TEST_F(CastActivityManagerTest, FindMirroringActivityByRouteId) { … }
TEST_F(CastActivityManagerTest, LaunchAccessCodeCastSavedDeviceSuccess) { … }
TEST_F(CastActivityManagerTest, LaunchAccessCodeCastSavedDeviceFailure) { … }
TEST_F(CastActivityManagerTest, LaunchAccessCodeCastInstantDeviceSuccess) { … }
TEST_F(CastActivityManagerTest, LaunchMdnsInstantDeviceSuccess) { … }
}