void Chaser_Test::createCopy() { Doc doc(this); Chaser* c1 = new Chaser(m_doc); c1->setName("First"); c1->setFadeInSpeed(42); c1->setFadeOutSpeed(69); c1->setDuration(1337); c1->setDirection(Chaser::Backward); c1->setRunOrder(Chaser::SingleShot); c1->addStep(ChaserStep(20)); c1->addStep(ChaserStep(30)); c1->addStep(ChaserStep(40)); doc.addFunction(c1); QVERIFY(c1->id() != Function::invalidId()); Function* f = c1->createCopy(&doc); QVERIFY(f != NULL); QVERIFY(f != c1); QVERIFY(f->id() != c1->id()); Chaser* copy = qobject_cast<Chaser*> (f); QVERIFY(copy != NULL); QVERIFY(copy->fadeInSpeed() == 42); QVERIFY(copy->fadeOutSpeed() == 69); QVERIFY(copy->duration() == 1337); QVERIFY(copy->direction() == Chaser::Backward); QVERIFY(copy->runOrder() == Chaser::SingleShot); QVERIFY(copy->steps().size() == 3); QVERIFY(copy->steps().at(0) == ChaserStep(20)); QVERIFY(copy->steps().at(1) == ChaserStep(30)); QVERIFY(copy->steps().at(2) == ChaserStep(40)); }
void Chaser_Test::createCopy() { Doc doc(this, m_cache); Chaser* c1 = new Chaser(m_doc); c1->setName("First"); c1->setBus(15); c1->setDirection(Chaser::Backward); c1->setRunOrder(Chaser::SingleShot); c1->addStep(20); c1->addStep(30); c1->addStep(40); doc.addFunction(c1); QVERIFY(c1->id() != Function::invalidId()); Function* f = c1->createCopy(&doc); QVERIFY(f != NULL); QVERIFY(f != c1); QVERIFY(f->id() != c1->id()); Chaser* copy = qobject_cast<Chaser*> (f); QVERIFY(copy != NULL); QVERIFY(copy->busID() == 15); QVERIFY(copy->direction() == Chaser::Backward); QVERIFY(copy->runOrder() == Chaser::SingleShot); QVERIFY(copy->steps().size() == 3); QVERIFY(copy->steps().at(0) == 20); QVERIFY(copy->steps().at(1) == 30); QVERIFY(copy->steps().at(2) == 40); }
void VCCueList_Test::functionRemoved() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); cl.setChaser(c->id()); // Chaser members are removed from list m_doc->deleteFunction(c->steps().first().fid); QCOMPARE(cl.m_tree->topLevelItemCount(), 4); // deferred changes arrive afetr 100ms QTest::qWait(150); QCOMPARE(cl.m_tree->topLevelItemCount(), 3); QCOMPARE(cl.m_tree->topLevelItem(0)->text(0), QString("1")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(0), QString("2")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(0), QString("3")); QCOMPARE(cl.m_tree->topLevelItem(0)->text(1), QString("Second")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(1), QString("Third")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(1), QString("Fourth")); // Chaser is removed completely m_doc->deleteFunction(c->id()); QCOMPARE(cl.m_tree->topLevelItemCount(), 0); QCOMPARE(cl.chaserID(), Function::invalidId()); }
void Chaser_Test::armMissingFunction() { Doc* doc = new Doc(this, m_cache); Fixture* fxi = new Fixture(doc); fxi->setName("Test Fixture"); 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(123); // Nonexistent function c->addStep(s2->id()); c->addStep(55); // Nonexistent function QVERIFY(c->steps().size() == 4); c->arm(); QVERIFY(c->steps().size() == 2); // Nonexistent functions are removed delete doc; }
void Chaser_Test::armSuccess() { Doc* doc = new Doc(this, m_cache); Fixture* fxi = new Fixture(doc); fxi->setName("Test Fixture"); 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); QVERIFY(s1->id() != Function::invalidId()); Scene* s2 = new Scene(doc); s2->setName("Scene2"); s2->setValue(fxi->id(), 0, 0); s2->setValue(fxi->id(), 1, 0); doc->addFunction(s2); QVERIFY(s2->id() != Function::invalidId()); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->addStep(s1->id()); c->addStep(s2->id()); QVERIFY(c->steps().size() == 2); c->arm(); QVERIFY(c->steps().size() == 2); delete doc; }
void VCCueList_Test::chaser() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); // Try to put a non-chaser as the chaser cl.setChaser(c->steps().first().fid); QCOMPARE(cl.chaserID(), Function::invalidId()); QCOMPARE(cl.m_tree->topLevelItemCount(), 0); // Put a real chaser as the chaser cl.setChaser(c->id()); QCOMPARE(cl.chaserID(), c->id()); QCOMPARE(cl.m_tree->topLevelItemCount(), 4); QCOMPARE(cl.m_tree->topLevelItem(0)->text(0), QString("1")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(0), QString("2")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(0), QString("3")); QCOMPARE(cl.m_tree->topLevelItem(3)->text(0), QString("4")); QCOMPARE(cl.m_tree->topLevelItem(0)->text(1), QString("First")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(1), QString("Second")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(1), QString("Third")); QCOMPARE(cl.m_tree->topLevelItem(3)->text(1), QString("Fourth")); }
void VCCueList_Test::manualActivation() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); c->setDuration(Function::infiniteSpeed()); cl.setChaser(c->id()); Scene* s1 = qobject_cast<Scene*> (m_doc->function(c->steps()[0].fid)); //Scene* s2 = qobject_cast<Scene*> (m_doc->function(c->steps()[1].fid)); Scene* s3 = qobject_cast<Scene*> (m_doc->function(c->steps()[2].fid)); //Scene* s4 = qobject_cast<Scene*> (m_doc->function(c->steps()[3].fid)); Q_ASSERT(s1 /*&& s2*/ && s3/* && s4*/); // Switch mode m_doc->setMode(Doc::Operate); MasterTimer* timer = m_doc->masterTimer(); // QVERIFY(cl.m_runner == NULL); cl.slotItemActivated(cl.m_tree->topLevelItem(2)); // QVERIFY(cl.m_runner != NULL); timer->timerTick(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); // Same item cl.slotItemActivated(cl.m_tree->topLevelItem(2)); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); // Another item cl.slotItemActivated(cl.m_tree->topLevelItem(0)); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); // Crash check cl.slotItemActivated(NULL); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); }
void VCCueList_Test::nextPrevious() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); c->setDuration(Function::infiniteSpeed()); cl.setChaser(c->id()); QCOMPARE(c->steps().size(), 4); Scene* s1 = qobject_cast<Scene*> (m_doc->function(c->steps()[0].fid)); Scene* s2 = qobject_cast<Scene*> (m_doc->function(c->steps()[1].fid)); Scene* s3 = qobject_cast<Scene*> (m_doc->function(c->steps()[2].fid)); Scene* s4 = qobject_cast<Scene*> (m_doc->function(c->steps()[3].fid)); Q_ASSERT(s1 && s2 && s3 && s4); // Not in operate mode, check for crashes cl.slotNextCue(); cl.slotPreviousCue(); cl.slotItemActivated(cl.m_tree->topLevelItem(2)); // QVERIFY(cl.m_runner == NULL); // Switch mode m_doc->setMode(Doc::Operate); MasterTimer* timer = m_doc->masterTimer(); // Create runner with a next action -> first item should be activated cl.slotNextCue(); // QVERIFY(cl.m_runner != NULL); timer->timerTick(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); cl.slotNextCue(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s2); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s2); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s2); cl.slotNextCue(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s3); cl.slotPreviousCue(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s2); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s2); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s2); cl.slotPreviousCue(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); // Wrap around to the last cue cl.slotPreviousCue(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s4); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s4); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s4); // Wrap around to the next cue cl.slotNextCue(); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); timer->timerTick(); QCOMPARE(timer->runningFunctions(), 2); QCOMPARE(timer->m_functionList[1], s1); }