Ignore:
Timestamp:
Mar 7, 2014, 7:08:35 PM (11 years ago)
Author:
hock@…
Message:

TEST_F(SystemQueueTimingTest, DelayedCall)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/SystemQueue-tests.cc

    r12751 r12752  
    267267public:
    268268   
     269/**
     270 *  typical delay time
     271 *
     272 *  should be long enough for meaningful tests,
     273 *  but should not lengthen the test excessivly
     274 */
     275#define DELAY_TIME 10  // ms
     276#define DELAY_MARGIN 1000  // microseconds (1/1000 ms)
     277   
    269278};
    270279
    271280
    272 TEST_F(SystemQueueTimingTest, MultipleCalls)  /* TODO different name..? */
    273 {
    274    
    275 }
    276 
     281/**
     282 *  schedules a delayed call and tests whether it is called (more or less timely..)
     283 */
     284TEST_F(SystemQueueTimingTest, DelayedCall)
     285{
     286    SystemQueue& sysq = SystemQueue::instance();
     287    checkmark = false;  // just to be sure..
     288   
     289    // start
     290    sysq.run();
     291   
     292    // scheduleCall
     293    sysq.scheduleCall(
     294        boost::bind(&SystemQueueTest::Check, this), DELAY_TIME
     295    );
     296
     297    // noting to do until the delay is up..
     298    usleep(DELAY_TIME + DELAY_MARGIN);
     299   
     300    // wait for the event to happen
     301    wait_for_checkmark(MAX_WAIT);
     302   
     303    // stop
     304    sysq.cancel();
     305   
     306    EXPECT_TRUE( checkmark ) << "Deleyed function was not called within delaytime ("
     307        << DELAY_TIME << " ms) + " << (MAX_WAIT + DELAY_MARGIN) << " microseconds.";
     308}
     309
Note: See TracChangeset for help on using the changeset viewer.