#include "components/gcm_driver/gcm_account_mapper.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/test/simple_test_clock.h"
#include "base/time/time.h"
#include "components/gcm_driver/fake_gcm_driver.h"
#include "google_apis/gcm/engine/account_mapping.h"
#include "google_apis/gcm/engine/gcm_store.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gcm {
namespace {
const char kGCMAccountMapperSenderId[] = …;
const char kGCMAccountMapperSendTo[] = …;
const char kRegistrationId[] = …;
const char kEmbeddedAppIdKey[] = …;
const char kTestAppId[] = …;
const char kTestDataKey[] = …;
const char kTestDataValue[] = …;
const char kTestCollapseKey[] = …;
const char kTestSenderId[] = …;
AccountMapping MakeAccountMapping(const CoreAccountId& account_id,
AccountMapping::MappingStatus status,
const base::Time& status_change_timestamp,
const std::string& last_message_id) { … }
GCMClient::AccountTokenInfo MakeAccountTokenInfo(
const CoreAccountId& account_id) { … }
class CustomFakeGCMDriver : public FakeGCMDriver { … };
CustomFakeGCMDriver::CustomFakeGCMDriver()
: … { … }
CustomFakeGCMDriver::~CustomFakeGCMDriver() { … }
void CustomFakeGCMDriver::UpdateAccountMapping(
const AccountMapping& account_mapping) { … }
void CustomFakeGCMDriver::RemoveAccountMapping(
const CoreAccountId& account_id) { … }
void CustomFakeGCMDriver::RegisterImpl(
const std::string& app_id,
const std::vector<std::string>& sender_ids) { … }
void CustomFakeGCMDriver::CompleteRegister(const std::string& registration_id,
GCMClient::Result result) { … }
void CustomFakeGCMDriver::CompleteSend(const std::string& message_id,
GCMClient::Result result) { … }
void CustomFakeGCMDriver::AcknowledgeSend(const std::string& message_id) { … }
void CustomFakeGCMDriver::MessageSendError(const std::string& message_id) { … }
void CustomFakeGCMDriver::SendImpl(const std::string& app_id,
const std::string& receiver_id,
const OutgoingMessage& message) { … }
void CustomFakeGCMDriver::CompleteSendAllMessages() { … }
void CustomFakeGCMDriver::AcknowledgeSendAllMessages() { … }
void CustomFakeGCMDriver::Clear() { … }
void CustomFakeGCMDriver::SetLastMessageAction(const std::string& message_id,
LastMessageAction action) { … }
}
class GCMAccountMapperTest : public testing::Test { … };
GCMAccountMapperTest::GCMAccountMapperTest()
: … { … }
GCMAccountMapperTest::~GCMAccountMapperTest() { … }
void GCMAccountMapperTest::Restart() { … }
void GCMAccountMapperTest::Initialize(
const GCMAccountMapper::AccountMappings mappings) { … }
void GCMAccountMapperTest::MessageReceived(const std::string& app_id,
const IncomingMessage& message) { … }
TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) { … }
TEST_F(GCMAccountMapperTest, RegistrationRetryUponFailure) { … }
TEST_F(GCMAccountMapperTest, InitializeAccountMappings) { … }
TEST_F(GCMAccountMapperTest, SetAccountTokensOnlyWorksWithRegisterationId) { … }
TEST_F(GCMAccountMapperTest, AddMappingMessageSendErrorForMappedAccount) { … }
TEST_F(GCMAccountMapperTest, RemoveMappingMessageAckedAfterRestart) { … }
TEST_F(GCMAccountMapperTest, RemoveMappingMessageSendError) { … }
TEST_F(GCMAccountMapperTest, DispatchMessageSentToGaiaID) { … }
}