--
You received this message because you are subscribed to the Google Groups "cpputest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpputest+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "cpputest" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cpputest/8z51XVSopsE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cpputest+u...@googlegroups.com.
Basically we have a CallAnswerer that monitors a object that only purpose is to notify that a new call is available, when the event happens (the signal) on my callbacks i will handle the events and do all the required stuff (what i want to test).
Usually the DBus method calls are mocked so i can just check if the methods are being called correctly on the right moment, but the event of a new call being received could trigger other events (like monitoring the call proxy to do something when the call is terminated).
As you can see that is no need at all to make the callbacks functions public, the client code of the CallAnswerer is not interested on then.Since i don't have DBus on the unit tests i mock the call_new_for_bus and call_new_for_bus_finish, but then my problem with callbacks started :-).
On Oct 23, 2013, at 8:58 AM, Tiago Katcipis <katc...@inf.ufsc.br> wrote:Basically we have a CallAnswerer that monitors a object that only purpose is to notify that a new call is available, when the event happens (the signal) on my callbacks i will handle the events and do all the required stuff (what i want to test).
Usually the DBus method calls are mocked so i can just check if the methods are being called correctly on the right moment, but the event of a new call being received could trigger other events (like monitoring the call proxy to do something when the call is terminated).
As you can see that is no need at all to make the callbacks functions public, the client code of the CallAnswerer is not interested on then.Since i don't have DBus on the unit tests i mock the call_new_for_bus and call_new_for_bus_finish, but then my problem with callbacks started :-).
It seems that your test-doubles for the DBus can capture and expose the callback function pointers so your test can call them. Also the test-doubles themselves can call them.
The later is what my article series shows.
The "how" to capture and expose the callback was my original question, it seems that a good way is to use the setData and getData, using the name of the function as a scope for the mock, like:
mock("my_function").setData("callback", callback);
GCallback callback = mock("my_function").getData("callback");
Letting the double call the callback seems to avoid some duplication on most cases, may it will be better.
The later is what my article series shows.
I will take a look at it.
Thanks for the help James.
It is a bit off topic, but i feel compelled to say that Test Driven Development for Embedded C is totally awesome and changed the way i develop in C, thanks for that too :-).
[...] This article series may be similar to what you need, though it uses the fake function framework. http://www.renaissancesoftware.net/blog/?s=rtos&submit=Search
On Oct 23, 2013, at 12:50 PM, Tiago Katcipis <tiagok...@gmail.com> wrote:
The "how" to capture and expose the callback was my original question, it seems that a good way is to use the setData and getData, using the name of the function as a scope for the mock, like:You can just save them in a global variable or data structure and access them directly or via a getter function. You have the full power of the C language at your disposal. You do not have to involve CppUMock. In the article, see the custom_fake. That is part of the fake function framework, but you can do the same thing in your stubs.