Changeset 12763 for tests


Ignore:
Timestamp:
Mar 13, 2014, 7:30:17 PM (11 years ago)
Author:
hock@…
Message:

priority queue (but not tested)

--> FIXME in SystemEvent.h (has to be fixed first!)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/SystemQueue-tests.cc

    r12762 r12763  
    9292    void Check()
    9393    {
    94         // XXX
    9594        cout << "### Check ### "<< endl;
    9695
    9796        checkmark = true;
    9897    }
    99    
     98
     99    void Cancel()
     100    {
     101        cout << "### Cancel ### "<< endl;
     102
     103        SystemQueue::instance().cancel();
     104        checkmark = true;
     105    }
     106
    100107    void LongRunner()
    101108    {
     
    163170
    164171/**
     172 *  Enqueues an event but then cancels the SystemQueue without running
     173 */
     174TEST_F(SystemQueueTest, EmptyAfterCancel)
     175{
     176    SystemQueue& sysq = SystemQueue::instance();
     177
     178    EXPECT_TRUE( sysq.isEmpty() );
     179   
     180    // enqueue event
     181    sysq.scheduleCall(
     182        boost::bind(&SystemQueueTest::Check, this)
     183    );
     184   
     185    EXPECT_FALSE( sysq.isEmpty() );
     186   
     187    // cancel
     188    sysq.cancel();
     189   
     190    EXPECT_TRUE( sysq.isEmpty() );
     191}
     192
     193
     194/**
     195 *  cancels the SystemQueue from inside a scheduled event
     196 */
     197TEST_F(SystemQueueTest, CancelFromInsideEvent)
     198{
     199    SystemQueue& sysq = SystemQueue::instance();
     200    checkmark = false;  // just to be sure..
     201   
     202    // start
     203    sysq.run();
     204   
     205    // scheduleCall
     206    sysq.scheduleCall(
     207        boost::bind(&SystemQueueTest::Cancel, this)
     208    );
     209
     210    // wait for the event to happen
     211    wait_for_checkmark(MAX_WAIT);
     212
     213    EXPECT_FALSE( sysq.isRunning() ) << "SystemQueue has not stopped properly.";
     214    EXPECT_TRUE( sysq.isEmpty() ) << "SystemQueue has not stopped properly.";
     215}
     216
     217
     218/**
    165219 *  schedule a call and test whether it is actually performed by the SystemQueue
    166220 */
Note: See TracChangeset for help on using the changeset viewer.