Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7167041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:30:47+00:00 2026-05-28T14:30:47+00:00

This is the Class design for Device Discovery Library in the network using Bonjour.I

  • 0

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.

  1. Client Program need to implement IDeviceEnumerationCallback to receive Device Information

  2. 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??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:30:47+00:00Added an answer on May 28, 2026 at 2:30 pm

    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

    #include <gmock/gmock.h>
    class MockIDeviceEnumerationCallback : public IDeviceEnumerationCallback
    {
    public:
        MOCK_METHOD3(onDeviceDiscovered, void(DeviceInfo* pDeviceInfo,unsigned short nNoOfDevice,void* pContext));
    };
    

    and expect an call to the function using

    MockIDeviceEnumerationCallback mock;
    EXPECT_CALL(mock, onDeviceDiscovered(_, _, _))
        .WillOnce(Return(1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this php class ( http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php ) for creating the different sized images
I was reading up on singleton class design in C# on this great resource
I generated this class using SQLMetal.exe. It is very bindable at runtime, but if
I'm writing a parallel evolutionary algorithm library using C++, MPI and CUDA. I need
In class of this design: class X { X* left_; X* right_; X(const X&)
I'm using this class as my key to Hashmap with overriden hasCode() and equals()
For a policy-based class-design I need some of the policies to call functions that
I've seen this question: Class design with vector as a private/public member? , but
I was doing this design: How can I model this class in a database?
We are using OOP perl as a programming languge to design this framework, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.