2 Copyright (C) 2012 Paul Davis
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.
19 #include "ardour/playlist.h"
20 #include "ardour/playlist_factory.h"
21 #include "ardour/region.h"
22 #include "playlist_equivalent_regions_test.h"
24 CPPUNIT_TEST_SUITE_REGISTRATION (PlaylistEquivalentRegionsTest);
27 using namespace ARDOUR;
30 PlaylistEquivalentRegionsTest::setUp ()
32 AudioRegionTest::setUp ();
34 _playlist_b = PlaylistFactory::create (DataType::AUDIO, *_session, "testB");
38 PlaylistEquivalentRegionsTest::tearDown ()
42 AudioRegionTest::tearDown ();
45 /* Test simple equivalency operations */
47 PlaylistEquivalentRegionsTest::basicsTest ()
49 /* Put _r[0] on _playlist */
50 _playlist->add_region (_r[0], 42);
52 /* And _r[1] on _playlist_b at the same position */
53 _playlist_b->add_region (_r[1], 42);
55 /* Look for the equivalents to _r[0] on _playlist_b */
56 vector<boost::shared_ptr<Region> > e;
57 _playlist_b->get_equivalent_regions (_r[0], e);
59 /* That should be _r[1] */
60 CPPUNIT_ASSERT_EQUAL (size_t (1), e.size ());
61 CPPUNIT_ASSERT_EQUAL (e.front(), _r[1]);
64 _r[1]->set_position (66);
66 /* Look again for the equivalents to _r[0] on _playlist_b */
68 _playlist_b->get_equivalent_regions (_r[0], e);
70 /* There should be none */
71 CPPUNIT_ASSERT (e.empty ());
75 PlaylistEquivalentRegionsTest::multiLayerTest ()
78 _playlist_b->clear ();
80 /* Put _r[0] and _r[1] at the same position on _playlist so that they overlap */
81 _playlist->add_region (_r[0], 42);
82 _playlist->add_region (_r[1], 42);
84 /* And _r[2], _r[3] similarly on _playlist_b */
85 _playlist_b->add_region (_r[2], 42);
86 _playlist_b->add_region (_r[3], 42);
88 /* Look for equivalents to _r[0] on _playlist_b */
89 vector<boost::shared_ptr<Region> > e;
90 _playlist_b->get_equivalent_regions (_r[0], e);
92 /* That should be _r[2] and _r[3] */
93 CPPUNIT_ASSERT_EQUAL (size_t (2), e.size ());
94 CPPUNIT_ASSERT ((e.front() == _r[2] && e.back() == _r[3]) || (e.front() == _r[3] && e.back() == _r[2]));