test: add state check helper method

Reduce duplicate code by providing a simple helper that will perform the
expectation check of a given state.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I37aae09bebc44149671e1510e815dc724bd60c0b
diff --git a/test/firmware_state_notyetstarted_unittest.cpp b/test/firmware_state_notyetstarted_unittest.cpp
index 4d850aa..f662820 100644
--- a/test/firmware_state_notyetstarted_unittest.cpp
+++ b/test/firmware_state_notyetstarted_unittest.cpp
@@ -90,26 +90,22 @@
  */
 TEST_F(FirmwareHandlerNotYetStartedTest, OpenStaticImageFileVerifyStateChange)
 {
-    auto realHandler = dynamic_cast<FirmwareBlobHandler*>(handler.get());
-
     EXPECT_CALL(imageMock, open(staticLayoutBlobId)).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(session, flags, staticLayoutBlobId));
-    EXPECT_EQ(FirmwareBlobHandler::UpdateState::uploadInProgress,
-              realHandler->getCurrentState());
+
+    expectedState(FirmwareBlobHandler::UpdateState::uploadInProgress);
 
     EXPECT_TRUE(handler->canHandleBlob(activeImageBlobId));
 }
 
 TEST_F(FirmwareHandlerNotYetStartedTest, OpenHashFileVerifyStateChange)
 {
-    auto realHandler = dynamic_cast<FirmwareBlobHandler*>(handler.get());
-
     EXPECT_CALL(imageMock, open(hashBlobId)).WillOnce(Return(true));
 
     EXPECT_TRUE(handler->open(session, flags, hashBlobId));
-    EXPECT_EQ(FirmwareBlobHandler::UpdateState::uploadInProgress,
-              realHandler->getCurrentState());
+
+    expectedState(FirmwareBlobHandler::UpdateState::uploadInProgress);
 
     EXPECT_TRUE(handler->canHandleBlob(activeHashBlobId));
 }