tools: add progress implementation
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I9da1674d6cbc688efc7bab0e033788d6ee4694f7
diff --git a/tools/test/tools_lpc_unittest.cpp b/tools/test/tools_lpc_unittest.cpp
index 84a81eb..9e417ed 100644
--- a/tools/test/tools_lpc_unittest.cpp
+++ b/tools/test/tools_lpc_unittest.cpp
@@ -1,6 +1,7 @@
#include "internal_sys_mock.hpp"
#include "io_mock.hpp"
#include "lpc.hpp"
+#include "progress_mock.hpp"
#include <cstring>
#include <ipmiblob/test/blob_interface_mock.hpp>
@@ -9,6 +10,8 @@
namespace host_tool
{
+namespace
+{
using ::testing::_;
using ::testing::ContainerEq;
@@ -23,14 +26,17 @@
internal::InternalSysMock sysMock;
ipmiblob::BlobInterfaceMock blobMock;
HostIoInterfaceMock ioMock;
+ ProgressMock progMock;
const std::uint32_t address = 0xfedc1000;
const std::uint32_t length = 0x1000;
- LpcDataHandler handler(&blobMock, &ioMock, address, length, &sysMock);
+ LpcDataHandler handler(&blobMock, &ioMock, address, length, &progMock,
+ &sysMock);
std::uint16_t session = 0xbeef;
std::string filePath = "/asdf";
int fileDescriptor = 5;
+ const int fakeFileSize = 100;
LpcRegion host_lpc_buf;
host_lpc_buf.address = address;
@@ -45,6 +51,8 @@
EXPECT_CALL(sysMock, open(StrEq(filePath.c_str()), _))
.WillOnce(Return(fileDescriptor));
+ EXPECT_CALL(sysMock, getSize(StrEq(filePath.c_str())))
+ .WillOnce(Return(fakeFileSize));
EXPECT_CALL(sysMock, read(_, NotNull(), Gt(data.size())))
.WillOnce(Invoke([&data](int, void* buf, std::size_t) {
std::memcpy(buf, data.data(), data.size());
@@ -66,4 +74,5 @@
EXPECT_TRUE(handler.sendContents(filePath, session));
}
+} // namespace
} // namespace host_tool