Re: RFC: Gtk+ testing utilities



On Fri, 16 Nov 2007, Tommi Komulainen wrote:

Some quick and random comments that come to mind...

/* syncronize rendering operations with X server rendering queue */
void            gtk_test_xserver_render_sync    (GdkWindow      *window);

/* synthesize and send key press or release event */
gboolean        gtk_test_simulate_key           (GdkWindow      *window,

/* synthesize and send button press or release event */
gboolean        gtk_test_simulate_button        (GdkWindow      *window,

Shouldn't the above be named gdk_test or take GtkWidget as parameter?

hmm, strictly speacking, you could argue for creating gdktestutils.h in gdk
and moving this there, yes. i wasn't sure opening up the gdk_test namespace
is really worth the hassle, but considering that we'd hopefully extend Gdk
tests and test utils in the future, your change would probably be for the
better.

  while (gtk_events_pending ())
    gtk_main_iteration ();

The test examples had quite a few of these, adding noise.

not sure what you mean with "adding noise"?

Most of them
were related to spin buttons, so I suppose in general tests shouldn't
have many of these? Would it make sense to flush the events in
gtk_test_spin_button_click instead, for example?

if you do GUI interaction tests with an X server, you'll not be able to
avoid processing events from within your test programs.
here's a simplified example:

  button = create_button();
  gtk_widget_show_now (button);
  /* the above calls the main loop recursively until button is visible */

  /* button is now mapped on screen */
  gtk_test_widget_click (button, 1, 0);
  /* button click events are in the outgoing queue */
  gdk_flush(); /* force sending of button events to x server now */

  g_assert (button_clicked_callback_called == TRUE);
  /* assertion fails, because button events weren't received by the app yet */

  while (gtk_events_pending ()) /* receive x events (button clicks) */
    gtk_main_iteration ();      /* handle x events (call clicked callback */
  g_assert (button_clicked_callback_called == TRUE);
  /* assertion passes, because main loop handled button clicks now */

on top of that, the spin button code sets up its own asyncronous
main loop handlers to process event updates. so there's no way
around intermediate recursive main loop invocations to verify GUI
interaction logic. also gdk_flush() is not a suitable replacement
as it only sends events, but doesn't cause the application to
receive and process GUI events.

Tommi Komulainen                            <tommi komulainen nokia com>

---
ciaoTJ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]