Add test cases for testing basic CFB functions. These tests cannot run in CI because the CI environment has no display. Mark these tests as `build_only`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
/*
|
|
* Copyright (c) 2024 TOKITA Hiroshi
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/drivers/display.h>
|
|
#include <zephyr/ztest.h>
|
|
#include <zephyr/device.h>
|
|
#include <zephyr/logging/log.h>
|
|
#include <zephyr/display/cfb.h>
|
|
|
|
#include "testdata.h"
|
|
#include "utils.h"
|
|
|
|
LOG_MODULE_REGISTER(clear, CONFIG_DISPLAY_LOG_LEVEL);
|
|
|
|
static const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
|
|
static const uint32_t display_width = DT_PROP(DT_CHOSEN(zephyr_display), width);
|
|
static const uint32_t display_height = DT_PROP(DT_CHOSEN(zephyr_display), height);
|
|
|
|
/**
|
|
* Fill the buffer with 0xAA before running tests.
|
|
*/
|
|
static void cfb_test_before(void *text_fixture)
|
|
{
|
|
struct display_buffer_descriptor desc = {
|
|
.height = display_height,
|
|
.pitch = display_width,
|
|
.width = display_width,
|
|
.buf_size = display_height * display_width / 8,
|
|
};
|
|
|
|
memset(read_buffer, 0xAA, sizeof(read_buffer));
|
|
zassert_ok(display_write(dev, 0, 0, &desc, read_buffer));
|
|
|
|
zassert_ok(display_blanking_off(dev));
|
|
|
|
zassert_ok(cfb_framebuffer_init(dev));
|
|
}
|
|
|
|
static void cfb_test_after(void *test_fixture)
|
|
{
|
|
cfb_framebuffer_deinit(dev);
|
|
}
|
|
|
|
ZTEST(clear, test_clear_false)
|
|
{
|
|
zassert_ok(cfb_framebuffer_clear(dev, false));
|
|
|
|
/* checking memory not updated */
|
|
zassert_false(verify_color_inside_rect(0, 0, 320, 240, 0x0));
|
|
}
|
|
|
|
ZTEST(clear, test_clear_true)
|
|
{
|
|
zassert_ok(cfb_framebuffer_clear(dev, true));
|
|
|
|
zassert_true(verify_color_inside_rect(0, 0, 320, 240, 0x0));
|
|
}
|
|
|
|
ZTEST_SUITE(clear, NULL, NULL, cfb_test_before, cfb_test_after, NULL);
|