test: use common test object
Many tests only set up an IPMI data handler, or one with LPC in
addition, therefore this code can be more easily managed in one
location.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ie42a74d59bbd74c077c3cf7794546c71e92d2ef7
diff --git a/test/firmware_open_unittest.cpp b/test/firmware_open_unittest.cpp
index 13f802b..c8c93c0 100644
--- a/test/firmware_open_unittest.cpp
+++ b/test/firmware_open_unittest.cpp
@@ -1,5 +1,6 @@
#include "data_mock.hpp"
#include "firmware_handler.hpp"
+#include "firmware_unittest.hpp"
#include "image_mock.hpp"
#include "util.hpp"
#include "verification_mock.hpp"
@@ -16,51 +17,12 @@
using ::testing::Return;
using ::testing::StrEq;
-class FirmwareHandlerOpenTestIpmiOnly : public ::testing::Test
+class FirmwareHandlerOpenTestIpmiOnly : public IpmiOnlyFirmwareTest
{
- protected:
- ImageHandlerMock imageMock;
- std::vector<HandlerPack> blobs;
- std::vector<DataHandlerPack> data;
- std::unique_ptr<GenericBlobInterface> handler;
-
- void SetUp() override
- {
- blobs = {
- {hashBlobId, &imageMock},
- {"asdf", &imageMock},
- };
- data = {
- {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
- };
- handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
- blobs, data, CreateVerifyMock());
- }
};
-class FirmwareHandlerOpenTestLpc : public ::testing::Test
+class FirmwareHandlerOpenTestLpc : public FakeLpcFirmwareTest
{
- protected:
- DataHandlerMock dataMock;
- ImageHandlerMock imageMock;
- std::vector<HandlerPack> blobs;
- std::vector<DataHandlerPack> data;
- std::unique_ptr<GenericBlobInterface> handler;
-
- void SetUp() override
- {
- blobs = {
- {hashBlobId, &imageMock},
- {"asdf", &imageMock},
- };
- data = {
- {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
- {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
- };
-
- handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
- blobs, data, CreateVerifyMock());
- }
};
TEST_F(FirmwareHandlerOpenTestIpmiOnly, OpenWithEverythingValid)