示例#1
0
void ActiveObjectTest::restartTest()
{
    TestObject test;
    // First start
    test.start();
    QVERIFY( test.isStarted() );

    // Wait for a while (it takes some time for a thread to start).
    std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
    while (std::chrono::system_clock::now() - start < std::chrono::milliseconds(100) );

    test.stop();
    QVERIFY( !test.isStarted() );
    QVERIFY( test.actionCalled() );

    // Restart
    test.reset();
    test.start();
    QVERIFY( test.isStarted() );

    // Wait for a while (it takes some time for a thread to start).
    start = std::chrono::system_clock::now();
    while (std::chrono::system_clock::now() - start < std::chrono::milliseconds(100) );

    test.stop();
    QVERIFY( !test.isStarted() );
    QVERIFY( test.actionCalled() );

}
示例#2
0
void ActiveObjectTest::constructorTest()
{
    TestObject test;
    QVERIFY2 (!test.isStarted(),
              "Constructed object is started at construction");
}