test: name the release-then-drop check the two IBus lifecycle tests share

This commit is contained in:
2026-08-16 18:37:29 +09:00
parent 0aef3506b6
commit 4b6cc6fb2f

View File

@@ -326,6 +326,17 @@ cleanup:
ibusend(&f); ibusend(&f);
} }
/* A second release is silent, and dropping frees the slot. */
static void
checkdrop(struct ct *t, Ibusfix *f, Ictx *ctx, char *path)
{
releasecontext(ctx);
notrace(t, f);
dropcontext(ctx);
notrace(t, f);
CT_EQ_PTR(t, nil, findcontext(f->c1, path));
}
void void
ibus_context_lifecycle(struct ct *t) ibus_context_lifecycle(struct ct *t)
{ {
@@ -412,11 +423,7 @@ ibus_context_lifecycle(struct ct *t)
CT_CHECK(t, !a->caret.valid); CT_CHECK(t, !a->caret.valid);
checkenginepreedit(t, ""); checkenginepreedit(t, "");
CT_EQ_PTR(t, b, testengineowner()); CT_EQ_PTR(t, b, testengineowner());
releasecontext(a); checkdrop(t, &f, a, "/context/one");
notrace(t, &f);
dropcontext(a);
notrace(t, &f);
CT_EQ_PTR(t, nil, findcontext(f.c1, "/context/one"));
reused = newcontext(f.c1, "/context/stale-destroy"); reused = newcontext(f.c1, "/context/stale-destroy");
CT_EQ_PTR(t, a, reused); CT_EQ_PTR(t, a, reused);
@@ -482,11 +489,7 @@ ibus_active_release_lifecycle(struct ct *t)
CT_CHECK(t, !ctx->focused); CT_CHECK(t, !ctx->focused);
checkenginepreedit(t, ""); checkenginepreedit(t, "");
CT_EQ_PTR(t, nil, testengineowner()); CT_EQ_PTR(t, nil, testengineowner());
releasecontext(ctx); checkdrop(t, &f, ctx, "/context/reset");
notrace(t, &f);
dropcontext(ctx);
notrace(t, &f);
CT_EQ_PTR(t, nil, findcontext(f.c1, "/context/reset"));
reused = newcontext(f.c1, "/context/destroy"); reused = newcontext(f.c1, "/context/destroy");
CT_EQ_PTR(t, ctx, reused); CT_EQ_PTR(t, ctx, reused);