#include "chrome/browser/media/router/discovery/access_code/access_code_cast_discovery_interface.h"
#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h"
#include "chrome/browser/media/router/discovery/access_code/access_code_test_util.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/endpoint_fetcher/endpoint_fetcher.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "content/public/test/browser_task_environment.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
MockDiscoveryDeviceCallback;
AccessCodeCastDiscoveryInterface;
MockEndpointFetcherCallback;
DiscoveryDevice;
AddSinkResultCode;
_;
Eq;
Invoke;
InvokeArgument;
Mock;
NiceMock;
Return;
namespace media_router {
namespace {
const char kMockPostData[] = …;
constexpr base::TimeDelta kMockTimeout = …;
const char kMockOAuthConsumerName[] = …;
const char kMockScope[] = …;
const char kMockEndpoint[] = …;
const char kHttpMethod[] = …;
const char kMockContentType[] = …;
const char kEmail[] = …;
const char kDefaultURL[] = …;
const char kMalformedResponse[] = …;
const char kEmptyResponse[] = …;
const char kExpectedResponse[] = …;
const char kEndpointResponseSuccess[] = …;
const char kEndpointResponseSuccessPartialData[] = …;
const char kEndpointResponseFieldsMissing[] = …;
const char kEndpointResponseWrongDataTypes[] = …;
const char kErrorResponseFmt[] = …;
}
MATCHER_P(DiscoveryDeviceProtoEquals, message, "") { … }
class AccessCodeCastDiscoveryInterfaceTest : public testing::Test { … };
TEST_F(AccessCodeCastDiscoveryInterfaceTest,
ServerResponseAuthenticationError) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, ServerError) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(AccessCodeCastDiscoveryInterfaceTest, SyncError) { … }
#endif
TEST_F(AccessCodeCastDiscoveryInterfaceTest, HttpErrorMapping) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, ServerResponseMalformedError) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, ServerResponseEmptyError) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, ServerResponseSucess) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest,
ServerResponseSucessWithPartialData) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, FieldsMissingInResponse) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, WrongDataTypesInResponse) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, CommandLineSwitch) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest,
HandleServerErrorProfileSyncError) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, HandleServerErrorAuthError) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest, HandleServerErrorServerError) { … }
TEST_F(AccessCodeCastDiscoveryInterfaceTest,
HandleServerErrorResponseMalformedError) { … }
}