diff --git a/tests/ibus_test.c b/tests/ibus_test.c index 0035a07..d010a8d 100644 --- a/tests/ibus_test.c +++ b/tests/ibus_test.c @@ -326,6 +326,17 @@ cleanup: 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 ibus_context_lifecycle(struct ct *t) { @@ -412,11 +423,7 @@ ibus_context_lifecycle(struct ct *t) CT_CHECK(t, !a->caret.valid); checkenginepreedit(t, "ん"); CT_EQ_PTR(t, b, testengineowner()); - releasecontext(a); - notrace(t, &f); - dropcontext(a); - notrace(t, &f); - CT_EQ_PTR(t, nil, findcontext(f.c1, "/context/one")); + checkdrop(t, &f, a, "/context/one"); reused = newcontext(f.c1, "/context/stale-destroy"); CT_EQ_PTR(t, a, reused); @@ -482,11 +489,7 @@ ibus_active_release_lifecycle(struct ct *t) CT_CHECK(t, !ctx->focused); checkenginepreedit(t, ""); CT_EQ_PTR(t, nil, testengineowner()); - releasecontext(ctx); - notrace(t, &f); - dropcontext(ctx); - notrace(t, &f); - CT_EQ_PTR(t, nil, findcontext(f.c1, "/context/reset")); + checkdrop(t, &f, ctx, "/context/reset"); reused = newcontext(f.c1, "/context/destroy"); CT_EQ_PTR(t, ctx, reused);