2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/test/unit_test.hpp>
21 #include "lib/image_decoder.h"
22 #include "lib/image_content.h"
27 using boost::shared_ptr;
29 BOOST_AUTO_TEST_CASE (video_decoder_fill_test1)
31 shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
32 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
33 ImageDecoder decoder (c);
35 decoder.fill_2d (0, 4);
36 BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 4);
37 list<ContentVideo>::iterator i = decoder._decoded_video.begin();
38 for (int j = 0; j < 4; ++j) {
39 BOOST_CHECK_EQUAL (i->frame, j);
43 decoder.fill_2d (0, 7);
44 BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 7);
45 i = decoder._decoded_video.begin();
46 for (int j = 0; j < 7; ++j) {
47 BOOST_CHECK_EQUAL (i->frame, j);
52 BOOST_AUTO_TEST_CASE (video_decoder_fill_test2)
54 shared_ptr<Film> film = new_test_film ("video_decoder_fill_test");
55 shared_ptr<ImageContent> c (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
56 ImageDecoder decoder (c);
58 decoder.fill_3d (0, 4, EYES_LEFT);
59 BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 8);
60 list<ContentVideo>::iterator i = decoder._decoded_video.begin();
61 for (int j = 0; j < 8; ++j) {
62 BOOST_CHECK_EQUAL (i->frame, j / 2);
63 BOOST_CHECK_EQUAL (i->eyes, (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);
67 decoder.fill_3d (0, 7, EYES_RIGHT);
68 BOOST_CHECK_EQUAL (decoder._decoded_video.size(), 15);
69 i = decoder._decoded_video.begin();
70 for (int j = 0; j < 15; ++j) {
71 BOOST_CHECK_EQUAL (i->frame, j / 2);
72 BOOST_CHECK_EQUAL (i->eyes, (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT);