#include "remoting/host/heartbeat_sender.h"
#include <stdint.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "remoting/base/fake_oauth_token_getter.h"
#include "remoting/base/protobuf_http_status.h"
#include "remoting/signaling/fake_signal_strategy.h"
#include "remoting/signaling/signal_strategy.h"
#include "remoting/signaling/signaling_address.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
namespace {
_;
AtMost;
InSequence;
Return;
LegacyHeartbeatResponseCallback;
SendHeartbeatResponseCallback;
constexpr char kOAuthAccessToken[] = …;
constexpr char kHostId[] = …;
constexpr char kUserEmail[] = …;
constexpr char kFtlId[] = …;
constexpr int32_t kGoodIntervalSeconds = …;
constexpr base::TimeDelta kWaitForAllStrategiesConnectedTimeout = …;
constexpr base::TimeDelta kOfflineReasonTimeout = …;
constexpr base::TimeDelta kTestHeartbeatDelay = …;
struct ValidateLegacyHeartbeatOptions { … };
void ValidateLegacyHeartbeat(
std::unique_ptr<apis::v1::HeartbeatRequest> request,
const ValidateLegacyHeartbeatOptions& options) { … }
decltype(auto) DoValidateLegacyHeartbeatAndRespondOk(
const ValidateLegacyHeartbeatOptions& options) { … }
decltype(auto) DoValidateSendHeartbeatAndRespondOk() { … }
class MockDelegate : public HeartbeatSender::Delegate { … };
class MockObserver : public HeartbeatSender::Observer { … };
}
class HeartbeatSenderTest : public testing::Test { … };
TEST_F(HeartbeatSenderTest, SendHeartbeat) { … }
TEST_F(HeartbeatSenderTest, SendHeartbeat_WithFqdn) { … }
TEST_F(HeartbeatSenderTest, SendHeartbeat_WithOwnerEmail) { … }
TEST_F(HeartbeatSenderTest, SendHeartbeat_RequireSessionAuth) { … }
TEST_F(HeartbeatSenderTest, SendHeartbeat_IsCorpUser) { … }
TEST_F(HeartbeatSenderTest, SignalingReconnect_NewHeartbeats) { … }
TEST_F(HeartbeatSenderTest, SignalingReconnect_NewHeartbeats_Lite) { … }
TEST_F(HeartbeatSenderTest, SignalingReconnect_NewHeartbeats_Googler) { … }
TEST_F(HeartbeatSenderTest, Signaling_MultipleHeartbeats) { … }
TEST_F(HeartbeatSenderTest, Signaling_MultipleHeartbeats_Googler) { … }
TEST_F(HeartbeatSenderTest, Signaling_MultipleHeartbeats_Lite) { … }
TEST_F(HeartbeatSenderTest, SetHostOfflineReason) { … }
TEST_F(HeartbeatSenderTest, UnknownHostId) { … }
TEST_F(HeartbeatSenderTest, FailedToHeartbeat_Backoff) { … }
TEST_F(HeartbeatSenderTest, HostComesBackOnlineAfterServiceOutage) { … }
TEST_F(HeartbeatSenderTest, Unauthenticated) { … }
TEST_F(HeartbeatSenderTest, GooglerHostname) { … }
}