#include "components/invalidation/impl/fcm_network_handler.h"
#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/invalidation/impl/invalidation_switches.h"
#include "components/invalidation/impl/status.h"
#include "google_apis/gcm/engine/account_mapping.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
TestMockTimeTaskRunner;
InstanceIDHandler;
InstanceID;
InstanceIDDriver;
_;
Eq;
Invoke;
StrictMock;
WithArg;
namespace invalidation {
namespace {
const char kInvalidationsAppId[] = …;
base::Time GetDummyNow() { … }
gcm::IncomingMessage CreateValidMessage() { … }
class MockInstanceID : public InstanceID { … };
class MockGCMDriver : public gcm::GCMDriver { … };
class MockInstanceIDDriver : public InstanceIDDriver { … };
class MockOnTokenCallback { … };
class MockOnMessageCallback { … };
}
class FCMNetworkHandlerTest : public testing::Test { … };
class FCMNetworkHandlerTestWithTTL : public FCMNetworkHandlerTest { … };
TEST_F(FCMNetworkHandlerTest, ShouldPassTheTokenOnceRecieved) { … }
TEST_F(FCMNetworkHandlerTest, ShouldPassTheTokenOnceSubscribed) { … }
TEST_F(FCMNetworkHandlerTest, ShouldNotInvokeMessageCallbackOnEmptyMessage) { … }
TEST_F(FCMNetworkHandlerTest, ShouldInvokeMessageCallbackOnValidMessage) { … }
TEST_F(FCMNetworkHandlerTest,
ShouldNotInvokeMessageCallbackOnMessageWithEmptyVersion) { … }
TEST_F(FCMNetworkHandlerTest,
ShouldNotInvokeMessageCallbackOnMessageWithInvalidVersion) { … }
TEST_F(FCMNetworkHandlerTest,
ShouldNotInvokeMessageCallbackOnMessageWithEmptyPrivateTopic) { … }
TEST_F(FCMNetworkHandlerTest, ShouldRequestTokenImmediatellyEvenIfSaved) { … }
TEST_F(FCMNetworkHandlerTest, ShouldScheduleTokenValidationAndActOnNewToken) { … }
TEST_F(FCMNetworkHandlerTest,
ShouldScheduleTokenValidationAndDoNotActOnSameToken) { … }
TEST_F(FCMNetworkHandlerTestWithTTL, ShouldProvideTTLWithPolicySenderID) { … }
TEST_F(FCMNetworkHandlerTestWithTTL, ShouldNotProvideTTLWithFakeSenderID) { … }
}