Example #1
0
void
TestSqlTrack::testSetAllValuesBatch()
{
    {
        Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" );
        Meta::SqlTrack *sqlTrack1 = static_cast<Meta::SqlTrack*>( track1.data() );

        QSignalSpy spy( m_collection, SIGNAL(updated()));
        MetaNotificationSpy metaSpy;
        metaSpy.subscribeTo( track1 );

        sqlTrack1->beginUpdate();

        setAllValues( sqlTrack1 );
        QCOMPARE( metaSpy.notificationsFromTracks().count(), 1 ); // add label does one notify

        sqlTrack1->endUpdate();
        QCOMPARE( metaSpy.notificationsFromTracks().count(), 2 ); // only one notificate for all the changes

        getAllValues( sqlTrack1 );
    }

    // and also after empty cache
    m_collection->registry()->emptyCache();

    {
        Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" );
        Meta::SqlTrack *sqlTrack1 = static_cast<Meta::SqlTrack*>( track1.data() );
        QVERIFY( track1 );
        getAllValues( sqlTrack1 );
    }
}
Example #2
0
void
TestSqlTrack::testSetAllValuesSingleNotExisting()
{
    {
        // get a new track
        Meta::TrackPtr track1 = m_collection->registry()->getTrack( -1, "./IamANewTrack.mp3", 1, "1e34fb213489" );

        QSignalSpy spy( m_collection, SIGNAL(updated()));
        MetaNotificationSpy metaSpy;
        metaSpy.subscribeTo( track1 );

        Meta::SqlTrack *sqlTrack1 = static_cast<Meta::SqlTrack*>( track1.data() );
        setAllValues( sqlTrack1 );
        getAllValues( sqlTrack1 );

        // new track should have an up-to-date create time (not more than 3 seconds old)
        QVERIFY( track1->createDate().secsTo(QDateTime::currentDateTime()) < 3 );

        QVERIFY( metaSpy.notificationsFromTracks().count() > 1 ); // we should be notified about the changes
    }

    // and also after empty cache
    m_collection->registry()->emptyCache();

    {
        Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" );
        Meta::SqlTrack *sqlTrack1 = static_cast<Meta::SqlTrack*>( track1.data() );
        QVERIFY( track1 );
        getAllValues( sqlTrack1 );
    }
}
Example #3
0
/** Set all track values but before that create them in the registry. */
void
TestSqlTrack::testSetAllValuesSingleExisting()
{
    {
        Meta::GenrePtr    genre    = m_collection->registry()->getGenre( "New Genre" );
        Meta::ComposerPtr composer = m_collection->registry()->getComposer( "New Composer" );
        Meta::YearPtr     year     = m_collection->registry()->getYear( 1999 );
        Meta::AlbumPtr    album    = m_collection->registry()->getAlbum( "New Album", "New Artist" );
        m_collection->registry()->getLabel( "New Label" );

        Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/IDoNotExist.mp3" );

        Meta::SqlTrack *sqlTrack1 = static_cast<Meta::SqlTrack*>( track1.data() );
        setAllValues( sqlTrack1 );
        getAllValues( sqlTrack1 );

        // check that the existing object are really updated with the new tracklist
        QCOMPARE( genre->tracks().count(), 1 );
        QCOMPARE( genre->tracks().first().data(), track1.data() );

        QCOMPARE( composer->tracks().count(), 1 );
        QCOMPARE( composer->tracks().first().data(), track1.data() );

        QCOMPARE( year->tracks().count(), 1 );
        QCOMPARE( year->tracks().first().data(), track1.data() );

        // the logic, how renaming the track artist influences its album is still
        // unfinished. For sure the track must be in an album with the defined
        // name
        QCOMPARE( sqlTrack1->album()->name(), QString("New Album") );
        QCOMPARE( sqlTrack1->album()->tracks().count(), 1 );
        QCOMPARE( sqlTrack1->album()->tracks().first().data(), track1.data() );
    }

    // and also after empty cache
    m_collection->registry()->emptyCache();

    {
        Meta::TrackPtr track1 = m_collection->registry()->getTrack( "/new_url" );
        Meta::SqlTrack *sqlTrack1 = static_cast<Meta::SqlTrack*>( track1.data() );
        QVERIFY( track1 );
        getAllValues( sqlTrack1 );

        Meta::GenrePtr    genre    = m_collection->registry()->getGenre( "New Genre" );
        Meta::ComposerPtr composer = m_collection->registry()->getComposer( "New Composer" );
        Meta::YearPtr     year     = m_collection->registry()->getYear( 1999 );
        Meta::AlbumPtr    album    = m_collection->registry()->getAlbum( "New Album", "New Artist" );

        // check that the existing object are really updated with the new tracklist
        QCOMPARE( genre->tracks().count(), 1 );
        QCOMPARE( genre->tracks().first().data(), track1.data() );

        QCOMPARE( composer->tracks().count(), 1 );
        QCOMPARE( composer->tracks().first().data(), track1.data() );

        QCOMPARE( year->tracks().count(), 1 );
        QCOMPARE( year->tracks().first().data(), track1.data() );

        // the logic, how renaming the track artist influences its album is still
        // unfinished. For sure the track must be in an album with the defined
        // name
        QCOMPARE( sqlTrack1->album()->name(), QString("New Album") );
        QCOMPARE( sqlTrack1->album()->tracks().count(), 1 );
        QCOMPARE( sqlTrack1->album()->tracks().first().data(), track1.data() );
    }
}
Example #4
0
void CHolonomicPathNode::interpolate(CHolonomicPathNode* from, float t, float angularCoeff) {
  float vect[7];

  if (_nodeType == sim_holonomicpathplanning_xy) {
    vect[0] = values[0] - from->values[0];
    vect[1] = values[1] - from->values[1];

    float l = sqrtf(vect[0] * vect[0] + vect[1] * vect[1]);
    float bound = t / l;

    values[0] = vect[0] * bound + from->values[0];
    values[1] = vect[1] * bound + from->values[1];
  } else if (_nodeType == sim_holonomicpathplanning_xyz) {
    vect[0] = values[0] - from->values[0];
    vect[1] = values[1] - from->values[1];
    vect[2] = values[2] - from->values[2];

    float l = sqrtf(vect[0] * vect[0] + vect[1] * vect[1] + vect[2] * vect[2]);
    float bound = t / l;
/*
    values[0] = vect[0] * bound + from->values[0];
    values[1] = vect[1] * bound + from->values[1];
    values[2] = vect[2] * bound + from->values[2];
    */
    for (int i = 0; i < 3; i++) {
      values[i] = from->values[i] * (1.0 - bound) + values[i] * bound;
    }
  } else if (_nodeType == sim_holonomicpathplanning_xyg) {
    vect[0] = values[0] - from->values[0];
    vect[1] = values[1] - from->values[1];
    vect[2] = CPathPlanningInterface::getNormalizedAngle(values[2] - from->values[2]);

    float l = vect[0] * vect[0] + vect[1] * vect[1];
    l = sqrtf(l + vect[2] * angularCoeff * vect[2] * angularCoeff);
    float bound = t / l;

    values[0] = vect[0] * bound + from->values[0];
    values[1] = vect[1] * bound + from->values[1];
    values[2] = CPathPlanningInterface::getNormalizedAngle(
          vect[2] * bound + from->values[2]);
  } else if (_nodeType == sim_holonomicpathplanning_xyzabg) {
    vect[0] = values[0] - from->values[0];
    vect[1] = values[1] - from->values[1];
    vect[2] = values[2] - from->values[2];
    C4Vector toP, fromP;
    C3Vector dum;
    getAllValues(dum, toP);
    from->getAllValues(dum, fromP);
    C4Vector diff(fromP.getInverse()*toP);
    vect[3] = diff(0);
    vect[4] = diff(1);
    vect[5] = diff(2);
    vect[6] = diff(3);

    float ap = angularCoeff * fromP.getAngleBetweenQuaternions(toP);
    float l = vect[0] * vect[0] + vect[1] * vect[1] + vect[2] * vect[2];
    l = sqrtf(l + ap * ap);
    float bound = t / l;

    values[0] = vect[0] * bound + from->values[0];
    values[1] = vect[1] * bound + from->values[1];
    values[2] = vect[2] * bound + from->values[2];
    C4Vector q;
    q.setIdentity();
    fromP.buildInterpolation(q, diff, bound);
    values[3] = fromP(0);
    values[4] = fromP(1);
    values[5] = fromP(2);
    values[6] = fromP(3);
  }
}
Example #5
0
static void testConversions() {
	DataValue value;
	bool boolean;
	int8_t int8;
	uint8_t uint8;
	int16_t int16;
	uint16_t uint16;
	int32_t int32;
	uint32_t uint32;
	int64_t int64;
	uint64_t uint64;
	float float32;
	double float64;
	fixed16_16 fixed;
	void * pointer;
	const char * string;
	const void * blob;
	HashTable * hashTable;
	DataArray * array;
	AssociativeArray * assArray;
	
	value = valueCreateBoolean(false);
	getAllValues(value);
	assertAllTypes(0, 0, 0.0, 0x00000, NULL);
	value = valueCreateBoolean(true);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateInt8(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateInt8(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateUInt8(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateUInt8(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateInt16(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateInt16(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateUInt16(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateUInt16(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateInt32(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateInt32(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateUInt32(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateUInt32(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateInt64(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateInt64(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateUInt64(0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateUInt64(1);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	
	value = valueCreateFloat(0.0f);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateFloat(1.0f);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	value = valueCreateFloat(1.25f);
	getAllValues(value);
	assertAllTypes(true, 1, 1.25, 0x14000, NULL);
	
	value = valueCreateDouble(0.0);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateDouble(1.0);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	value = valueCreateDouble(1.25);
	getAllValues(value);
	assertAllTypes(true, 1, 1.25, 0x14000, NULL);
	
	value = valueCreateFixed16_16(0x00000);
	getAllValues(value);
	assertAllTypes(false, 0, 0.0, 0x00000, NULL);
	value = valueCreateFixed16_16(0x10000);
	getAllValues(value);
	assertAllTypes(true, 1, 1.0, 0x10000, NULL);
	value = valueCreateFixed16_16(0x14000);
	getAllValues(value);
	assertAllTypes(true, 1, 1.25, 0x14000, NULL);
	
	value = valueCreatePointer(NULL);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypes(NULL);
	value = valueCreatePointer((void *) 0x1);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypesSeparate((void *) 0x1, NULL, NULL, NULL, NULL, NULL);
	
	value = valueCreateString(NULL, 0, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypes(NULL);
	value = valueCreateString("abcd", 4, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypesSeparate(value.value.string, value.value.string, value.value.string, NULL, NULL, NULL);
	
	value = valueCreateBlob(NULL, 0, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypes(NULL);
	value = valueCreateBlob("abcd", 4, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypesSeparate(value.value.blob.bytes, NULL, value.value.blob.bytes, NULL, NULL, NULL);
	
	value = valueCreateHashTable(NULL, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypes(NULL);
	value = valueCreateHashTable(hashCreate(), true, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypesSeparate(value.value.hashTable, NULL, NULL, value.value.hashTable, NULL, NULL);
	valueDispose(&value);
	
	value = valueCreateArray(NULL, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypes(NULL);
	value = valueCreateArray(arrayCreate(), true, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypesSeparate(value.value.array, NULL, NULL, NULL, value.value.array, NULL);
	valueDispose(&value);
	
	value = valueCreateAssociativeArray(NULL, false, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypes(NULL);
	value = valueCreateAssociativeArray(associativeArrayCreate(), true, false);
	getAllValues(value);
	assertAllPrimitiveTypes(false, 0, 0.0, 0x00000);
	assertAllPointerTypesSeparate(value.value.associativeArray, NULL, NULL, NULL, NULL, value.value.associativeArray);
	valueDispose(&value);
}