Re: g_test with mainloop integration?
- Date: Fri, 11 Jan 2008 13:19:02 +0100 (CET)
- From: Tim Janik <timj@xxxxxxxxxxx>
- Subject: Re: g_test with mainloop integration?
On Sun, 6 Jan 2008, Mikkel Kamstrup Erlandsen wrote:
> On 05/01/2008, Tim Janik <timj@xxxxxxx> wrote:
> test would look like the below pseudo code:
>
> ---------
>
> setup (fix) {
> fix->search = create_search_on_search_engine()
> }
>
> test_run (fix) {
> Hits hits;
>
> start_search(fix->search);
>
> // below call returns control back to the main loop until the
> // signal is emitted on fix->search and then magically writes
> // the signal arg into &hits
> wait_for_signal(fix->search, "hits-added", &hits);
> assert(hits->count > 0);
> }
>
> teardown (fix) {
> clean_up (fix);
> }
>
> main () {
> add_test_with_main_loop (setup, test_run, teardown);
> }
>
> ---------
>
> The two interesting calls are wait_for_signal() and add_test_with_main_loop().
>
> The wait_for_signal() method process the main loop until a signal is
> emitted on a given object - or maybe until a timeout is reached[1].
this can be done by running a main loop within wait_for_signal().
> The whole idea about that method is that it should be possible to
> write your tests without using callbacks. This will help make the
> tests more expressive and easily maintained.
>
> To flag that some test case should run in a main loop you use some
> special way of registering it. Like add_test_with_main_loop. There are
> a lot of open questions on that one... Fx:
> - Should all three functions, setup, test_run, and teardown, be run
> in the mainloop, or just test_run()
> - Should the mainloop process events in between calling the three functions?
i still fail to see why your main test function should run as part
of a main loop. (and in what way, idler/timer/io-driven, with what
priority, etc.)
> Cheers,
> Mikkel
---
ciaoTJ
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-devel-list