Re: Writing tests for a UI app




On Feb 8, 2005, at 2:51 AM, ofey aikon wrote:

What is the typical approach towards writing tests for a UI app ?

Have a look at the test suite for Gtk2... for the most part we only have to make sure that the functions call correctly, as they're bindings, but often this requires testing that something happens or ensuring that an event loop runs.

We use Gtk2::TestHelper for that. It brings in some boilerplate ("use"ing Test::More for you, calling Gtk2->init for you, doing version checks for you) and defines a few convenience functions (run_main, ok_idle, is_idle) to make it easy to do tests that require a main loop but must not be interactive.



I would assume that the "correct" way to test this call-back is to
trigger the event programmatically on a specified treeview cell and
then test the arguments received ?

That's what i'd do.


But how do I trigger the event on a particular cell (without a user
clicking on that particular cell) ? I guess if I have a handle to the
CELL itself, I can use the $renderer->start_editing (,,,,,) call. But
I can't think of a way to get a handle to the CELL itself.

Remember, you don't ever actually get a handle to a single cell, only to a CellRenderer that has been set up with properties reflecting values of the currently-being-rendered row in the column to which the CellRenderer is attached.

Far easier than calling $renderer->start_editing is asking the view to set the cursor on a column & path and start editing it.

# if you have only one renderer per column
  $tree_view->set_cursor ($path, $focus_column, $start_editing)
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html#gtk-tree- view-set-cursor

# if you have more than one renderer per column (the general case, available since gtk+ 2.2) $tree_view->set_cursor_on_cell ($path, $focus_column, $focus_cell, $start_editing) http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html#gtk-tree- view-set-cursor-on-cell



--
muppet <scott at asofyet dot org>




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