Re: [Vala] How to test async methods?
- From: Felipe Lavratti <felipelav gmail com>
- To: "marcin saepia net" <marcin saepia net>
- Cc: vala <vala-list gnome org>
- Subject: Re: [Vala] How to test async methods?
- Date: Tue, 16 Feb 2016 11:26:38 -0200
This is how I am doing, it is not with async mechanism itself, but it
shows how I use MainLoop in testing. I have to ask it to `quit` in
order to unblock.
public void test_line_receive () {
bool called = false;
var loop = new MainLoop ();
var process = new TestFileProcess ();
var cut = new AsyncChannel (process);
cut.on_line_received.connect ((line) => {
called = true;
assert (line == "this is the full line received.");
loop.quit ();
});
process.file.write ("this is the full line received.".data);
process.file.flush ();
loop.run ();
assert (called == true);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]