#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <memory>
#include <numbers>
#include <utility>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/math_constants.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/threading/thread.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "remoting/base/constants.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/protocol/audio_source.h"
#include "remoting/protocol/audio_stream.h"
#include "remoting/protocol/audio_stub.h"
#include "remoting/protocol/desktop_capturer.h"
#include "remoting/protocol/fake_session.h"
#include "remoting/protocol/fake_video_renderer.h"
#include "remoting/protocol/ice_connection_to_client.h"
#include "remoting/protocol/ice_connection_to_host.h"
#include "remoting/protocol/network_settings.h"
#include "remoting/protocol/protocol_mock_objects.h"
#include "remoting/protocol/transport_context.h"
#include "remoting/protocol/video_stream.h"
#include "remoting/protocol/webrtc_connection_to_client.h"
#include "remoting/protocol/webrtc_connection_to_host.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
_;
InvokeWithoutArgs;
NotNull;
StrictMock;
namespace remoting::protocol {
namespace {
MATCHER_P(EqualsCapabilitiesMessage, message, "") { … }
MATCHER_P(EqualsKeyEvent, event, "") { … }
ACTION_P(QuitRunLoop, run_loop) { … }
class MockConnectionToHostEventCallback
: public ConnectionToHost::HostEventCallback { … };
class TestScreenCapturer : public DesktopCapturer { … };
static const int kAudioSampleRate = AudioPacket::SAMPLING_RATE_48000;
static const int kAudioPacketDurationMs = …;
static constexpr int kSamplesPerAudioPacket = …;
static constexpr base::TimeDelta kAudioPacketDuration = …;
static const int kAudioChannels = …;
static const int kTestAudioSignalFrequencyLeftHz = …;
static const int kTestAudioSignalFrequencyRightHz = …;
class TestAudioSource : public AudioSource { … };
class FakeAudioPlayer : public AudioStub { … };
}
class ConnectionTest : public testing::Test,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ConnectionTest, RejectConnection) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_Disconnect …
#else
#define MAYBE_Disconnect …
#endif
TEST_P(ConnectionTest, MAYBE_Disconnect) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_Control …
#else
#define MAYBE_Control …
#endif
TEST_P(ConnectionTest, MAYBE_Control) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_Events …
#else
#define MAYBE_Events …
#endif
TEST_P(ConnectionTest, MAYBE_Events) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_Video …
#else
#define MAYBE_Video …
#endif
TEST_P(ConnectionTest, MAYBE_Video) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_VideoWithSlowSignaling …
#else
#define MAYBE_VideoWithSlowSignaling …
#endif
TEST_P(ConnectionTest, MAYBE_VideoWithSlowSignaling) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_DestroyOnIncomingMessage …
#else
#define MAYBE_DestroyOnIncomingMessage …
#endif
TEST_P(ConnectionTest, MAYBE_DestroyOnIncomingMessage) { … }
TEST_P(ConnectionTest, DISABLED_VideoStats) { … }
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
(defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER)) || \
BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
#define MAYBE_Audio …
#else
#define MAYBE_Audio …
#endif
TEST_P(ConnectionTest, MAYBE_Audio) { … }
TEST_P(ConnectionTest, DISABLED_FirstCaptureFailed) { … }
TEST_P(ConnectionTest, DISABLED_SecondCaptureFailed) { … }
}