ardour
playlist_equivalent_regions_test.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Paul Davis
3 
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.
8 
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.
13 
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.
17 */
18 
19 #include "ardour/playlist.h"
21 #include "ardour/region.h"
23 
25 
26 using namespace std;
27 using namespace ARDOUR;
28 
29 void
31 {
33 
34  _playlist_b = PlaylistFactory::create (DataType::AUDIO, *_session, "testB");
35 }
36 
37 void
39 {
40  _playlist_b.reset ();
41 
43 }
44 
45 /* Test simple equivalency operations */
46 void
48 {
49  /* Put _r[0] on _playlist */
50  _playlist->add_region (_r[0], 42);
51 
52  /* And _r[1] on _playlist_b at the same position */
53  _playlist_b->add_region (_r[1], 42);
54 
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);
58 
59  /* That should be _r[1] */
60  CPPUNIT_ASSERT_EQUAL (size_t (1), e.size ());
61  CPPUNIT_ASSERT_EQUAL (e.front(), _r[1]);
62 
63  /* Move _r[1] */
64  _r[1]->set_position (66);
65 
66  /* Look again for the equivalents to _r[0] on _playlist_b */
67  e.clear ();
68  _playlist_b->get_equivalent_regions (_r[0], e);
69 
70  /* There should be none */
71  CPPUNIT_ASSERT (e.empty ());
72 }
73 
74 void
76 {
77  _playlist->clear ();
78  _playlist_b->clear ();
79 
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);
83 
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);
87 
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);
91 
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]));
95 }
virtual void tearDown()
Definition: Beats.hpp:239
Definition: amp.h:29
CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistEquivalentRegionsTest)
virtual void setUp()