test: add dynamic@change-fb-modifier

This commit is contained in:
Simon Ser 2023-02-09 12:34:08 +01:00
parent ab72b0d5c6
commit 62cd0aad09
2 changed files with 55 additions and 2 deletions

View file

@ -54,6 +54,7 @@ tests = {
'dynamic': [
'same',
'change-fb',
'change-fb-modifier',
'unset-fb',
'set-fb',
'add-layer',

View file

@ -1,4 +1,5 @@
#include <assert.h>
#include <drm_fourcc.h>
#include <unistd.h>
#include <libliftoff.h>
#include <stdbool.h>
@ -100,16 +101,66 @@ run_same(struct context *ctx)
static void
run_change_fb(struct context *ctx)
{
uint32_t fb_id;
drmModeFB2 fb_info;
fb_id = liftoff_mock_drm_create_fb(ctx->layer);
fb_info = (drmModeFB2) {
.fb_id = fb_id,
.width = 1920,
.height = 1080,
.flags = DRM_MODE_FB_MODIFIERS,
.pixel_format = DRM_FORMAT_ARGB8888,
.modifier = DRM_FORMAT_MOD_LINEAR,
};
liftoff_mock_drm_set_fb_info(&fb_info);
liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id);
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
liftoff_layer_set_property(ctx->layer, "FB_ID",
liftoff_mock_drm_create_fb(ctx->layer));
/* Create a new FB with the exact same FB info as the first one. */
fb_id = liftoff_mock_drm_create_fb(ctx->layer);
fb_info.fb_id = fb_id;
liftoff_mock_drm_set_fb_info(&fb_info);
liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id);
second_commit(ctx, true);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void
run_change_fb_modifier(struct context *ctx)
{
uint32_t fb_id;
drmModeFB2 fb_info;
fb_id = liftoff_mock_drm_create_fb(ctx->layer);
fb_info = (drmModeFB2) {
.fb_id = fb_id,
.width = 1920,
.height = 1080,
.flags = DRM_MODE_FB_MODIFIERS,
.pixel_format = DRM_FORMAT_ARGB8888,
.modifier = I915_FORMAT_MOD_Y_TILED,
};
liftoff_mock_drm_set_fb_info(&fb_info);
liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id);
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
/* Simulate the situation where the previous FB gets removed, and a new
* one gets re-created with the same FB ID but a different modifier.
* This should prevent the first configuration from being re-used. */
fb_info.modifier = I915_FORMAT_MOD_X_TILED;
liftoff_mock_drm_set_fb_info(&fb_info);
liftoff_layer_set_property(ctx->layer, "FB_ID", fb_id);
second_commit(ctx, false);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void
run_unset_fb(struct context *ctx)
{
@ -274,6 +325,7 @@ run_change_fb_damage_clips(struct context *ctx)
static const struct test_case tests[] = {
{ .name = "same", .run = run_same },
{ .name = "change-fb", .run = run_change_fb },
{ .name = "change-fb-modifier", .run = run_change_fb_modifier },
{ .name = "unset-fb", .run = run_unset_fb },
{ .name = "set-fb", .run = run_set_fb },
{ .name = "add-layer", .run = run_add_layer },