Changeset 12749


Ignore:
Timestamp:
Mar 5, 2014, 7:55:12 PM (10 years ago)
Author:
hock@…
Message:

first test that actually runs the SystemQueue

(but a FIXME is still open..)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/SystemQueue-tests.cc

    r12748 r12749  
    22#include "ariba/utility/system/SystemQueue.h"
    33
     4#include <ostream>
     5
    46using namespace ::testing;
    57using namespace ariba::utility;
    6 
     8using namespace std;
    79
    810/**
     
    1214{
    1315    SystemQueue& sysq = SystemQueue::instance();
     16   
     17//     cout << &sysq << endl;
    1418   
    1519    EXPECT_FALSE( sysq.isRunning() );
     
    3034
    3135//     cout << &sysq << endl;
    32     ASSERT_TRUE( &sysq == &sysq2 );
     36   
     37    EXPECT_TRUE( &sysq == &sysq2 );
    3338}
    3439
    3540
     41/**
     42 *  Start and stop the SystemQueue
     43 */
     44TEST(SystemQueue, StartStop)
     45{
     46    SystemQueue& sysq = SystemQueue::instance();
     47
     48    EXPECT_FALSE( sysq.isRunning() );
     49   
     50    // start
     51    sysq.run();
     52   
     53    EXPECT_TRUE( sysq.isRunning() );
     54   
     55    // stop
     56    sysq.cancel();
     57   
     58    EXPECT_FALSE( sysq.isRunning() );
     59}
     60
     61
     62/**
     63 *  Test fixture
     64 *
     65 *  class that can be called by the SystemQueue
     66 */
     67// To use a test fixture, derive a class from testing::Test.
     68class SystemQueueTest :
     69        public testing::Test
     70{
     71public:
     72
     73    SystemQueueTest() :
     74        checkmark(false)
     75    {
     76    }
     77       
     78    void Check()
     79    {
     80        checkmark = true;
     81//         cout << "Hallo Mario ^^" << endl;
     82    }
     83
     84    bool checkmark;
     85};
     86
     87TEST_F(SystemQueueTest, ScheduleCall)
     88{
     89    SystemQueue& sysq = SystemQueue::instance();
     90    checkmark = false;  // just to be sure..
     91   
     92    // start
     93    sysq.run();
     94   
     95    // scheduleCall
     96    sysq.scheduleCall(
     97        boost::bind(&SystemQueueTest::Check, this)
     98    );
     99
     100    // FIXME: yes, we have to wait a while here...
     101    //   maybe write a function (in the fixture): wait_for_remaining_events(int max_millisecs)
     102   
     103    // stop
     104    sysq.cancel();
     105   
     106    EXPECT_TRUE( checkmark );
     107   
     108    /* NOTE: If this fails, maybe we'll have to wait a bit..?
     109     *   There should be a possibility to cancel the SystemQueue as soon as it's empty..
     110     */
     111}
     112
Note: See TracChangeset for help on using the changeset viewer.