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_sessionstat_unittest.cpp b/test/firmware_sessionstat_unittest.cpp
index f8cc727..d3d35f9 100644
--- a/test/firmware_sessionstat_unittest.cpp
+++ b/test/firmware_sessionstat_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"
@@ -13,40 +14,26 @@
 using ::testing::Eq;
 using ::testing::Return;
 
-class FirmwareSessionStateTest : public ::testing::Test
+class FirmwareSessionStateTestIpmiOnly : public IpmiOnlyFirmwareTest
 {
-  protected:
-    ImageHandlerMock imageMock1, imageMock2;
-    std::vector<HandlerPack> blobs;
-
-    void SetUp() override
-    {
-        blobs = {
-            {hashBlobId, &imageMock1},
-            {"asdf", &imageMock2},
-        };
-    }
 };
 
-TEST_F(FirmwareSessionStateTest, DataTypeIpmiNoMetadata)
+class FirmwareSessionStateTestLpc : public FakeLpcFirmwareTest
+{
+};
+
+TEST_F(FirmwareSessionStateTestIpmiOnly, DataTypeIpmiNoMetadata)
 {
     /* Verifying running stat if the type of data session is IPMI returns no
      * metadata.
      */
-    std::vector<DataHandlerPack> data = {
-        {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
-    };
-
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        blobs, data, CreateVerifyMock());
-
-    EXPECT_CALL(imageMock2, open("asdf")).WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi, "asdf"));
 
     int size = 512;
-    EXPECT_CALL(imageMock2, getSize()).WillOnce(Return(size));
+    EXPECT_CALL(imageMock, getSize()).WillOnce(Return(size));
 
     struct BlobMeta meta;
     EXPECT_TRUE(handler->stat(0, &meta));
@@ -56,30 +43,20 @@
     EXPECT_EQ(meta.metadata.size(), 0);
 }
 
-TEST_F(FirmwareSessionStateTest, DataTypeP2AReturnsMetadata)
+TEST_F(FirmwareSessionStateTestLpc, DataTypeP2AReturnsMetadata)
 {
     /* Really any type that isn't IPMI can return metadata, but we only expect
      * P2A to for now.  Later, LPC may have reason to provide data, and can by
      * simply implementing read().
      */
-    DataHandlerMock dataMock;
-
-    std::vector<DataHandlerPack> data = {
-        {FirmwareBlobHandler::UpdateFlags::ipmi, nullptr},
-        {FirmwareBlobHandler::UpdateFlags::lpc, &dataMock},
-    };
-
-    auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
-        blobs, data, CreateVerifyMock());
-
     EXPECT_CALL(dataMock, open()).WillOnce(Return(true));
-    EXPECT_CALL(imageMock2, open("asdf")).WillOnce(Return(true));
+    EXPECT_CALL(imageMock, open("asdf")).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(
         0, OpenFlags::write | FirmwareBlobHandler::UpdateFlags::lpc, "asdf"));
 
     int size = 512;
-    EXPECT_CALL(imageMock2, getSize()).WillOnce(Return(size));
+    EXPECT_CALL(imageMock, getSize()).WillOnce(Return(size));
     std::vector<std::uint8_t> mBytes = {0x01, 0x02};
     EXPECT_CALL(dataMock, readMeta()).WillOnce(Return(mBytes));