1 /***************************************************************************
2     copyright           : (C) 2009 by Lukas Lalinsky
3     email               : lukas@oxygene.sk
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 <stdio.h>
28 #include <tag.h>
29 #include <mp4coverart.h>
30 #include <cppunit/extensions/HelperMacros.h>
31 #include "utils.h"
32 
33 using namespace std;
34 using namespace TagLib;
35 
36 class TestMP4CoverArt : public CppUnit::TestFixture
37 {
38   CPPUNIT_TEST_SUITE(TestMP4CoverArt);
39   CPPUNIT_TEST(testSimple);
40   CPPUNIT_TEST(testList);
41   CPPUNIT_TEST_SUITE_END();
42 
43 public:
44 
testSimple()45   void testSimple()
46   {
47     MP4::CoverArt c(MP4::CoverArt::PNG, "foo");
48     CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c.format());
49     CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c.data());
50 
51     MP4::CoverArt c2(c);
52     CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c2.format());
53     CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c2.data());
54 
55     MP4::CoverArt c3 = c;
56     CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, c3.format());
57     CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), c3.data());
58   }
59 
testList()60   void testList()
61   {
62     MP4::CoverArtList l;
63     l.append(MP4::CoverArt(MP4::CoverArt::PNG, "foo"));
64     l.append(MP4::CoverArt(MP4::CoverArt::JPEG, "bar"));
65 
66     CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
67     CPPUNIT_ASSERT_EQUAL(ByteVector("foo"), l[0].data());
68     CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
69     CPPUNIT_ASSERT_EQUAL(ByteVector("bar"), l[1].data());
70   }
71 
72 };
73 
74 CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4CoverArt);
75