blob: 906d2b4b8093e0f98ad79b56dbcb00510fb5cc50 [file] [log] [blame]
Patrick Venture8e1b2332019-01-17 15:22:45 -08001#include "blob_interface_mock.hpp"
2#include "internal_sys_mock.hpp"
3#include "lpc.hpp"
4
5#include <cstring>
6
7#include <gtest/gtest.h>
8
9namespace host_tool
10{
11
12using ::testing::ContainerEq;
13
14TEST(LpcHandleTest, verifySendsFileContents)
15{
Patrick Venture69a9e192019-01-17 16:02:33 -080016 internal::InternalSysMock sysMock;
Patrick Venture8e1b2332019-01-17 15:22:45 -080017 BlobInterfaceMock blobMock;
18
Patrick Venture69a9e192019-01-17 16:02:33 -080019 LpcDataHandler handler(&blobMock, &sysMock);
Patrick Venture8e1b2332019-01-17 15:22:45 -080020 std::uint16_t session = 0xbeef;
21 std::string filePath = "/asdf";
22
23 LpcRegion host_lpc_buf;
24 host_lpc_buf.address = 0xfedc1000;
25 host_lpc_buf.length = 0x1000;
26
27 std::vector<std::uint8_t> bytes(sizeof(host_lpc_buf));
28 std::memcpy(bytes.data(), &host_lpc_buf, sizeof(host_lpc_buf));
29
30 EXPECT_CALL(blobMock, writeMeta(session, 0, ContainerEq(bytes)));
31
32 EXPECT_FALSE(handler.sendContents(filePath, session));
33}
34
35} // namespace host_tool