Commit 747440d0fa95f2205a8fcef49b6c7845700b6246

Authored by Simon Glass
1 parent 85e08db85b

dm: video: test: Test that bitmap display works correctly

Add a test for the 'bmp' command. Test both the uncompressed and compressed
versions of the file, since they use different code paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>

Showing 3 changed files with 56 additions and 0 deletions Side-by-side Diff

include/configs/sandbox.h
... ... @@ -163,6 +163,8 @@
163 163 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
164 164 #define LCD_BPP LCD_COLOR16
165 165 #define CONFIG_LCD_BMP_RLE8
  166 +#define CONFIG_VIDEO_BMP_RLE8
  167 +#define CONFIG_SPLASH_SCREEN_ALIGN
166 168  
167 169 #define CONFIG_KEYBOARD
168 170  
... ... @@ -215,4 +215,58 @@
215 215 return 0;
216 216 }
217 217 DM_TEST(dm_test_video_rotation3, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  218 +
  219 +/* Read a file into memory and return a pointer to it */
  220 +static int read_file(struct unit_test_state *uts, const char *fname,
  221 + ulong *addrp)
  222 +{
  223 + int buf_size = 100000;
  224 + ulong addr = 0;
  225 + int size, fd;
  226 + char *buf;
  227 +
  228 + buf = map_sysmem(addr, 0);
  229 + ut_assert(buf != NULL);
  230 + fd = os_open(fname, OS_O_RDONLY);
  231 + ut_assert(fd >= 0);
  232 + size = os_read(fd, buf, buf_size);
  233 + ut_assert(size >= 0);
  234 + ut_assert(size < buf_size);
  235 + os_close(fd);
  236 + *addrp = addr;
  237 +
  238 + return 0;
  239 +}
  240 +
  241 +/* Test drawing a bitmap file */
  242 +static int dm_test_video_bmp(struct unit_test_state *uts)
  243 +{
  244 + struct udevice *dev;
  245 + ulong addr;
  246 +
  247 + ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
  248 + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr));
  249 +
  250 + ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
  251 + ut_asserteq(1368, compress_frame_buffer(dev));
  252 +
  253 + return 0;
  254 +}
  255 +DM_TEST(dm_test_video_bmp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  256 +
  257 +/* Test drawing a compressed bitmap file */
  258 +static int dm_test_video_bmp_comp(struct unit_test_state *uts)
  259 +{
  260 + struct udevice *dev;
  261 + ulong addr;
  262 +
  263 + ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
  264 + ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr));
  265 +
  266 + ut_assertok(video_bmp_display(dev, addr, 0, 0, false));
  267 + ut_asserteq(1368, compress_frame_buffer(dev));
  268 +
  269 + return 0;
  270 +}
  271 +DM_TEST(dm_test_video_bmp_comp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
tools/logos/denx-comp.bmp
No preview for this file type