#include "google_apis/gcm/engine/mcs_client.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "base/timer/timer.h"
#include "google_apis/gcm/base/fake_encryptor.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
#include "google_apis/gcm/engine/fake_connection_handler.h"
#include "google_apis/gcm/engine/gcm_store_impl.h"
#include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gcm {
namespace {
const uint64_t kAndroidId = …;
const uint64_t kSecurityToken = …;
const int kMessageBatchSize = …;
const int kAckLimitSize = …;
const int kTTLValue = …;
enum RequestImmediateAck { … };
MCSMessage BuildDataMessage(const std::string& from,
const std::string& category,
const std::string& message_id,
int last_stream_id_received,
const std::string& persistent_id,
int ttl,
uint64_t sent,
int queued,
const std::string& token,
const uint64_t& user_id,
RequestImmediateAck immediate_ack) { … }
class TestMCSClient : public MCSClient { … };
class TestConnectionListener : public ConnectionFactory::ConnectionListener { … };
class MCSClientTest : public testing::Test { … };
MCSClientTest::MCSClientTest()
: … { … }
MCSClientTest::~MCSClientTest() { … }
void MCSClientTest::SetUp() { … }
void MCSClientTest::TearDown() { … }
void MCSClientTest::BuildMCSClient() { … }
void MCSClientTest::InitializeClient() { … }
void MCSClientTest::LoginClient(
const std::vector<std::string>& acknowledged_ids) { … }
void MCSClientTest::LoginClientWithHeartbeat(
const std::vector<std::string>& acknowledged_ids,
int heartbeat_interval_ms) { … }
void MCSClientTest::AddExpectedLoginRequest(
const std::vector<std::string>& acknowledged_ids,
int heartbeat_interval_ms) { … }
void MCSClientTest::StoreCredentials() { … }
FakeConnectionHandler* MCSClientTest::GetFakeHandler() const { … }
void MCSClientTest::WaitForMCSEvent() { … }
void MCSClientTest::PumpLoop() { … }
void MCSClientTest::ErrorCallback() { … }
void MCSClientTest::MessageReceivedCallback(const MCSMessage& message) { … }
void MCSClientTest::MessageSentCallback(int64_t user_serial_number,
const std::string& app_id,
const std::string& message_id,
MCSClient::MessageSendStatus status) { … }
void MCSClientTest::SetDeviceCredentialsCallback(bool success) { … }
TEST_F(MCSClientTest, InitializeNew) { … }
TEST_F(MCSClientTest, InitializeExisting) { … }
TEST_F(MCSClientTest, LoginSuccess) { … }
TEST_F(MCSClientTest, FailLogin) { … }
TEST_F(MCSClientTest, SendMessageNoRMQ) { … }
TEST_F(MCSClientTest, SendMessageNoRMQWhileDisconnected) { … }
TEST_F(MCSClientTest, SendMessageRMQ) { … }
TEST_F(MCSClientTest, SendMessageRMQWhileDisconnected) { … }
TEST_F(MCSClientTest, SendMessageRMQOnRestart) { … }
TEST_F(MCSClientTest, SendMessageRMQWithStreamAck) { … }
TEST_F(MCSClientTest, SendMessageRMQAckOnReconnect) { … }
TEST_F(MCSClientTest, SendMessageRMQPartialAckOnReconnect) { … }
TEST_F(MCSClientTest, SelectiveAckMidStream) { … }
TEST_F(MCSClientTest, AckOnLogin) { … }
TEST_F(MCSClientTest, AckOnSend) { … }
TEST_F(MCSClientTest, AckWhenLimitReachedWithHeartbeat) { … }
TEST_F(MCSClientTest, ExpiredTTLOnSend) { … }
TEST_F(MCSClientTest, ExpiredTTLOnRestart) { … }
TEST_F(MCSClientTest, CollapseKeysSameApp) { … }
TEST_F(MCSClientTest, CollapseKeysDifferentApp) { … }
TEST_F(MCSClientTest, CollapseKeysDifferentUser) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalTooShort) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalTooLong) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalSingleInterval) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalSetBeforeInitialize) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalSetBeforeLogin) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalSecondIntervalLonger) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalSecondIntervalShorter) { … }
TEST_F(MCSClientTest, CustomHeartbeatIntervalRemoveShorterInterval) { … }
TEST_F(MCSClientTest, AckWhenImmediateAckRequested) { … }
}
}