#include "chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.h"
#include <string>
#include <utility>
#include <vector>
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/simple_test_clock.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/timer/mock_timer.h"
#include "chrome/browser/media/router/discovery/mdns/media_sink_util.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/media/router/test/provider_test_helpers.h"
#include "components/media_router/common/providers/cast/channel/cast_socket.h"
#include "components/media_router/common/providers/cast/channel/cast_socket_service.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/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
Bucket;
ChannelError;
_;
ElementsAre;
Return;
SaveArg;
WithArgs;
MockBoolCallback;
namespace media_router {
namespace {
const char kPubliclyRoutableIPv4Address[] = …;
MATCHER_P(RetryParamEq, expected, "") { … }
MATCHER_P(OpenParamEq, expected, "") { … }
class MockObserver : public MediaSinkServiceBase::Observer { … };
}
class CastMediaSinkServiceImplTest : public ::testing::TestWithParam<bool> { … };
const std::vector<DiscoveryNetworkInfo>
CastMediaSinkServiceImplTest::fake_ethernet_info_ = …;
const std::vector<DiscoveryNetworkInfo>
CastMediaSinkServiceImplTest::fake_wifi_info_ = …;
const std::vector<DiscoveryNetworkInfo>
CastMediaSinkServiceImplTest::fake_unknown_info_ = …;
std::vector<DiscoveryNetworkInfo>
CastMediaSinkServiceImplTest::fake_network_info_ = …;
TEST_P(CastMediaSinkServiceImplTest, TestOnChannelOpenSucceeded) { … }
TEST_P(CastMediaSinkServiceImplTest, TestMultipleOnChannelOpenSucceeded) { … }
TEST_P(CastMediaSinkServiceImplTest, TestTimer) { … }
TEST_P(CastMediaSinkServiceImplTest, TestOpenChannelNoRetry) { … }
TEST_P(CastMediaSinkServiceImplTest, TestOpenChannelRetryOnce) { … }
TEST_P(CastMediaSinkServiceImplTest, TestOpenChannelFails) { … }
TEST_P(CastMediaSinkServiceImplTest, TestMultipleOpenChannels) { … }
TEST_P(CastMediaSinkServiceImplTest, OpenChannelNewIPSameSink) { … }
TEST_P(CastMediaSinkServiceImplTest, OpenChannelUpdatedSinkSameIP) { … }
TEST_P(CastMediaSinkServiceImplTest, TestOnChannelOpenFailed) { … }
TEST_P(CastMediaSinkServiceImplTest, TestSuccessOnChannelErrorRetry) { … }
TEST_P(CastMediaSinkServiceImplTest, TestFailureOnChannelErrorRetry) { … }
TEST_P(CastMediaSinkServiceImplTest,
TestOnChannelErrorMayRetryForConnectingChannel) { … }
TEST_P(CastMediaSinkServiceImplTest, TestOnChannelErrorNoRetryForMissingSink) { … }
TEST_P(CastMediaSinkServiceImplTest, TestOnSinkAddedOrUpdated) { … }
TEST_P(CastMediaSinkServiceImplTest,
TestOnSinkAddedOrUpdatedSkipsIfNonCastDevice) { … }
TEST_P(CastMediaSinkServiceImplTest, IgnoreDialSinkIfSameIdAsCast) { … }
TEST_P(CastMediaSinkServiceImplTest, IgnoreDialSinkIfSameIpAddressAsCast) { … }
TEST_P(CastMediaSinkServiceImplTest, OpenChannelsNow) { … }
TEST_P(CastMediaSinkServiceImplTest, CacheSinksForKnownNetwork) { … }
TEST_P(CastMediaSinkServiceImplTest, CacheContainsOnlyResolvedSinks) { … }
TEST_P(CastMediaSinkServiceImplTest, CacheUpdatedOnChannelOpenFailed) { … }
TEST_P(CastMediaSinkServiceImplTest, UnknownNetworkNoCache) { … }
TEST_P(CastMediaSinkServiceImplTest, CacheUpdatedForKnownNetwork) { … }
TEST_P(CastMediaSinkServiceImplTest, CacheDialDiscoveredSinks) { … }
TEST_P(CastMediaSinkServiceImplTest, DualDiscoveryDoesntDuplicateCacheItems) { … }
TEST_P(CastMediaSinkServiceImplTest, CacheSinksForDirectNetworkChange) { … }
TEST_P(CastMediaSinkServiceImplTest, TestCreateCastSocketOpenParams) { … }
TEST_P(CastMediaSinkServiceImplTest, TestHasSink) { … }
TEST_P(CastMediaSinkServiceImplTest, TestDisconnectAndRemoveSink) { … }
TEST_P(CastMediaSinkServiceImplTest, TestAccessCodeSinkNotAddedToNetworkCache) { … }
TEST_P(CastMediaSinkServiceImplTest,
TestOpenChannelFailsForPubliclyRoutableIP) { … }
INSTANTIATE_TEST_SUITE_P(…);
}