Mir

Comment 2 for bug 1655293

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

TEST_F(RaiseSurfaces, key_event_with_cookie)
{
    fake_keyboard->emit_event(mis::a_key_down_event().of_scancode(KEY_M));

    int events = 1;
    if (wait_for_n_events(events, this))
    {
        std::lock_guard<std::mutex> lk(mutex);
        ASSERT_FALSE(out_cookies.empty());
        EXPECT_EQ(mir_surface_get_focus(surface2), mir_surface_focused);

        MirCookie const* cookie = mir_cookie_from_buffer(out_cookies.back().data(), out_cookies.back().size());
        attempt_focus(surface2, cookie);

        mir_cookie_release(cookie);
    }
}

WTF is this test intended to test?

The fixture creates two fullscreen surfaces and paints the default bufferstream. (I think that we're in the process of breaking that technique.)

Then we synthesise a keyboard event and wait for to reach the client.

If we don't see the event, then the test *passes*. That seems wrong.

If we do see the event we check that the second surface has focus. Why do we EXPECT that? That isn't what this test is about! And /this/ is the expectation that fails.

We then try raising surface2 and wait for it to have focus (which, we've just established it has).