summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-22 19:42:39 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-22 19:42:39 +0000
commit1c724e363a644abaee7efb39d6091e7b30de0fb6 (patch)
tree413e28533849835f8496c8c972bd26e1d27aefbe /test
parent1e9f115b7cda68ccba99f58d194a2c0eb83e7e23 (diff)
Various work.
Diffstat (limited to 'test')
-rw-r--r--test/cpl_sar.cc2
-rw-r--r--test/recovery_test.cc10
-rw-r--r--test/round_trip_test.cc11
-rw-r--r--test/subs_in_out.cc3
-rw-r--r--test/subtitle_tests.cc4
-rw-r--r--test/test.cc15
-rw-r--r--test/test.h21
7 files changed, 50 insertions, 16 deletions
diff --git a/test/cpl_sar.cc b/test/cpl_sar.cc
index e280dbd3..3ab1ec26 100644
--- a/test/cpl_sar.cc
+++ b/test/cpl_sar.cc
@@ -29,7 +29,7 @@ using boost::shared_ptr;
*/
BOOST_AUTO_TEST_CASE (cpl_sar)
{
- shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF ("build/test/foo", "video.mxf"));
+ shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF ("build/test/foo/video.mxf"));
mp->set_interop (true);
{
diff --git a/test/recovery_test.cc b/test/recovery_test.cc
index 4cde723f..b67c54f7 100644
--- a/test/recovery_test.cc
+++ b/test/recovery_test.cc
@@ -48,10 +48,9 @@ BOOST_AUTO_TEST_CASE (recovery)
boost::filesystem::remove_all ("build/test/baz");
boost::filesystem::create_directories ("build/test/baz");
- shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF ("build/test/baz", "video1.mxf"));
- mp->set_edit_rate (24);
+ shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF (24));
mp->set_size (dcp::Size (32, 32));
- shared_ptr<dcp::PictureMXFWriter> writer = mp->start_write (false);
+ shared_ptr<dcp::PictureMXFWriter> writer = mp->start_write ("build/test/baz/video1.mxf", false);
int written_size = 0;
for (int i = 0; i < 24; ++i) {
@@ -78,10 +77,9 @@ BOOST_AUTO_TEST_CASE (recovery)
Kumu::ResetTestRNG ();
#endif
- mp.reset (new dcp::MonoPictureMXF ("build/test/baz", "video2.mxf"));
- mp->set_edit_rate (24);
+ mp.reset (new dcp::MonoPictureMXF (24));
mp->set_size (dcp::Size (32, 32));
- writer = mp->start_write (true);
+ writer = mp->start_write ("build/test/baz/video2.mxf", true);
writer->write (data, size);
diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc
index 0e6fe5f5..69bf63f9 100644
--- a/test/round_trip_test.cc
+++ b/test/round_trip_test.cc
@@ -58,9 +58,14 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
shared_ptr<dcp::MonoPictureMXF> asset_A (new dcp::MonoPictureMXF (work_dir, "video.mxf"));
asset_A->set_edit_rate (24);
- asset_A->set_intrinsic_duration (24);
- asset_A->set_size (dcp::Size (32, 32));
- asset_A->create (j2c);
+ shared_ptr<PictureMXFWriter> writer;
+ boost::filesystem::path mxf = work_dir + "video.mxf";
+ writer->start_write (mxf, false);
+ TestFile j2c ("test/data/32x32_red_square.j2c");
+ for (int i = 0; i < 24; ++i) {
+ writer->write (j2c.data (), j2c.size ());
+ }
+ writer->finalize ();
dcp::Key key;
diff --git a/test/subs_in_out.cc b/test/subs_in_out.cc
index 923cfe2e..40e5476c 100644
--- a/test/subs_in_out.cc
+++ b/test/subs_in_out.cc
@@ -10,8 +10,7 @@ int main (int argc, char* argv[])
exit (EXIT_FAILURE);
}
- dcp::SubtitleAsset s ("foo", "bar", "baz");
- s.read_xml (argv[1]);
+ dcp::SubtitleAsset s (argv[1]);
cout << s.xml_as_string ();
return 0;
}
diff --git a/test/subtitle_tests.cc b/test/subtitle_tests.cc
index 23e5b821..b2b2d363 100644
--- a/test/subtitle_tests.cc
+++ b/test/subtitle_tests.cc
@@ -26,7 +26,7 @@ using boost::shared_ptr;
/* Load a subtitle asset from XML and check that it is read correctly */
BOOST_AUTO_TEST_CASE (subtitles1)
{
- dcp::SubtitleAsset subs ("test/data", "subs1.xml");
+ dcp::SubtitleAsset subs ("test/data/subs1.xml");
BOOST_CHECK_EQUAL (subs.language(), "French");
@@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE (subtitles1)
/** And similarly for another one */
BOOST_AUTO_TEST_CASE (subtitles2)
{
- dcp::SubtitleAsset subs ("test/data", "subs2.xml");
+ dcp::SubtitleAsset subs ("test/data/subs2.xml");
list<shared_ptr<dcp::Subtitle> > s = subs.subtitles_at (dcp::Time (0, 0, 42, 100));
BOOST_CHECK_EQUAL (s.size(), 2);
diff --git a/test/test.cc b/test/test.cc
index f693467e..ff018cd5 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -21,6 +21,7 @@
#define BOOST_TEST_MODULE libdcp_test
#include <boost/test/unit_test.hpp>
#include "util.h"
+#include "test.h"
using std::string;
@@ -48,3 +49,17 @@ wav (dcp::Channel)
string test_corpus = "../libdcp-test";
+TestFile::TestFile (boost::filesystem::path file)
+{
+ _size = boost::filesystem::file_size (file);
+ _data = new uint8_t[_size];
+ FILE* f = dcp::fopen_boost (file, "r");
+ assert (f);
+ fread (_data, 1, _size, f);
+ fclose (f);
+}
+
+TestFile::~TestFile ()
+{
+ delete[] _data;
+}
diff --git a/test/test.h b/test/test.h
index dc704004..31b4bf0a 100644
--- a/test/test.h
+++ b/test/test.h
@@ -17,6 +17,23 @@
*/
-extern boost::filesystem::path j2c (int);
-extern boost::filesystem::path wav (dcp::Channel);
extern std::string test_corpus;
+
+class TestFile
+{
+public:
+ TestFile (boost::filesystem::path file);
+ ~TestFile ();
+
+ uint8_t* data () const {
+ return _data;
+ }
+
+ int64_t size () const {
+ return _size;
+ }
+
+private:
+ uint8_t* _data;
+ int64_t _size;
+};