test-runner: make test_case_wait() wait for queued-work

Sometimes (for example with minimization) a request from the client
causes queued work rather than immediate work; so make the test client
'wait' command wait for a full frame cycle.

https://bugzilla.gnome.org/show_bug.cgi?id=737233
This commit is contained in:
Owen W. Taylor 2014-09-24 15:52:11 -04:00
parent d3142b92f0
commit 74c37d49c4

View File

@ -413,6 +413,7 @@ typedef struct {
AsyncWaiter *waiter; AsyncWaiter *waiter;
guint log_handler_id; guint log_handler_id;
GString *warning_messages; GString *warning_messages;
GMainLoop *loop;
} TestCase; } TestCase;
static gboolean static gboolean
@ -483,10 +484,21 @@ test_case_new (void)
test->clients = g_hash_table_new (g_str_hash, g_str_equal); test->clients = g_hash_table_new (g_str_hash, g_str_equal);
test->waiter = async_waiter_new (); test->waiter = async_waiter_new ();
test->loop = g_main_loop_new (NULL, FALSE);
return test; return test;
} }
static gboolean
test_case_before_redraw (gpointer data)
{
TestCase *test = data;
g_main_loop_quit (test->loop);
return FALSE;
}
static gboolean static gboolean
test_case_wait (TestCase *test, test_case_wait (TestCase *test,
GError **error) GError **error)
@ -494,11 +506,30 @@ test_case_wait (TestCase *test,
GHashTableIter iter; GHashTableIter iter;
gpointer key, value; gpointer key, value;
/* First have each client set a XSync counter, and wait until
* we receive the resulting event - so we know we've received
* everything that the client have sent us.
*/
g_hash_table_iter_init (&iter, test->clients); g_hash_table_iter_init (&iter, test->clients);
while (g_hash_table_iter_next (&iter, &key, &value)) while (g_hash_table_iter_next (&iter, &key, &value))
if (!test_client_wait (value, error)) if (!test_client_wait (value, error))
return FALSE; return FALSE;
/* Then wait until we've done any outstanding queued up work.
* Though we add this as BEFORE_REDRAW, the iteration that runs the
* BEFORE_REDRAW idles will proceed on and do the redraw, so we're
* waiting until after *all* frame processing.
*/
meta_later_add (META_LATER_BEFORE_REDRAW,
test_case_before_redraw,
test,
NULL);
g_main_loop_run (test->loop);
/* Then set an XSync counter ourselves and and wait until
* we receive the resulting event - this makes sure that we've
* received back any X events we generated.
*/
async_waiter_set_and_wait (test->waiter); async_waiter_set_and_wait (test->waiter);
return TRUE; return TRUE;
} }