blob: b82ab6a231f0f1418201bf83004af63e76247aeb [file] [log] [blame]
Patrick Venturedf848ee2018-11-06 15:44:00 -08001#include "firmware_handler.hpp"
Patrick Venturea78e39f2018-11-06 18:37:06 -08002#include "image_mock.hpp"
Patrick Venturedf848ee2018-11-06 15:44:00 -08003
4#include <memory>
5#include <vector>
6
7#include <gtest/gtest.h>
8
9namespace blobs
10{
11TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk)
12{
Patrick Venturedf848ee2018-11-06 15:44:00 -080013 struct ListItem
14 {
15 std::string name;
16 bool expected;
17 };
18
19 std::vector<ListItem> items = {
20 {"asdf", true}, {"nope", false}, {"123123", false}, {"bcdf", true}};
21
Patrick Venturea78e39f2018-11-06 18:37:06 -080022 ImageHandlerMock imageMock;
23
24 std::vector<HandlerPack> blobs = {
25 {"asdf", &imageMock},
26 {"bcdf", &imageMock},
27 };
28
Patrick Venturedf848ee2018-11-06 15:44:00 -080029 auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler(
Patrick Venturea78e39f2018-11-06 18:37:06 -080030 blobs, static_cast<uint16_t>(FirmwareUpdateFlags::bt));
Patrick Venturedf848ee2018-11-06 15:44:00 -080031
32 for (const auto& item : items)
33 {
34 EXPECT_EQ(item.expected, handler->canHandleBlob(item.name));
35 }
36}
37} // namespace blobs