This is the Class design for Device Discovery Library in the network using Bonjour.I need to develop Test case for it using GTest.I am new to GTEst.
-
Client Program need to implement IDeviceEnumerationCallback to receive Device Information
-
Callback will be called after Interval time and frequency
Say Interval is 200 ms and frequency is 2. it will call the two times callback after 200 ms.class IDeviceEnumerationCallback { public: /* This callback is called when Device are Enumerated and is regsitered in EnumerateWiFiDevice method */ virtual void onDeviceDiscovered( DeviceInfo* pDeviceInfo,unsigned short nNoOfDevice,void* pContext) = 0; }; IDeviceDiscovery { virtual int InitialiseDeviceDiscovery(IDeviceEnumerationCallback*) = 0; virtual void UnInitialiseDeviceDiscovery() = 0; virtual int EnumerateDevice() = 0; virtual void SetDiscoveryInterval(unsigned long nDiscoveryInterval); virtual void SetDiscoveryFrequency(unsigned short nFrequency); virtual unsigned long GettDiscoveryInterval(); virtual unsigned short GettDiscoveryFrequency(); } class CDeviceDiscovery : public IDeviceDiscovery { // implemenation }
When I Develop Unit Test for EnumerateDevice() It will return immediately Saying -1 or 1.But the result will be returned in the callback.How to Know Whether Device is enumerated properly or not using GTest.
Do I require GTest Mock Here??
You could use Gmock for this. A good explanation can be found on this page:
http://code.google.com/p/googlemock/wiki/ForDummies
You would mock IDeviceEnumerationCallback
and expect an call to the function using