#include "remoting/host/ipc_desktop_environment.h"
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/process/process.h"
#include "base/process/process_handle.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_platform_file.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "remoting/base/auto_thread.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/base/constants.h"
#include "remoting/host/desktop_process.h"
#include "remoting/host/desktop_session.h"
#include "remoting/host/desktop_session_connector.h"
#include "remoting/host/desktop_session_proxy.h"
#include "remoting/host/fake_keyboard_layout_monitor.h"
#include "remoting/host/fake_mouse_cursor_monitor.h"
#include "remoting/host/host_mock_objects.h"
#include "remoting/host/mojom/desktop_session.mojom.h"
#include "remoting/protocol/fake_desktop_capturer.h"
#include "remoting/protocol/protocol_mock_objects.h"
#include "remoting/protocol/test_event_matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
RunCallback;
RunOnceCallback;
RunOnceClosure;
_;
AnyNumber;
AtLeast;
AtMost;
ByMove;
DeleteArg;
DoAll;
InSequence;
Return;
ReturnRef;
namespace remoting {
EqualsTouchEvent;
EqualsTouchEventTypeAndId;
using SetUpUrlForwarderResponse =
protocol::UrlForwarderControl::SetUpUrlForwarderResponse;
namespace {
class MockScreenCapturerCallback : public webrtc::DesktopCapturer::Callback { … };
class MockDaemonListener : public IPC::Listener,
public mojom::DesktopSessionRequestHandler { … };
bool MockDaemonListener::OnMessageReceived(const IPC::Message& message) { … }
void MockDaemonListener::OnAssociatedInterfaceRequest(
const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) { … }
void MockDaemonListener::Disconnect() { … }
class MockDesktopSessionManager : public mojom::DesktopSessionManager { … };
void MockDesktopSessionManager::BindNewReceiver(
mojo::PendingAssociatedReceiver<mojom::DesktopSessionManager> receiver) { … }
}
class IpcDesktopEnvironmentTest : public testing::Test { … };
IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest()
: … { … }
IpcDesktopEnvironmentTest::~IpcDesktopEnvironmentTest() = default;
void IpcDesktopEnvironmentTest::SetUp() { … }
void IpcDesktopEnvironmentTest::TearDown() { … }
void IpcDesktopEnvironmentTest::CreateDesktopSession(
int terminal_id,
const ScreenResolution& resolution,
bool virtual_terminal) { … }
void IpcDesktopEnvironmentTest::CloseDesktopSession(int terminal_id) { … }
std::unique_ptr<DesktopEnvironment>
IpcDesktopEnvironmentTest::CreateDesktopEnvironment() { … }
std::unique_ptr<InputInjector>
IpcDesktopEnvironmentTest::CreateInputInjector() { … }
void IpcDesktopEnvironmentTest::DeleteDesktopEnvironment() { … }
void IpcDesktopEnvironmentTest::ReflectClipboardEvent(
const protocol::ClipboardEvent& event) { … }
void IpcDesktopEnvironmentTest::CreateDesktopProcess() { … }
void IpcDesktopEnvironmentTest::DestroyDesktopProcess() { … }
void IpcDesktopEnvironmentTest::ResetRemoteUrlForwarderConfigurator() { … }
void IpcDesktopEnvironmentTest::OnDisconnectCallback() { … }
void IpcDesktopEnvironmentTest::ConnectDesktopChannel(
mojo::ScopedMessagePipeHandle desktop_pipe) { … }
void IpcDesktopEnvironmentTest::RunMainLoopUntilDone() { … }
void IpcDesktopEnvironmentTest::QuitSetupRunLoop() { … }
TEST_F(IpcDesktopEnvironmentTest, Basic) { … }
TEST_F(IpcDesktopEnvironmentTest, TouchEventsCapabilities) { … }
TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { … }
TEST_F(IpcDesktopEnvironmentTest, Reattach) { … }
TEST_F(IpcDesktopEnvironmentTest, InjectClipboardEvent) { … }
TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { … }
TEST_F(IpcDesktopEnvironmentTest, InjectTextEvent) { … }
TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { … }
TEST_F(IpcDesktopEnvironmentTest, InjectTouchEvent) { … }
TEST_F(IpcDesktopEnvironmentTest, SetScreenResolution) { … }
TEST_F(IpcDesktopEnvironmentTest, CheckUrlForwarderState) { … }
TEST_F(IpcDesktopEnvironmentTest, SetUpUrlForwarderHappyPath) { … }
TEST_F(IpcDesktopEnvironmentTest, SetUpUrlForwarderFailed) { … }
}