TEST_F(TrackExporterTest, SimpleListExport) { // Create a simple list of trackpointers and export them. QFileInfo fileinfo1(m_testDataDir.filePath("cover-test.ogg")); TrackPointer track1(TrackInfoObject::newTemporary(fileinfo1)); QFileInfo fileinfo2(m_testDataDir.filePath("cover-test.flac")); TrackPointer track2(TrackInfoObject::newTemporary(fileinfo2)); QFileInfo fileinfo3(m_testDataDir.filePath("cover-test.m4a")); TrackPointer track3(TrackInfoObject::newTemporary(fileinfo3)); // An initializer list would be prettier here, but it doesn't compile // on MSVC or OSX. QList<TrackPointer> tracks; tracks.append(track1); tracks.append(track2); tracks.append(track3); TrackExportWorker worker(m_exportDir.canonicalPath(), tracks); m_answerer.reset(new FakeOverwriteAnswerer(&worker)); worker.run(); EXPECT_TRUE(worker.wait(10000)); EXPECT_EQ(3, m_answerer->currentProgress()); EXPECT_EQ(3, m_answerer->currentProgressCount()); // The destination folder should have all the files. EXPECT_TRUE(QFileInfo(m_exportDir.filePath("cover-test.ogg")).exists()); EXPECT_TRUE(QFileInfo(m_exportDir.filePath("cover-test.flac")).exists()); EXPECT_TRUE(QFileInfo(m_exportDir.filePath("cover-test.m4a")).exists()); }
TEST_F(TrackExporterTest, DedupeList) { // Create a track list with a duplicate track, see that it gets deduped. QFileInfo fileinfo1(m_testDataDir.filePath("cover-test.ogg")); TrackPointer track1(TrackInfoObject::newTemporary(fileinfo1)); TrackPointer track2(TrackInfoObject::newTemporary(fileinfo1)); // Set up the worker and answerer. QList<TrackPointer> tracks; tracks.append(track1); tracks.append(track2); TrackExportWorker worker(m_exportDir.canonicalPath(), tracks); m_answerer.reset(new FakeOverwriteAnswerer(&worker)); worker.run(); EXPECT_TRUE(worker.wait(10000)); EXPECT_EQ(1, m_answerer->currentProgress()); EXPECT_EQ(1, m_answerer->currentProgressCount()); // Both files should have been overwritten. QFileInfo newfile1(m_exportDir.filePath("cover-test.ogg")); EXPECT_TRUE(newfile1.exists()); // Should only be one file QFileInfoList files = m_exportDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files); EXPECT_EQ(1, files.size()); }
static VALUE cGraphicsView_scene_get(VALUE v_self) { track1("%s::scene_get", v_self); const RPP::QObject<QGraphicsView> self = v_self; return qt2v(self->scene()); }
/* override */ static VALUE cPropertyAnimation_startValue_set(VALUE v_self, VALUE v_start) { track2("%s::startValue=%s", v_self, v_start); const RPP::QObject<QPropertyAnimation> self = v_self; /* If no target is set here, use parent. * If no propertyName is set here, use R_QT_DYNVALUE_PROPERTYID. * This assumes the parent can only have 1 animation at a time. * But it auto updates the value inside the parent! * Which I expect to be a DynamicAttribute anyway! */ if (!self->targetObject()) { const RPP::QObject<QObject> parent = self->parent(); track1("no target, use parent %s", parent); self->setTargetObject(parent); /* Normally that would be the DynamicAttribute. * * It is now important that the handler is set. * Something like: * * target.disconnect :dynamicPropertyChanged * target.dynamicPropertyChanged do |name| * val = property(name) * apply_model val * end * * And now in C++... */ parent.call("disconnect", RPP::Symbol("dynamicPropertyChanged")); /* CONFUSING. * disconnect is NOT required at the moment, since * dynamicPropertyChanged is a ruby-signal and there can only be one 'slot' currently. */ parent.call_with_block("dynamicPropertyChanged", dynamicPropertyChanged_block, parent); } if (self->propertyName().isEmpty()) { const QVariant var = v2qvar_safe(v_start); const RPP::QObject<QObject> parent = self->parent(); parent->setProperty(R_QT_DYNVALUE_PROPERTYID, var); trace("no propertyName set, use DYNVALUE magic"); self->setPropertyName(QByteArray(R_QT_DYNVALUE_PROPERTYID)); } return self.super(v_start); }
TEST_F(TrackExporterTest, OverwriteSkip) { // Export a tracklist with two existing tracks -- overwrite one and skip // the other. QFileInfo fileinfo1(m_testDataDir.filePath("cover-test.ogg")); const qint64 fileSize1 = fileinfo1.size(); TrackPointer track1(Track::newTemporary(fileinfo1)); QFileInfo fileinfo2(m_testDataDir.filePath("cover-test.m4a")); TrackPointer track2(Track::newTemporary(fileinfo2)); // Create empty versions at the destination so we can see if we actually // overwrote or skipped. QFile file1(m_exportDir.filePath("cover-test.ogg")); ASSERT_TRUE(file1.open(QIODevice::WriteOnly)); file1.close(); QFile file2(m_exportDir.filePath("cover-test.m4a")); ASSERT_TRUE(file2.open(QIODevice::WriteOnly)); file2.close(); // Set up the worker and answerer. QList<TrackPointer> tracks; tracks.append(track1); tracks.append(track2); TrackExportWorker worker(m_exportDir.canonicalPath(), tracks); m_answerer.reset(new FakeOverwriteAnswerer(&worker)); m_answerer->setAnswer(QFileInfo(file1).canonicalFilePath(), TrackExportWorker::OverwriteAnswer::OVERWRITE); m_answerer->setAnswer(QFileInfo(file2).canonicalFilePath(), TrackExportWorker::OverwriteAnswer::SKIP); worker.run(); EXPECT_TRUE(worker.wait(10000)); EXPECT_EQ(2, m_answerer->currentProgress()); EXPECT_EQ(2, m_answerer->currentProgressCount()); // The destination folder should have both the files, one skipped and // one written. QFileInfo newfile1(m_exportDir.filePath("cover-test.ogg")); EXPECT_TRUE(newfile1.exists()); EXPECT_EQ(fileSize1, newfile1.size()); QFileInfo newfile2(m_exportDir.filePath("cover-test.m4a")); EXPECT_TRUE(newfile2.exists()); EXPECT_EQ(0, newfile2.size()); }
TEST_F(TrackExporterTest, Cancel) { // Export a tracklist with two existing tracks, but cancel before we do // anything. QFileInfo fileinfo1(m_testDataDir.filePath("cover-test.ogg")); TrackPointer track1(TrackInfoObject::newTemporary(fileinfo1)); QFileInfo fileinfo2(m_testDataDir.filePath("cover-test.m4a")); TrackPointer track2(TrackInfoObject::newTemporary(fileinfo2)); // Create empty version at the destination so we can see if we actually // canceled. QFile file2(m_exportDir.filePath("cover-test.m4a")); ASSERT_TRUE(file2.open(QIODevice::WriteOnly)); file2.close(); // Set up the worker and answerer. QList<TrackPointer> tracks; tracks.append(track1); tracks.append(track2); TrackExportWorker worker(m_exportDir.canonicalPath(), tracks); m_answerer.reset(new FakeOverwriteAnswerer(&worker)); m_answerer->setAnswer(QFileInfo(file2).canonicalFilePath(), TrackExportWorker::OverwriteAnswer::CANCEL); worker.run(); EXPECT_TRUE(worker.wait(10000)); EXPECT_EQ(-1, m_answerer->currentProgress()); EXPECT_EQ(-1, m_answerer->currentProgressCount()); // Both files should have been skipped because we canceled the process, // so the .ogg shouldn't exist at all. QFileInfo newfile1(m_exportDir.filePath("cover-test.ogg")); EXPECT_FALSE(newfile1.exists()); QFileInfo newfile2(m_exportDir.filePath("cover-test.m4a")); EXPECT_TRUE(newfile2.exists()); EXPECT_EQ(0, newfile2.size()); }
TEST_F(TrackExporterTest, MungeFilename) { // Create a track list with a duplicate track in a different location, // see that the name gets munged. QFileInfo fileinfo1(m_testDataDir.filePath("cover-test.ogg")); TrackPointer track1(TrackInfoObject::newTemporary(fileinfo1)); // Create a file with the same name in a different place. Its filename // should be munged and the file still copied. QDir tempPath(QDir::tempPath()); QFile file2(tempPath.filePath("cover-test.ogg")); QFileInfo fileinfo2(file2); ASSERT_TRUE(file2.open(QIODevice::WriteOnly)); file2.close(); TrackPointer track2(TrackInfoObject::newTemporary(fileinfo2)); // Set up the worker and answerer. QList<TrackPointer> tracks; tracks.append(track1); tracks.append(track2); TrackExportWorker worker(m_exportDir.canonicalPath(), tracks); m_answerer.reset(new FakeOverwriteAnswerer(&worker)); worker.run(); EXPECT_TRUE(worker.wait(10000)); EXPECT_EQ(2, m_answerer->currentProgress()); EXPECT_EQ(2, m_answerer->currentProgressCount()); QFileInfo newfile1(m_exportDir.filePath("cover-test.ogg")); EXPECT_TRUE(newfile1.exists()); QFileInfo newfile2(m_exportDir.filePath("cover-test-0001.ogg")); EXPECT_TRUE(newfile2.exists()); // Remove the track we created. tempPath.remove("cover-test.ogg"); }
static VALUE cAbstractAnimation_start(int argc, VALUE *argv, VALUE v_self) { track1("%s::start", v_self); RPP::Symbol policy(RPP::UNSAFE); RPP::Scan(argc, argv).opt(policy); QAbstractAnimation::DeletionPolicy pol = QAbstractAnimation::KeepWhenStopped; if (policy.test()) { if (policy == "keepWhenStopped" || policy == "default" || policy == "keep" ) pol = QAbstractAnimation::KeepWhenStopped; else if (policy == "deleteWhenStopped" || policy == "autoDelete" || policy == "auto_delete" ) pol = QAbstractAnimation::DeleteWhenStopped; else rb_raise(rb_eArgError, "bad DeletionPolicy :%s", policy.to_s()); } RPP::QObject<QAbstractAnimation>(v_self)->start(pol); return v_self; }