void testPicture() { ScopedFileCopy copy("empty", ".ogg"); string newname = copy.fileName(); { Vorbis::File f(newname.c_str()); FLAC::Picture *newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); newpic->setWidth(5); newpic->setHeight(6); newpic->setColorDepth(16); newpic->setNumColors(7); newpic->setMimeType("image/jpeg"); newpic->setDescription("new image"); newpic->setData("JPEG data"); f.tag()->addPicture(newpic); f.save(); } { Vorbis::File f(newname.c_str()); List<FLAC::Picture *> lst = f.tag()->pictureList(); CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); CPPUNIT_ASSERT_EQUAL((int)5, lst[0]->width()); CPPUNIT_ASSERT_EQUAL((int)6, lst[0]->height()); CPPUNIT_ASSERT_EQUAL((int)16, lst[0]->colorDepth()); CPPUNIT_ASSERT_EQUAL((int)7, lst[0]->numColors()); CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), lst[0]->mimeType()); CPPUNIT_ASSERT_EQUAL(String("new image"), lst[0]->description()); CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), lst[0]->data()); } }
void testAddPicture() { ScopedFileCopy copy("silence-44-s", ".flac"); string newname = copy.fileName(); { FLAC::File f(newname.c_str()); List<FLAC::Picture *> lst = f.pictureList(); CPPUNIT_ASSERT_EQUAL((unsigned int)1, lst.size()); FLAC::Picture *newpic = new FLAC::Picture(); newpic->setType(FLAC::Picture::BackCover); newpic->setWidth(5); newpic->setHeight(6); newpic->setColorDepth(16); newpic->setNumColors(7); newpic->setMimeType("image/jpeg"); newpic->setDescription("new image"); newpic->setData("JPEG data"); f.addPicture(newpic); f.save(); } { FLAC::File f(newname.c_str()); List<FLAC::Picture *> lst = f.pictureList(); CPPUNIT_ASSERT_EQUAL((unsigned int)2, lst.size()); FLAC::Picture *pic = lst[0]; CPPUNIT_ASSERT_EQUAL(FLAC::Picture::FrontCover, pic->type()); CPPUNIT_ASSERT_EQUAL(1, pic->width()); CPPUNIT_ASSERT_EQUAL(1, pic->height()); CPPUNIT_ASSERT_EQUAL(24, pic->colorDepth()); CPPUNIT_ASSERT_EQUAL(0, pic->numColors()); CPPUNIT_ASSERT_EQUAL(String("image/png"), pic->mimeType()); CPPUNIT_ASSERT_EQUAL(String("A pixel."), pic->description()); CPPUNIT_ASSERT_EQUAL((unsigned int)150, pic->data().size()); pic = lst[1]; CPPUNIT_ASSERT_EQUAL(FLAC::Picture::BackCover, pic->type()); CPPUNIT_ASSERT_EQUAL(5, pic->width()); CPPUNIT_ASSERT_EQUAL(6, pic->height()); CPPUNIT_ASSERT_EQUAL(16, pic->colorDepth()); CPPUNIT_ASSERT_EQUAL(7, pic->numColors()); CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), pic->mimeType()); CPPUNIT_ASSERT_EQUAL(String("new image"), pic->description()); CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), pic->data()); } }