#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "remoting/host/native_messaging/native_messaging_reader.h"
#include <cstdint>
#include <memory>
#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "build/build_config.h"
#include "remoting/host/setup/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
class NativeMessagingReaderTest : public testing::Test { … };
NativeMessagingReaderTest::NativeMessagingReaderTest() = default;
NativeMessagingReaderTest::~NativeMessagingReaderTest() = default;
void NativeMessagingReaderTest::SetUp() { … }
void NativeMessagingReaderTest::RunAndWaitForOperationComplete() { … }
void NativeMessagingReaderTest::OnMessage(base::Value message) { … }
void NativeMessagingReaderTest::OnError() { … }
void NativeMessagingReaderTest::WriteMessage(const std::string& message) { … }
void NativeMessagingReaderTest::WriteData(const char* data, int length) { … }
TEST_F(NativeMessagingReaderTest, ReaderDestroyedByClosingPipe) { … }
#if BUILDFLAG(IS_WIN)
TEST_F(NativeMessagingReaderTest, DISABLED_ReaderDestroyedByOwner) {
WriteMessage("{\"foo\": 42}");
RunAndWaitForOperationComplete();
ASSERT_FALSE(on_error_signaled_);
reader_.reset();
ASSERT_FALSE(on_error_signaled_);
}
#endif
TEST_F(NativeMessagingReaderTest, SingleGoodMessage) { … }
TEST_F(NativeMessagingReaderTest, MultipleGoodMessages) { … }
TEST_F(NativeMessagingReaderTest, InvalidLength) { … }
TEST_F(NativeMessagingReaderTest, EmptyFile) { … }
TEST_F(NativeMessagingReaderTest, ShortHeader) { … }
TEST_F(NativeMessagingReaderTest, EmptyBody) { … }
TEST_F(NativeMessagingReaderTest, ShortBody) { … }
TEST_F(NativeMessagingReaderTest, InvalidJSON) { … }
}