Commit 747440d0fa95f2205a8fcef49b6c7845700b6246
1 parent
85e08db85b
Exists in
v2017.01-smarct4x
and in
30 other branches
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
test/dm/video.c
... | ... | @@ -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