chromium/remoting/signaling/ftl_message_reception_channel_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {};

// Fake stream implementation to allow probing if a stream is closed by client.
class FakeScopedProtobufHttpRequest : public ScopedProtobufHttpRequest {};

std::unique_ptr<FakeScopedProtobufHttpRequest> CreateFakeServerStream() {}

// Creates a gmock EXPECT_CALL action that:
//   1. Creates a fake server stream and returns it as the start stream result
//   2. Posts a task to call |on_stream_opened| at the end of current sequence
//   3. Writes the WeakPtr to the fake server stream to |optional_out_stream|
//      if it is provided.
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) {}

}  // namespace

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) {}

}  // namespace remoting