Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 1 | #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 | |
| 9 | namespace host_tool |
| 10 | { |
| 11 | |
| 12 | using ::testing::ContainerEq; |
| 13 | |
| 14 | TEST(LpcHandleTest, verifySendsFileContents) |
| 15 | { |
Patrick Venture | 69a9e19 | 2019-01-17 16:02:33 -0800 | [diff] [blame^] | 16 | internal::InternalSysMock sysMock; |
Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 17 | BlobInterfaceMock blobMock; |
| 18 | |
Patrick Venture | 69a9e19 | 2019-01-17 16:02:33 -0800 | [diff] [blame^] | 19 | LpcDataHandler handler(&blobMock, &sysMock); |
Patrick Venture | 8e1b233 | 2019-01-17 15:22:45 -0800 | [diff] [blame] | 20 | 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 |