#include "components/sharing_message/sharing_message_sender.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "components/send_tab_to_self/target_device_info.h"
#include "components/sharing_message/fake_device_info.h"
#include "components/sharing_message/ios_push/sharing_ios_push_sender.h"
#include "components/sharing_message/proto/sharing_message.pb.h"
#include "components/sharing_message/sharing_fcm_sender.h"
#include "components/sharing_message/sharing_metrics.h"
#include "components/sharing_message/sharing_sync_preference.h"
#include "components/sharing_message/sharing_utils.h"
#include "components/sync/protocol/device_info_specifics.pb.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 "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const char kReceiverGUID[] = …;
const char kReceiverDeviceName[] = …;
const char kP256dh[] = …;
const char kAuthSecret[] = …;
const char kFCMToken[] = …;
const char kAuthorizedEntity[] = …;
const char kSenderVapidFcmToken[] = …;
const char kSenderVapidP256dh[] = …;
const char kSenderVapidAuthSecret[] = …;
const char kSenderSenderIdFcmToken[] = …;
const char kSenderSenderIdP256dh[] = …;
const char kSenderSenderIdAuthSecret[] = …;
const char kSenderMessageID[] = …;
constexpr base::TimeDelta kTimeToLive = …;
namespace {
class MockSharingFCMSender : public SharingFCMSender { … };
class MockSharingIOSPushSender : public sharing_message::SharingIOSPushSender { … };
class MockSendMessageDelegate
: public SharingMessageSender::SendMessageDelegate { … };
syncer::DeviceInfo::SharingInfo CreateLocalSharingInfo() { … }
syncer::DeviceInfo::SharingInfo CreateSharingInfo() { … }
SharingTargetDeviceInfo CreateFakeSharingTargetDeviceInfo(
const std::string& guid,
const std::string& client_name) { … }
}
class SharingMessageSenderTest : public testing::Test { … };
MATCHER_P(ProtoEquals, message, "") { … }
}
TEST_F(SharingMessageSenderTest, MessageSent_AckTimedout) { … }
TEST_F(SharingMessageSenderTest, SendMessageToDevice_InternalError) { … }
TEST_F(SharingMessageSenderTest, SendUnencryptedMessageToDevice_InternalError) { … }
TEST_F(SharingMessageSenderTest, MessageSent_AckReceived) { … }
TEST_F(SharingMessageSenderTest, MessageSent_AckReceivedBeforeMessageId) { … }
TEST_F(SharingMessageSenderTest, NonExistingDelegate) { … }
TEST_F(SharingMessageSenderTest, RequestCancelled) { … }