コード例 #1
0
void DAOLayerTest::updateTest()
{
    DAOLayer * daoLayer = DAOLayer::getInstance();
    CPPUNIT_ASSERT(daoLayer != NULL);

    int res;
    QList<Record *> * records = daoLayer->getRecords();
    int init = records->count();

    QList<SkeletonData*> * frames = new QList<SkeletonData*>();
    QList<Vector3> * jointures = new QList<Vector3>();
    Vector3 *vector = new Vector3();
    jointures->append(*vector);
    SkeletonData * skelData = new SkeletonData(jointures,1000);
    frames->append(skelData);
    Gesture * gesture = new Gesture(frames);
    Command * command = new Command("toto", KEYSTROKE);
    QList<Gesture *> * gestures = new QList<Gesture *>();
    gestures->append(gesture);
    Record * record = new Record("MyTestRecord2",gestures,command);
    record->setCommandActive(0);
    record->setId(1);
    res = daoLayer->updateRecord(record);
    CPPUNIT_ASSERT(res == 0);

    records = daoLayer->getRecords();
    init = records->count();
    Record  *rSave = NULL;
    for (int i = 0 ; i < init ; i++)
    {
        Record *r = records->at(i);
        if(r->getId() == 1)
        {
            rSave = r;
        }
    }

    CPPUNIT_ASSERT(rSave->getId() == 1);
    CPPUNIT_ASSERT(strcmp(rSave->getName(),"MyTestRecord2") == 0);
    command = rSave->getCommand();
    CPPUNIT_ASSERT(strcmp(command->getDefinition().toLocal8Bit().data(),"toto") == 0);
    CPPUNIT_ASSERT(command->getType() == KEYSTROKE );
    CPPUNIT_ASSERT(rSave->isCommandActive() == 0);
    CPPUNIT_ASSERT(rSave->isGestureActive() == 1);
    CPPUNIT_ASSERT(rSave->isDeleted() == 0);
    CPPUNIT_ASSERT(!rSave->getCreationDate().isEmpty());
    CPPUNIT_ASSERT(strcmp(DAOLayer::gesturesToChar(rSave->getGestures()),"1 1 1 1000 0 0 0 ") == 0);
    CPPUNIT_ASSERT(records->count() == init);
    CPPUNIT_ASSERT(daoLayer->updateRecord(NULL) == 1);
}
コード例 #2
0
void DAOLayerTest::getTest()
{
    DAOLayer * daoLayer = DAOLayer::getInstance();
    CPPUNIT_ASSERT(daoLayer != NULL);
    QList<Record *> * records = daoLayer->getRecords();
    int init = records->count();
    Record  *rSave = NULL;
    for (int i = 0 ; i < init ; i++)
    {
        Record *r = records->at(i);
        if(r->getId() == 1)
        {
            rSave = r;
        }
    }

    Record * singRec = daoLayer->getSingleRecord(1);
    CPPUNIT_ASSERT(singRec != NULL);
    CPPUNIT_ASSERT(singRec->getId() == 1);


    CPPUNIT_ASSERT(rSave->getId() == 1);
    CPPUNIT_ASSERT(strcmp(rSave->getName(),"MyTestRecord2") == 0);
    Command * command = rSave->getCommand();
    CPPUNIT_ASSERT(strcmp(command->getDefinition().toLocal8Bit().data(),"toto") == 0);
    CPPUNIT_ASSERT(command->getType() == KEYSTROKE );
    CPPUNIT_ASSERT(rSave->isCommandActive() == 0);
    CPPUNIT_ASSERT(rSave->isGestureActive() == 1);
    CPPUNIT_ASSERT(rSave->isDeleted() == 0);
    CPPUNIT_ASSERT(!rSave->getCreationDate().isEmpty());
    CPPUNIT_ASSERT(strcmp(DAOLayer::gesturesToChar(rSave->getGestures()),"1 1 1 1000 0 0 0 ") == 0);

    records = daoLayer->getRecords();
    CPPUNIT_ASSERT(records->count() == init);

    CPPUNIT_ASSERT(daoLayer->getSingleRecord(-1) == NULL);
}