summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-06-14 13:01:32 +0000
committerCarl Hetherington <carl@carlh.net>2012-06-14 13:01:32 +0000
commite258a15330a7cf1dfb7f54870fc6945cdbd07922 (patch)
tree75453d5418d40c488a574da5fc7fcc9bed95fe66
parentb7f586f0a3a2609790d5a451c8c46bc57092803d (diff)
Simple test for playlist region equivalency.
git-svn-id: svn://localhost/ardour2/branches/3.0@12724 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/test/playlist_equivalent_regions_test.cc95
-rw-r--r--libs/ardour/test/playlist_equivalent_regions_test.h36
-rw-r--r--libs/ardour/wscript1
3 files changed, 132 insertions, 0 deletions
diff --git a/libs/ardour/test/playlist_equivalent_regions_test.cc b/libs/ardour/test/playlist_equivalent_regions_test.cc
new file mode 100644
index 0000000000..12853d39dd
--- /dev/null
+++ b/libs/ardour/test/playlist_equivalent_regions_test.cc
@@ -0,0 +1,95 @@
+/*
+ Copyright (C) 2012 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ardour/playlist.h"
+#include "ardour/playlist_factory.h"
+#include "ardour/region.h"
+#include "playlist_equivalent_regions_test.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION (PlaylistEquivalentRegionsTest);
+
+using namespace std;
+using namespace ARDOUR;
+
+void
+PlaylistEquivalentRegionsTest::setUp ()
+{
+ AudioRegionTest::setUp ();
+
+ _playlist_b = PlaylistFactory::create (DataType::AUDIO, *_session, "testB");
+}
+
+void
+PlaylistEquivalentRegionsTest::tearDown ()
+{
+ _playlist_b.reset ();
+
+ AudioRegionTest::tearDown ();
+}
+
+/* Test simple equivalency operations */
+void
+PlaylistEquivalentRegionsTest::basicsTest ()
+{
+ /* Put _r[0] on _playlist */
+ _playlist->add_region (_r[0], 42);
+
+ /* And _r[1] on _playlist_b at the same position */
+ _playlist_b->add_region (_r[1], 42);
+
+ /* Look for the equivalents to _r[0] on _playlist_b */
+ vector<boost::shared_ptr<Region> > e;
+ _playlist_b->get_equivalent_regions (_r[0], e);
+
+ /* That should be _r[1] */
+ CPPUNIT_ASSERT_EQUAL (size_t (1), e.size ());
+ CPPUNIT_ASSERT_EQUAL (e.front(), _r[1]);
+
+ /* Move _r[1] */
+ _r[1]->set_position (66);
+
+ /* Look again for the equivalents to _r[0] on _playlist_b */
+ e.clear ();
+ _playlist_b->get_equivalent_regions (_r[0], e);
+
+ /* There should be none */
+ CPPUNIT_ASSERT (e.empty ());
+}
+
+void
+PlaylistEquivalentRegionsTest::multiLayerTest ()
+{
+ _playlist->clear ();
+ _playlist_b->clear ();
+
+ /* Put _r[0] and _r[1] at the same position on _playlist so that they overlap */
+ _playlist->add_region (_r[0], 42);
+ _playlist->add_region (_r[1], 42);
+
+ /* And _r[2], _r[3] similarly on _playlist_b */
+ _playlist_b->add_region (_r[2], 42);
+ _playlist_b->add_region (_r[3], 42);
+
+ /* Look for equivalents to _r[0] on _playlist_b */
+ vector<boost::shared_ptr<Region> > e;
+ _playlist_b->get_equivalent_regions (_r[0], e);
+
+ /* That should be _r[2] and _r[3] */
+ CPPUNIT_ASSERT_EQUAL (size_t (2), e.size ());
+ CPPUNIT_ASSERT ((e.front() == _r[2] && e.back() == _r[3]) || (e.front() == _r[3] && e.back() == _r[2]));
+}
diff --git a/libs/ardour/test/playlist_equivalent_regions_test.h b/libs/ardour/test/playlist_equivalent_regions_test.h
new file mode 100644
index 0000000000..a3447bbe80
--- /dev/null
+++ b/libs/ardour/test/playlist_equivalent_regions_test.h
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2012 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "audio_region_test.h"
+
+class PlaylistEquivalentRegionsTest : public AudioRegionTest
+{
+ CPPUNIT_TEST_SUITE (PlaylistEquivalentRegionsTest);
+ CPPUNIT_TEST (basicsTest);
+ CPPUNIT_TEST (multiLayerTest);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+ void setUp ();
+ void tearDown ();
+ void basicsTest ();
+ void multiLayerTest ();
+
+private:
+ boost::shared_ptr<ARDOUR::Playlist> _playlist_b;
+};
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index 25a2cb6d92..c16c0469ec 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -438,6 +438,7 @@ def build(bld):
test/framepos_minus_beats_test.cc
test/playlist_layering_test.cc
test/playlist_read_test.cc
+ test/playlist_equivalent_regions_test.cc
test/control_surfaces_test.cc
test/combine_regions_test.cc
test/mtdm_test.cc