Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 1 | #include "firmware_handler.hpp" |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 2 | #include "image_mock.hpp" |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 3 | |
| 4 | #include <memory> |
| 5 | #include <vector> |
| 6 | |
| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | namespace blobs |
| 10 | { |
| 11 | TEST(FirmwareHandlerCanHandleTest, VerifyItemsInListAreOk) |
| 12 | { |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 13 | 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 Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 22 | ImageHandlerMock imageMock; |
| 23 | |
| 24 | std::vector<HandlerPack> blobs = { |
| 25 | {"asdf", &imageMock}, |
| 26 | {"bcdf", &imageMock}, |
| 27 | }; |
| 28 | |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 29 | auto handler = FirmwareBlobHandler::CreateFirmwareBlobHandler( |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 30 | blobs, static_cast<uint16_t>(FirmwareUpdateFlags::bt)); |
Patrick Venture | df848ee | 2018-11-06 15:44:00 -0800 | [diff] [blame] | 31 | |
| 32 | for (const auto& item : items) |
| 33 | { |
| 34 | EXPECT_EQ(item.expected, handler->canHandleBlob(item.name)); |
| 35 | } |
| 36 | } |
| 37 | } // namespace blobs |