| 1 | /*************************************************************************** |
| 2 | copyright : (C) 2009 by Lukas Lalinsky |
| 3 | email : [email protected] |
| 4 | ***************************************************************************/ |
| 5 | |
| 6 | /*************************************************************************** |
| 7 | * This library is free software; you can redistribute it and/or modify * |
| 8 | * it under the terms of the GNU Lesser General Public License version * |
| 9 | * 2.1 as published by the Free Software Foundation. * |
| 10 | * * |
| 11 | * This library is distributed in the hope that it will be useful, but * |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 | * Lesser General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU Lesser General Public * |
| 17 | * License along with this library; if not, write to the Free Software * |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * |
| 19 | * 02110-1301 USA * |
| 20 | * * |
| 21 | * Alternatively, this file is available under the Mozilla Public * |
| 22 | * License Version 1.1. You may obtain a copy of the License at * |
| 23 | * http://www.mozilla.org/MPL/ * |
| 24 | ***************************************************************************/ |
| 25 | |
| 26 | #include <string> |
| 27 | #include <cstdio> |
| 28 | |
| 29 | #include "tag.h" |
| 30 | #include "mp4coverart.h" |
| 31 | #include <cppunit/extensions/HelperMacros.h> |
| 32 | #include "utils.h" |
| 33 | |
| 34 | using namespace std; |
| 35 | using namespace TagLib; |
| 36 | |
| 37 | class TestMP4CoverArt : public CppUnit::TestFixture |
| 38 | { |
| 39 | CPPUNIT_TEST_SUITE(TestMP4CoverArt); |
| 40 | CPPUNIT_TEST(testSimple); |
| 41 | CPPUNIT_TEST(testList); |
| 42 | CPPUNIT_TEST_SUITE_END(); |
| 43 | |
| 44 | public: |
| 45 | |
| 46 | void testSimple() |
| 47 | { |
| 48 | MP4::CoverArt c(MP4::CoverArt::PNG, "foo"); |
| 49 | CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c.format()); |
| 50 | CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c.data()); |
| 51 | |
| 52 | MP4::CoverArt c2(c); |
| 53 | CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c2.format()); |
| 54 | CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c2.data()); |
| 55 | |
| 56 | MP4::CoverArt c3 = c; |
| 57 | CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c3.format()); |
| 58 | CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c3.data()); |
| 59 | } |
| 60 | |
| 61 | void testList() |
| 62 | { |
| 63 | MP4::CoverArtList l; |
| 64 | l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo")); |
| 65 | l.append(MP4::CoverArt(MP4::CoverArt::JPEG, "bar")); |
| 66 | |
| 67 | CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format()); |
| 68 | CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), l[0].data()); |
| 69 | CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format()); |
| 70 | CPPUNIT_ASSERT_EQUAL(ByteVector("bar"), l[1].data()); |
| 71 | } |
| 72 | |
| 73 | }; |
| 74 | |
| 75 | CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4CoverArt); |