#include "components/sharing_message/sharing_fcm_sender.h"
#include <memory>
#include "base/base64.h"
#include "base/callback_list.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "components/gcm_driver/crypto/gcm_encryption_result.h"
#include "components/gcm_driver/fake_gcm_driver.h"
#include "components/sharing_message/features.h"
#include "components/sharing_message/proto/sharing_message.pb.h"
#include "components/sharing_message/sharing_constants.h"
#include "components/sharing_message/sharing_message_bridge.h"
#include "components/sharing_message/sharing_sync_preference.h"
#include "components/sharing_message/sharing_utils.h"
#include "components/sharing_message/vapid_key_manager.h"
#include "components/sharing_message/web_push/web_push_sender.h"
#include "components/sync/model/data_type_controller_delegate.h"
#include "components/sync/test/test_sync_service.h"
#include "components/sync_device_info/device_info.h"
#include "components/sync_device_info/fake_device_info_sync_service.h"
#include "components/sync_device_info/fake_local_device_info_provider.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "crypto/ec_private_key.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const char kMessageId[] = …;
const char kVapidFcmToken[] = …;
const char kVapidP256dh[] = …;
const char kVapidAuthSecret[] = …;
const char kSenderIdFcmToken[] = …;
const char kSenderIdP256dh[] = …;
const char kSenderIdAuthSecret[] = …;
const char kAuthorizedEntity[] = …;
const int kTtlSeconds = …;
const char kServerConfiguration[] = …;
const char kServerP256dh[] = …;
const char kServerAuthSecret[] = …;
class FakeGCMDriver : public gcm::FakeGCMDriver { … };
class FakeWebPushSender : public WebPushSender { … };
class FakeSharingMessageBridge : public SharingMessageBridge { … };
class MockVapidKeyManager : public VapidKeyManager { … };
class SharingFCMSenderTest : public testing::Test { … };
}
TEST_F(SharingFCMSenderTest, NoFcmRegistration) { … }
TEST_F(SharingFCMSenderTest, NoVapidKey) { … }
TEST_F(SharingFCMSenderTest, NoChannelsSpecified) { … }
TEST_F(SharingFCMSenderTest, PreferSync) { … }
struct WebPushResultTestData { … } kWebPushResultTestData[] = …;
class SharingFCMSenderWebPushResultTest
: public SharingFCMSenderTest,
public testing::WithParamInterface<WebPushResultTestData> { … };
TEST_P(SharingFCMSenderWebPushResultTest, ResultTest) { … }
INSTANTIATE_TEST_SUITE_P(…);
struct CommitErrorCodeTestData { … } kCommitErrorCodeTestData[] = …;
class SharingFCMSenderCommitErrorCodeTest
: public SharingFCMSenderTest,
public testing::WithParamInterface<CommitErrorCodeTestData> { … };
TEST_P(SharingFCMSenderCommitErrorCodeTest, ErrorCodeTest) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(SharingFCMSenderTest, ServerTarget) { … }