#include "remoting/signaling/ftl_message_reception_channel.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.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/protobuf_http_status.h"
#include "remoting/base/scoped_protobuf_http_request.h"
#include "remoting/proto/ftl/v1/ftl_messages.pb.h"
#include "remoting/signaling/ftl_services_context.h"
#include "remoting/signaling/signaling_tracker.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
namespace {
_;
Expectation;
Invoke;
Property;
Return;
ReceiveMessagesResponseCallback;
StatusCallback;
class MockSignalingTracker : public SignalingTracker { … };
class FakeScopedProtobufHttpRequest : public ScopedProtobufHttpRequest { … };
std::unique_ptr<FakeScopedProtobufHttpRequest> CreateFakeServerStream() { … }
template <typename OnStreamOpenedLambda>
decltype(auto) StartStream(OnStreamOpenedLambda on_stream_opened,
base::WeakPtr<FakeScopedProtobufHttpRequest>*
optional_out_stream = nullptr) { … }
base::OnceClosure NotReachedClosure() { … }
base::RepeatingCallback<void(const ProtobufHttpStatus&)>
NotReachedStatusCallback(const base::Location& location) { … }
base::OnceCallback<void(const ProtobufHttpStatus&)>
CheckStatusThenQuitRunLoopCallback(
const base::Location& from_here,
ProtobufHttpStatus::Code expected_status_code,
base::RunLoop* run_loop) { … }
}
class FtlMessageReceptionChannelTest : public testing::Test { … };
void FtlMessageReceptionChannelTest::SetUp() { … }
void FtlMessageReceptionChannelTest::TearDown() { … }
base::TimeDelta FtlMessageReceptionChannelTest::GetTimeUntilRetry() const { … }
int FtlMessageReceptionChannelTest::GetRetryFailureCount() const { … }
TEST_F(FtlMessageReceptionChannelTest,
TestStartReceivingMessages_StoppedImmediately) { … }
TEST_F(FtlMessageReceptionChannelTest,
TestStartReceivingMessages_NotAuthenticated) { … }
TEST_F(FtlMessageReceptionChannelTest,
TestStartReceivingMessages_StreamStarted) { … }
TEST_F(FtlMessageReceptionChannelTest,
TestStartReceivingMessages_RecoverableStreamError) { … }
TEST_F(FtlMessageReceptionChannelTest,
TestStartReceivingMessages_MultipleCalls) { … }
TEST_F(FtlMessageReceptionChannelTest, StreamsTwoMessages) { … }
TEST_F(FtlMessageReceptionChannelTest, ReceivedOnePong_OnSignalingActiveTwice) { … }
TEST_F(FtlMessageReceptionChannelTest, NoPongWithinTimeout_ResetsStream) { … }
TEST_F(FtlMessageReceptionChannelTest, ServerClosesStream_ResetsStream) { … }
TEST_F(FtlMessageReceptionChannelTest, TimeoutIncreasesToMaximum) { … }
TEST_F(FtlMessageReceptionChannelTest,
StartStreamFailsWithUnRecoverableErrorAndRetry_TimeoutApplied) { … }
}