blob: 16395df5ed416e06d1d1dce7978e77e1a5e94f62 [file] [log] [blame]
Patrick Venture21be45a2018-11-06 12:08:52 -08001#include "firmware_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08002#include "image_mock.hpp"
Patrick Venture21be45a2018-11-06 12:08:52 -08003
Patrick Venture52854622018-11-06 12:30:00 -08004#include <algorithm>
Patrick Venture21be45a2018-11-06 12:08:52 -08005#include <memory>
Patrick Venturea78e39f2018-11-06 18:37:06 -08006#include <vector>
Patrick Venture21be45a2018-11-06 12:08:52 -08007
8#include <gtest/gtest.h>
9
10namespace blobs
11{
Patrick Venture52854622018-11-06 12:30:00 -080012
13TEST(FirmwareHandlerTest, CreateEmptyListVerifyFails)
Patrick Venture21be45a2018-11-06 12:08:52 -080014{
15 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler({}, 0);
Patrick Venture52854622018-11-06 12:30:00 -080016 EXPECT_EQ(handler, nullptr);
17}
18TEST(FirmwareHandlerTest, CreateEmptyListVerifyHasHash)
19{
Patrick Venturea78e39f2018-11-06 18:37:06 -080020 ImageHandlerMock imageMock;
21
22 std::vector<HandlerPack> blobs = {
23 {"asdf", &imageMock},
24 };
25
26 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(blobs, 0);
Patrick Venture21be45a2018-11-06 12:08:52 -080027 auto result = handler->getBlobIds();
Patrick Venture52854622018-11-06 12:30:00 -080028 EXPECT_EQ(2, result.size());
29 EXPECT_EQ(2, std::count(result.begin(), result.end(), "asdf") +
30 std::count(result.begin(), result.end(),
31 FirmwareBlobHandler::hashBlobID));
Patrick Venture21be45a2018-11-06 12:08:52 -080032}
33} // namespace blobs