test: add dynamic unset-fb and set-fb tests

This adds test cases for 89b37acd98 ("Force re-alloc when previous FB_ID was
0") and 1700cbf1c9 ("Force re-alloc when setting FB to 0").
This commit is contained in:
Simon Ser 2020-12-05 12:36:34 +01:00
parent 89b37acd98
commit 86d7bc9fd7
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 40 additions and 1 deletions

View file

@ -49,6 +49,8 @@ tests = {
'dynamic': [
'same',
'change-fb',
'unset-fb',
'set-fb',
'add-layer',
'remove-layer',
'change-composition-layer',

View file

@ -51,7 +51,6 @@ static void first_commit(struct context *ctx) {
assert(ok);
ret = drmModeAtomicCommit(ctx->drm_fd, req, 0, NULL);
assert(ret == 0);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
drmModeAtomicFree(req);
ctx->commit_count = liftoff_mock_commit_count;
@ -87,36 +86,72 @@ static void second_commit(struct context *ctx, bool want_reuse_prev_alloc) {
static void run_same(struct context *ctx) {
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
second_commit(ctx, true);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void run_change_fb(struct context *ctx) {
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));
second_commit(ctx, true);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void run_unset_fb(struct context *ctx) {
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
liftoff_layer_set_property(ctx->layer, "FB_ID", 0);
second_commit(ctx, false);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == NULL);
}
static void run_set_fb(struct context *ctx) {
liftoff_layer_set_property(ctx->layer, "FB_ID", 0);
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == NULL);
liftoff_layer_set_property(ctx->layer, "FB_ID",
liftoff_mock_drm_create_fb(ctx->layer));
second_commit(ctx, false);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void run_add_layer(struct context *ctx) {
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
add_layer(ctx->output, 0, 0, 256, 256);
second_commit(ctx, false);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void run_remove_layer(struct context *ctx) {
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
liftoff_layer_destroy(ctx->other_layer);
ctx->other_layer = NULL;
second_commit(ctx, false);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
static void run_change_composition_layer(struct context *ctx) {
first_commit(ctx);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
liftoff_output_set_composition_layer(ctx->output, ctx->layer);
second_commit(ctx, false);
assert(liftoff_mock_plane_get_layer(ctx->mock_plane) == ctx->layer);
}
@ -124,6 +159,8 @@ static void run_change_composition_layer(struct context *ctx) {
static const struct test_case tests[] = {
{ .name = "same", .run = run_same },
{ .name = "change-fb", .run = run_change_fb },
{ .name = "unset-fb", .run = run_unset_fb },
{ .name = "set-fb", .run = run_set_fb },
{ .name = "add-layer", .run = run_add_layer },
{ .name = "remove-layer", .run = run_remove_layer },
{ .name = "change-composition-layer", .run = run_change_composition_layer },