* Test bitmap widget. */
| 119 | * Test bitmap widget. |
| 120 | */ |
| 121 | static void testBitmapWidget() |
| 122 | { |
| 123 | const uint16_t BITMAP_WIDTH = YAGfxTest::HEIGHT; /* Use height as width here for a square. */ |
| 124 | const uint16_t BITMAP_HEIGHT = YAGfxTest::HEIGHT; |
| 125 | const char* WIDGET_NAME = "bmpWidgetName"; |
| 126 | |
| 127 | YAGfxTest testGfx; |
| 128 | BitmapWidget bitmapWidget(BITMAP_WIDTH, BITMAP_HEIGHT); |
| 129 | YAGfxStaticBitmap<BITMAP_WIDTH, BITMAP_HEIGHT> bitmap; |
| 130 | |
| 131 | int16_t x = 0; |
| 132 | int16_t y = 0; |
| 133 | const Color* bitmapPtr = nullptr; |
| 134 | uint16_t width = 0U; |
| 135 | uint16_t height = 0U; |
| 136 | Color* displayBuffer = nullptr; |
| 137 | |
| 138 | /* Verify widget type name */ |
| 139 | TEST_ASSERT_EQUAL_STRING(BitmapWidget::WIDGET_TYPE, bitmapWidget.getType()); |
| 140 | |
| 141 | /* No widget name is set, it must be empty. */ |
| 142 | TEST_ASSERT_EQUAL_STRING("", bitmapWidget.getName().c_str()); |
| 143 | |
| 144 | /* Set widget name and read back. */ |
| 145 | bitmapWidget.setName(WIDGET_NAME); |
| 146 | TEST_ASSERT_EQUAL_STRING(WIDGET_NAME, bitmapWidget.getName().c_str()); |
| 147 | |
| 148 | /* Find widget with empty name. |
| 149 | * Expected: Not found |
| 150 | */ |
| 151 | TEST_ASSERT_NULL(bitmapWidget.find("")); |
| 152 | |
| 153 | /* Find widget with its name. |
| 154 | * Expected: Widget is found |
| 155 | */ |
| 156 | TEST_ASSERT_NOT_NULL(bitmapWidget.find(WIDGET_NAME)); |
| 157 | TEST_ASSERT_EQUAL_PTR(&bitmapWidget, bitmapWidget.find(WIDGET_NAME)); |
| 158 | |
| 159 | /* Create bitmap */ |
| 160 | for(y = 0; y < BITMAP_HEIGHT; ++y) |
| 161 | { |
| 162 | for(x = 0; x < BITMAP_WIDTH; ++x) |
| 163 | { |
| 164 | bitmap.drawPixel(x, y, x + y * BITMAP_WIDTH); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /* Set bitmap and read back */ |
| 169 | bitmapWidget.set(bitmap); |
| 170 | TEST_ASSERT_EQUAL_UINT16(BITMAP_WIDTH, bitmapWidget.get().getWidth()); |
| 171 | TEST_ASSERT_EQUAL_UINT16(BITMAP_HEIGHT, bitmapWidget.get().getHeight()); |
| 172 | |
| 173 | for(y = 0; y < BITMAP_HEIGHT; ++y) |
| 174 | { |
| 175 | for(x = 0; x < BITMAP_WIDTH; ++x) |
| 176 | { |
| 177 | const Color& bitmapColor = bitmap.getColor(x, y); |
| 178 | const Color& bitmapWidgetColor = bitmapWidget.get().getColor(x, y); |
nothing calls this directly
no test coverage detected