Example #1
0
void Chaser_Test::writeBusZeroLoopBackward()
{
    Doc* doc = new Doc(this, m_cache);

    Bus::instance()->setValue(Bus::defaultFade(), 0);
    Bus::instance()->setValue(Bus::defaultHold(), 0);

    Fixture* fxi = new Fixture(doc);
    fxi->setAddress(0);
    fxi->setUniverse(0);
    fxi->setChannels(2);
    doc->addFixture(fxi);

    Scene* s1 = new Scene(doc);
    s1->setName("Scene1");
    s1->setValue(fxi->id(), 0, UCHAR_MAX);
    s1->setValue(fxi->id(), 1, UCHAR_MAX);
    doc->addFunction(s1);

    Scene* s2 = new Scene(doc);
    s2->setName("Scene2");
    s2->setValue(fxi->id(), 0, 0);
    s2->setValue(fxi->id(), 1, 0);
    doc->addFunction(s2);

    Chaser* c = new Chaser(doc);
    c->setName("Chaser");
    c->setDirection(Chaser::Backward);
    c->addStep(s1->id());
    c->addStep(s2->id());

    s1->arm();
    s2->arm();
    c->arm();

    UniverseArray uni(1);
    MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni);

    QVERIFY(c->stopped() == true);
    mts->startFunction(c, true);
    QVERIFY(c->stopped() == false);

    /* Since hold bus' value is 0 each call to write() starts the next
       step in chaser. Last step comes first because the chaser is now
       running backwards. */
    c->write(mts, &uni);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s2);
    QVERIFY(s2->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s2->stopped() == true);
    mts->stopFunction(s2);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s1);
    QVERIFY(s1->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s1->stopped() == true);
    mts->stopFunction(s1);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s2);
    QVERIFY(s2->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s2->stopped() == true);
    mts->stopFunction(s2);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s1);
    QVERIFY(s1->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s1->stopped() == true);
    mts->stopFunction(s1);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s2);
    QVERIFY(s2->stopped() == false);

    c->stop();
    mts->stopFunction(c);
    QVERIFY(c->stopped() == true);
    QVERIFY(s1->stopped() == true);
    QVERIFY(s2->stopped() == true);

    c->disarm();
    s1->disarm();
    s2->disarm();

    delete mts;
    delete doc;
}
Example #2
0
void Chaser_Test::writeBusZeroSingleShotBackward()
{
    Doc* doc = new Doc(this, m_cache);

    Bus::instance()->setValue(Bus::defaultFade(), 0);
    Bus::instance()->setValue(Bus::defaultHold(), 0);

    Fixture* fxi = new Fixture(doc);
    fxi->setAddress(0);
    fxi->setUniverse(0);
    fxi->setChannels(2);
    doc->addFixture(fxi);

    Scene* s1 = new Scene(doc);
    s1->setName("Scene1");
    s1->setValue(fxi->id(), 0, UCHAR_MAX);
    s1->setValue(fxi->id(), 1, UCHAR_MAX);
    doc->addFunction(s1);

    Scene* s2 = new Scene(doc);
    s2->setName("Scene2");
    s2->setValue(fxi->id(), 0, 0);
    s2->setValue(fxi->id(), 1, 0);
    doc->addFunction(s2);

    Chaser* c = new Chaser(doc);
    c->setName("Chaser");
    c->setRunOrder(Chaser::SingleShot);
    c->setDirection(Chaser::Backward);
    c->addStep(s1->id());
    c->addStep(s2->id());

    s1->arm();
    s2->arm();
    c->arm();

    UniverseArray uni(1);
    MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni);

    QVERIFY(c->stopped() == true);
    mts->startFunction(c, true);
    QVERIFY(c->stopped() == false);

    /* SingleShot will stop automatically after the last step */
    c->write(mts, &uni);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s2);
    QVERIFY(s2->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s2->stopped() == true);
    mts->stopFunction(s2);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s1);
    QVERIFY(s1->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(c->stopped() == true);
    mts->stopFunction(c);
    QVERIFY(s1->stopped() == true);
    QVERIFY(s2->stopped() == true);

    c->disarm();
    s1->disarm();
    s2->disarm();

    delete mts;
    delete doc;
}
Example #3
0
void Chaser_Test::writeBusZeroLoopForward()
{
    Doc* doc = new Doc(this, m_cache);

    Bus::instance()->setValue(Bus::defaultFade(), 0);
    Bus::instance()->setValue(Bus::defaultHold(), 0);

    Fixture* fxi = new Fixture(doc);
    fxi->setAddress(0);
    fxi->setUniverse(0);
    fxi->setChannels(2);
    doc->addFixture(fxi);

    Scene* s1 = new Scene(doc);
    s1->setName("Scene1");
    s1->setValue(fxi->id(), 0, UCHAR_MAX);
    s1->setValue(fxi->id(), 1, UCHAR_MAX);
    doc->addFunction(s1);

    Scene* s2 = new Scene(doc);
    s2->setName("Scene2");
    s2->setValue(fxi->id(), 0, 0);
    s2->setValue(fxi->id(), 1, 0);
    doc->addFunction(s2);

    Chaser* c = new Chaser(doc);
    c->setName("Chaser");
    c->addStep(s1->id());
    c->addStep(s2->id());

    s1->arm();
    s2->arm();
    c->arm();

    UniverseArray uni(1);
    MasterTimerStub* mts = new MasterTimerStub(this, NULL, uni);

    QVERIFY(c->stopped() == true);
    mts->startFunction(c, true);
    QVERIFY(c->stopped() == false);

    /* Since hold bus' value is 0 each call to write() starts the next
       step in chaser. The functions must be manually removed from the
       stub, which is OK (we're not testing the timer now), as long as
       the correct step is always marked as stopped. */
    c->write(mts, &uni);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s1);
    QVERIFY(s1->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s1->stopped() == true);
    mts->stopFunction(s1);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s2);
    QVERIFY(s2->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s2->stopped() == true);
    mts->stopFunction(s2);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s1);
    QVERIFY(s1->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s1->stopped() == true);
    mts->stopFunction(s1);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s2);
    QVERIFY(s2->stopped() == false);

    c->write(mts, &uni);
    QVERIFY(s2->stopped() == true);
    mts->stopFunction(s2);
    QVERIFY(c->stopped() == false);
    QVERIFY(mts->m_functionList.size() == 2);
    QVERIFY(mts->m_functionList[0] == c);
    QVERIFY(mts->m_functionList[1] == s1);
    QVERIFY(s1->stopped() == false);

    c->stop();
    mts->stopFunction(c);
    QVERIFY(c->stopped() == true);
    QVERIFY(s1->stopped() == true);
    QVERIFY(s2->stopped() == true);

    c->disarm();
    s1->disarm();
    s2->disarm();

    delete mts;
    delete doc;
}