#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_tokenizer.h"
#include "base/task/single_thread_task_runner.h"
#include "google_apis/credentials_mode.h"
#include "google_apis/gcm/engine/gcm_registration_request_handler.h"
#include "google_apis/gcm/engine/gcm_request_test_base.h"
#include "google_apis/gcm/engine/instance_id_get_token_request_handler.h"
#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace gcm {
namespace {
const uint64_t kAndroidId = …;
const char kAppId[] = …;
const char kProductCategoryForSubtypes[] = …;
const char kDeveloperId[] = …;
const char kLoginHeader[] = …;
const char kRegistrationURL[] = …;
const uint64_t kSecurityToken = …;
const int kGCMVersion = …;
const char kInstanceId[] = …;
const char kScope[] = …;
}
class RegistrationRequestTest : public GCMRequestTestBase { … };
RegistrationRequestTest::RegistrationRequestTest()
: … { … }
RegistrationRequestTest::~RegistrationRequestTest() { … }
void RegistrationRequestTest::RegistrationCallback(
RegistrationRequest::Status status,
const std::string& registration_id) { … }
void RegistrationRequestTest::OnAboutToCompleteFetch() { … }
class GCMRegistrationRequestTest : public RegistrationRequestTest { … };
GCMRegistrationRequestTest::GCMRegistrationRequestTest() { … }
GCMRegistrationRequestTest::~GCMRegistrationRequestTest() { … }
void GCMRegistrationRequestTest::CreateRequest(const std::string& sender_ids) { … }
TEST_F(GCMRegistrationRequestTest, RequestSuccessful) { … }
TEST_F(GCMRegistrationRequestTest, RequestDataAndURL) { … }
TEST_F(GCMRegistrationRequestTest, RequestRegistrationWithMultipleSenderIds) { … }
TEST_F(GCMRegistrationRequestTest, ResponseParsing) { … }
TEST_F(GCMRegistrationRequestTest, ResponseParsingFailed) { … }
TEST_F(GCMRegistrationRequestTest, ResponseHttpStatusNotOK) { … }
TEST_F(GCMRegistrationRequestTest, ResponseMissingRegistrationId) { … }
TEST_F(GCMRegistrationRequestTest, ResponseDeviceRegistrationError) { … }
TEST_F(GCMRegistrationRequestTest, ResponseAuthenticationError) { … }
TEST_F(GCMRegistrationRequestTest, ResponseInternalServerError) { … }
TEST_F(GCMRegistrationRequestTest, ResponseInvalidParameters) { … }
TEST_F(GCMRegistrationRequestTest, ResponseInvalidSender) { … }
TEST_F(GCMRegistrationRequestTest, ResponseInvalidSenderBadRequest) { … }
TEST_F(GCMRegistrationRequestTest, ResponseQuotaExceeded) { … }
TEST_F(GCMRegistrationRequestTest, ResponseTooManyRegistrations) { … }
TEST_F(GCMRegistrationRequestTest, RequestNotSuccessful) { … }
TEST_F(GCMRegistrationRequestTest, ResponseHttpNotOk) { … }
TEST_F(GCMRegistrationRequestTest, MaximumAttemptsReachedWithZeroRetries) { … }
TEST_F(GCMRegistrationRequestTest, MaximumAttemptsReached) { … }
class InstanceIDGetTokenRequestTest : public RegistrationRequestTest { … };
InstanceIDGetTokenRequestTest::InstanceIDGetTokenRequestTest() { … }
InstanceIDGetTokenRequestTest::~InstanceIDGetTokenRequestTest() { … }
void InstanceIDGetTokenRequestTest::CreateRequest(
bool use_subtype,
const std::string& instance_id,
const std::string& authorized_entity,
const std::string& scope,
base::TimeDelta time_to_live) { … }
TEST_F(InstanceIDGetTokenRequestTest, RequestSuccessful) { … }
TEST_F(InstanceIDGetTokenRequestTest, RequestDataAndURL) { … }
TEST_F(InstanceIDGetTokenRequestTest, RequestDataWithTTL) { … }
TEST_F(InstanceIDGetTokenRequestTest, RequestDataWithSubtype) { … }
TEST_F(InstanceIDGetTokenRequestTest, ResponseHttpStatusNotOK) { … }
}