test: firmware verificationCompleted: canHandleBlob,getBlobIds

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I915cf37db60a1e44876985902306831306ed805f
diff --git a/test/firmware_state_verificationcompleted_unittest.cpp b/test/firmware_state_verificationcompleted_unittest.cpp
index 3d20ce7..f7a0f2c 100644
--- a/test/firmware_state_verificationcompleted_unittest.cpp
+++ b/test/firmware_state_verificationcompleted_unittest.cpp
@@ -20,6 +20,7 @@
 {
 
 using ::testing::Return;
+using ::testing::UnorderedElementsAreArray;
 
 /*
  * There are the following calls (parameters may vary):
@@ -76,12 +77,39 @@
         blobs::OpenFlags::write | FirmwareBlobHandler::UpdateFlags::ipmi;
 };
 
-/* TODO:
- * canHandleBlob(blob)
- * getBlobIds
- * deleteBlob(blob)
- *
+/* TODO: deleteBlob(blob) */
+
+/*
+ * canHandleBlob
  */
+TEST_F(FirmwareHandlerVerificationCompletedTest,
+       OnVerificationCompleteSuccessUpdateBlobIdNotPresent)
+{
+    /* the uploadBlobId is only added on close() of the verifyBlobId.  This is a
+     * consistent behavior with verifyBlobId only added when closing the image
+     * or hash.
+     */
+    getToVerificationCompleted(VerifyCheckResponses::success);
+    EXPECT_FALSE(handler->canHandleBlob(updateBlobId));
+}
+
+TEST_F(FirmwareHandlerVerificationCompletedTest,
+       OnVerificationCompleteFailureUpdateBlobIdNotPresent)
+{
+    getToVerificationCompleted(VerifyCheckResponses::failed);
+    EXPECT_FALSE(handler->canHandleBlob(updateBlobId));
+}
+
+/*
+ * getBlobIds
+ */
+TEST_F(FirmwareHandlerVerificationCompletedTest, GetBlobIdsReturnsExpectedList)
+{
+    getToVerificationCompleted(VerifyCheckResponses::success);
+    std::vector<std::string> expected = {verifyBlobId, hashBlobId,
+                                         activeImageBlobId, staticLayoutBlobId};
+    EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+}
 
 /*
  * stat(blob)