diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/certificates_test.cc | 14 | ||||
| -rw-r--r-- | test/color_test.cc | 8 | ||||
| -rw-r--r-- | test/cpl_sar_test.cc (renamed from test/cpl_sar.cc) | 18 | ||||
| -rw-r--r-- | test/dcp_test.cc | 82 | ||||
| -rw-r--r-- | test/dcp_time_test.cc | 22 | ||||
| -rw-r--r-- | test/decryption_test.cc | 29 | ||||
| -rw-r--r-- | test/encryption_test.cc | 80 | ||||
| -rw-r--r-- | test/error_test.cc | 47 | ||||
| -rw-r--r-- | test/frame_info_test.cc | 9 | ||||
| -rw-r--r-- | test/kdm_key_test.cc | 2 | ||||
| -rw-r--r-- | test/kdm_test.cc | 8 | ||||
| -rw-r--r-- | test/lut_test.cc | 48 | ||||
| -rw-r--r-- | test/read_dcp_test.cc | 10 | ||||
| -rw-r--r-- | test/recovery_test.cc | 18 | ||||
| -rw-r--r-- | test/rewrite_subs.cc | 28 | ||||
| -rw-r--r-- | test/round_trip_test.cc | 71 | ||||
| -rw-r--r-- | test/subs_in_out.cc | 5 | ||||
| -rw-r--r-- | test/subtitle_tests.cc | 451 | ||||
| -rw-r--r-- | test/test.cc | 5 | ||||
| -rw-r--r-- | test/test.h | 2 | ||||
| -rw-r--r-- | test/utc_offset_to_string_test.cc | 12 | ||||
| -rw-r--r-- | test/util_test.cc | 69 | ||||
| -rw-r--r-- | test/wscript | 34 |
23 files changed, 536 insertions, 536 deletions
diff --git a/test/certificates_test.cc b/test/certificates_test.cc index 0a66bc66..690afa77 100644 --- a/test/certificates_test.cc +++ b/test/certificates_test.cc @@ -25,15 +25,15 @@ using boost::shared_ptr; BOOST_AUTO_TEST_CASE (certificates) { - libdcp::CertificateChain c; + dcp::CertificateChain c; - c.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); - c.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); - c.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); + c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); + c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); + c.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); - list<shared_ptr<libdcp::Certificate> > leaf_to_root = c.leaf_to_root (); + list<shared_ptr<dcp::Certificate> > leaf_to_root = c.leaf_to_root (); - list<shared_ptr<libdcp::Certificate> >::iterator i = leaf_to_root.begin (); + list<shared_ptr<dcp::Certificate> >::iterator i = leaf_to_root.begin (); /* Leaf */ BOOST_CHECK_EQUAL (*i, c.leaf ()); @@ -78,6 +78,6 @@ BOOST_AUTO_TEST_CASE (certificates) ); /* Check that reconstruction from a string works */ - libdcp::Certificate test (c.root()->certificate (true)); + dcp::Certificate test (c.root()->certificate (true)); BOOST_CHECK_EQUAL (test.certificate(), c.root()->certificate()); } diff --git a/test/color_test.cc b/test/color_test.cc index 30a96a0d..d68f59d4 100644 --- a/test/color_test.cc +++ b/test/color_test.cc @@ -21,24 +21,24 @@ #include "util.h" -/* Check that libdcp::Color works */ +/* Check that dcp::Color works */ BOOST_AUTO_TEST_CASE (color) { - libdcp::Color c ("FFFF0000"); + dcp::Color c ("FFFF0000"); BOOST_CHECK_EQUAL (c.r, 255); BOOST_CHECK_EQUAL (c.g, 0); BOOST_CHECK_EQUAL (c.b, 0); BOOST_CHECK_EQUAL (c.to_argb_string(), "FFFF0000"); - c = libdcp::Color ("FF00FF00"); + c = dcp::Color ("FF00FF00"); BOOST_CHECK_EQUAL (c.r, 0); BOOST_CHECK_EQUAL (c.g, 255); BOOST_CHECK_EQUAL (c.b, 0); BOOST_CHECK_EQUAL (c.to_argb_string(), "FF00FF00"); - c = libdcp::Color ("FF0000FF"); + c = dcp::Color ("FF0000FF"); BOOST_CHECK_EQUAL (c.r, 0); BOOST_CHECK_EQUAL (c.g, 0); diff --git a/test/cpl_sar.cc b/test/cpl_sar_test.cc index c91ce287..0c62ea8b 100644 --- a/test/cpl_sar.cc +++ b/test/cpl_sar_test.cc @@ -17,10 +17,11 @@ */ -#include <boost/test/unit_test.hpp> -#include <libcxml/cxml.h> #include "cpl.h" -#include "mono_picture_asset.h" +#include "reel_mono_picture_asset.h" +#include "mono_picture_mxf.h" +#include <libcxml/cxml.h> +#include <boost/test/unit_test.hpp> using boost::shared_ptr; @@ -29,24 +30,23 @@ using boost::shared_ptr; */ BOOST_AUTO_TEST_CASE (cpl_sar) { - shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/foo", "video.mxf")); - mp->set_interop (true); + shared_ptr<dcp::ReelMonoPictureAsset> pa (new dcp::ReelMonoPictureAsset ()); { - mp->set_size (libdcp::Size (1998, 1080)); + pa->set_screen_aspect_ratio (dcp::Fraction (1998, 1080)); xmlpp::Document doc; xmlpp::Element* el = doc.create_root_node ("Test"); - mp->write_to_cpl (el); + pa->write_to_cpl (el, dcp::INTEROP); cxml::Node node (el); BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "1.85"); } { - mp->set_size (libdcp::Size (2048, 858)); + pa->set_screen_aspect_ratio (dcp::Fraction (2048, 858)); xmlpp::Document doc; xmlpp::Element* el = doc.create_root_node ("Test"); - mp->write_to_cpl (el); + pa->write_to_cpl (el, dcp::INTEROP); cxml::Node node (el); BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "2.39"); diff --git a/test/dcp_test.cc b/test/dcp_test.cc index d0c8b973..1736cb60 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> 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 @@ -17,15 +17,22 @@ */ -#include <boost/test/unit_test.hpp> #include "dcp.h" #include "metadata.h" #include "cpl.h" -#include "mono_picture_asset.h" -#include "sound_asset.h" +#include "mono_picture_mxf.h" +#include "picture_mxf_writer.h" +#include "sound_mxf_writer.h" +#include "sound_mxf.h" +#include "subtitle_content.h" #include "reel.h" #include "test.h" +#include "file.h" +#include "reel_mono_picture_asset.h" +#include "reel_sound_asset.h" #include "KM_util.h" +#include <sndfile.h> +#include <boost/test/unit_test.hpp> using boost::shared_ptr; @@ -35,43 +42,66 @@ BOOST_AUTO_TEST_CASE (dcp_test) Kumu::libdcp_test = true; /* Some known metadata */ - libdcp::XMLMetadata xml_meta; + dcp::XMLMetadata xml_meta; xml_meta.issuer = "OpenDCP 0.0.25"; xml_meta.creator = "OpenDCP 0.0.25"; xml_meta.issue_date = "2012-07-17T04:45:18+00:00"; - libdcp::MXFMetadata mxf_meta; + dcp::MXFMetadata mxf_meta; mxf_meta.company_name = "OpenDCP"; mxf_meta.product_name = "OpenDCP"; mxf_meta.product_version = "0.0.25"; - /* We're making build/test/DCP/foo */ + /* We're making build/test/foo */ boost::filesystem::remove_all ("build/test/DCP/foo"); boost::filesystem::create_directories ("build/test/DCP/foo"); - libdcp::DCP d ("build/test/DCP/foo"); - shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/DCP/foo", "A Test DCP", libdcp::FEATURE, 24, 24)); + dcp::DCP d ("build/test/DCP/foo"); + shared_ptr<dcp::CPL> cpl (new dcp::CPL ("A Test DCP", dcp::FEATURE)); + cpl->set_content_version_id ("urn:uri:81fb54df-e1bf-4647-8788-ea7ba154375b_2012-07-17T04:45:18+00:00"); + cpl->set_content_version_label_text ("81fb54df-e1bf-4647-8788-ea7ba154375b_2012-07-17T04:45:18+00:00"); - shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/DCP/foo", "video.mxf")); - mp->set_progress (&d.Progress); - mp->set_edit_rate (24); - mp->set_intrinsic_duration (24); - mp->set_duration (24); - mp->set_size (libdcp::Size (32, 32)); + shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF (dcp::Fraction (24, 1))); mp->set_metadata (mxf_meta); - mp->create (j2c); + shared_ptr<dcp::PictureMXFWriter> picture_writer = mp->start_write ("build/test/DCP/foo/video.mxf", dcp::SMPTE, false); + dcp::File j2c ("test/data/32x32_red_square.j2c"); + for (int i = 0; i < 24; ++i) { + picture_writer->write (j2c.data (), j2c.size ()); + } + picture_writer->finalize (); - shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/DCP/foo", "audio.mxf")); - ms->set_progress (&d.Progress); - ms->set_edit_rate (24); - ms->set_intrinsic_duration (24); - ms->set_duration (24); - ms->set_channels (2); + shared_ptr<dcp::SoundMXF> ms (new dcp::SoundMXF (dcp::Fraction (24, 1), 48000, 1)); ms->set_metadata (mxf_meta); - ms->create (wav); + shared_ptr<dcp::SoundMXFWriter> sound_writer = ms->start_write ("build/test/DCP/foo/audio.mxf", dcp::SMPTE); + + SF_INFO info; + info.format = 0; + SNDFILE* sndfile = sf_open ("test/data/1s_24-bit_48k_silence.wav", SFM_READ, &info); + BOOST_CHECK (sndfile); + float buffer[4096*6]; + float* channels[1]; + channels[0] = buffer; + while (1) { + sf_count_t N = sf_readf_float (sndfile, buffer, 4096); + sound_writer->write (channels, N); + if (N < 4096) { + break; + } + } + + sound_writer->finalize (); - cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ()))); - d.add_cpl (cpl); + cpl->add (shared_ptr<dcp::Reel> ( + new dcp::Reel ( + shared_ptr<dcp::ReelMonoPictureAsset> (new dcp::ReelMonoPictureAsset (mp, 0)), + shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (ms, 0)), + shared_ptr<dcp::ReelSubtitleAsset> () + ) + )); + + d.add (cpl); + d.add (mp); + d.add (ms); - d.write_xml (false, xml_meta); + d.write_xml (dcp::SMPTE, xml_meta); /* build/test/DCP/foo is checked against test/ref/DCP/foo by run-tests.sh */ } diff --git a/test/dcp_time_test.cc b/test/dcp_time_test.cc index 6892711e..2a5bca1b 100644 --- a/test/dcp_time_test.cc +++ b/test/dcp_time_test.cc @@ -20,10 +20,10 @@ #include <boost/test/unit_test.hpp> #include "dcp_time.h" -/** Check that libdcp::Time works */ +/** Check that dcp::Time works */ BOOST_AUTO_TEST_CASE (dcp_time) { - libdcp::Time t (977143, 24); + dcp::Time t (977143, 24); BOOST_CHECK_EQUAL (t.t, 73); BOOST_CHECK_EQUAL (t.s, 34); @@ -32,10 +32,10 @@ BOOST_AUTO_TEST_CASE (dcp_time) BOOST_CHECK_EQUAL (t.to_string(), "11:18:34:73"); BOOST_CHECK_EQUAL (t.to_ticks(), 10178573); - libdcp::Time a (3, 2, 3, 4); - libdcp::Time b (2, 3, 4, 5); + dcp::Time a (3, 2, 3, 4); + dcp::Time b (2, 3, 4, 5); - libdcp::Time r = a - b; + dcp::Time r = a - b; BOOST_CHECK_EQUAL (r.h, 0); BOOST_CHECK_EQUAL (r.m, 58); BOOST_CHECK_EQUAL (r.s, 58); @@ -43,8 +43,8 @@ BOOST_AUTO_TEST_CASE (dcp_time) BOOST_CHECK_EQUAL (r.to_string(), "0:58:58:249"); BOOST_CHECK_EQUAL (r.to_ticks(), 884749); - a = libdcp::Time (1, 58, 56, 240); - b = libdcp::Time (1, 7, 12, 120); + a = dcp::Time (1, 58, 56, 240); + b = dcp::Time (1, 7, 12, 120); r = a + b; BOOST_CHECK_EQUAL (r.h, 3); BOOST_CHECK_EQUAL (r.m, 6); @@ -53,10 +53,10 @@ BOOST_AUTO_TEST_CASE (dcp_time) BOOST_CHECK_EQUAL (r.to_string(), "3:6:9:110"); BOOST_CHECK_EQUAL (r.to_ticks(), 2792360); - a = libdcp::Time (24, 12, 6, 3); - b = libdcp::Time (16, 8, 4, 2); + a = dcp::Time (24, 12, 6, 3); + b = dcp::Time (16, 8, 4, 2); BOOST_CHECK_CLOSE (a / b, 1.5, 1e-5); - BOOST_CHECK_EQUAL (libdcp::Time (4128391203LL).to_ticks(), 4128391203LL); - BOOST_CHECK_EQUAL (libdcp::Time (60000).to_ticks(), 60000); + BOOST_CHECK_EQUAL (dcp::Time (4128391203LL).to_ticks(), 4128391203LL); + BOOST_CHECK_EQUAL (dcp::Time (60000).to_ticks(), 60000); } diff --git a/test/decryption_test.cc b/test/decryption_test.cc index d0e067ee..8dfeffa6 100644 --- a/test/decryption_test.cc +++ b/test/decryption_test.cc @@ -23,22 +23,23 @@ #include "mono_picture_frame.h" #include "cpl.h" #include "argb_frame.h" -#include "mono_picture_asset.h" +#include "mono_picture_mxf.h" +#include "reel_picture_asset.h" #include "reel.h" #include "test.h" using boost::dynamic_pointer_cast; using boost::shared_ptr; -static shared_ptr<const libdcp::ARGBFrame> -get_frame (libdcp::DCP const & dcp) +static shared_ptr<const dcp::ARGBFrame> +get_frame (dcp::DCP const & dcp) { - shared_ptr<const libdcp::Reel> reel = dcp.cpls().front()->reels().front (); - shared_ptr<const libdcp::PictureAsset> picture = reel->main_picture (); + shared_ptr<const dcp::Reel> reel = dcp.cpls().front()->reels().front (); + shared_ptr<dcp::PictureMXF> picture = reel->main_picture()->mxf (); BOOST_CHECK (picture); - shared_ptr<const libdcp::MonoPictureAsset> mono_picture = dynamic_pointer_cast<const libdcp::MonoPictureAsset> (picture); - shared_ptr<const libdcp::MonoPictureFrame> j2k_frame = mono_picture->get_frame (0); + shared_ptr<const dcp::MonoPictureMXF> mono_picture = dynamic_pointer_cast<const dcp::MonoPictureMXF> (picture); + shared_ptr<const dcp::MonoPictureFrame> j2k_frame = mono_picture->get_frame (0); return j2k_frame->argb_frame (); } @@ -47,25 +48,25 @@ BOOST_AUTO_TEST_CASE (decryption_test) { boost::filesystem::path plaintext_path = private_test; plaintext_path /= "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV"; - libdcp::DCP plaintext (plaintext_path.string ()); + dcp::DCP plaintext (plaintext_path.string ()); plaintext.read (); BOOST_CHECK_EQUAL (plaintext.encrypted (), false); boost::filesystem::path encrypted_path = private_test; encrypted_path /= "TONEPLATES-SMPTE-ENCRYPTED_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV"; - libdcp::DCP encrypted (encrypted_path.string ()); + dcp::DCP encrypted (encrypted_path.string ()); encrypted.read (); BOOST_CHECK_EQUAL (encrypted.encrypted (), true); - libdcp::KDM kdm ( + dcp::KDM kdm ( "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml", "test/data/private.key" ); - encrypted.add_kdm (kdm); + encrypted.add (kdm); - shared_ptr<const libdcp::ARGBFrame> plaintext_frame = get_frame (plaintext); - shared_ptr<const libdcp::ARGBFrame> encrypted_frame = get_frame (encrypted); + shared_ptr<const dcp::ARGBFrame> plaintext_frame = get_frame (plaintext); + shared_ptr<const dcp::ARGBFrame> encrypted_frame = get_frame (encrypted); /* Check that plaintext and encrypted are the same */ BOOST_CHECK_EQUAL (plaintext_frame->stride(), encrypted_frame->stride()); @@ -77,7 +78,7 @@ BOOST_AUTO_TEST_CASE (decryption_test) /** Load in a KDM that didn't work at first */ BOOST_AUTO_TEST_CASE (failing_kdm_test) { - libdcp::KDM kdm ( + dcp::KDM kdm ( "test/data/target.pem.crt.de5d4eba-e683-41ca-bdda-aa4ad96af3f4.kdm.xml", "test/data/private.key" ); diff --git a/test/encryption_test.cc b/test/encryption_test.cc index f08d4827..d029d4d5 100644 --- a/test/encryption_test.cc +++ b/test/encryption_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> 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 @@ -17,7 +17,6 @@ */ -#include <boost/test/unit_test.hpp> #include "kdm.h" #include "KM_util.h" #include "metadata.h" @@ -25,82 +24,83 @@ #include "dcp.h" #include "signer.h" #include "cpl.h" -#include "mono_picture_asset.h" -#include "sound_asset.h" +#include "mono_picture_mxf.h" +#include "picture_mxf_writer.h" +#include "sound_mxf.h" #include "reel.h" #include "test.h" +#include "file.h" #include "signer_chain.h" +#include "subtitle_content.h" +#include "reel_mono_picture_asset.h" +#include "reel_sound_asset.h" +#include <boost/test/unit_test.hpp> +#include <boost/shared_ptr.hpp> using boost::shared_ptr; /* Load a certificate chain from build/test/data/ *.pem and then build an encrypted DCP and a KDM using it. */ -BOOST_AUTO_TEST_CASE (encryption) +BOOST_AUTO_TEST_CASE (encryption_test) { boost::filesystem::remove_all ("build/test/signer"); boost::filesystem::create_directory ("build/test/signer"); - libdcp::make_signer_chain ("build/test/signer", "openssl"); + dcp::make_signer_chain ("build/test/signer", "openssl"); Kumu::libdcp_test = true; - libdcp::MXFMetadata mxf_metadata; + dcp::MXFMetadata mxf_metadata; mxf_metadata.company_name = "OpenDCP"; mxf_metadata.product_name = "OpenDCP"; mxf_metadata.product_version = "0.0.25"; - libdcp::XMLMetadata xml_metadata; + dcp::XMLMetadata xml_metadata; xml_metadata.issuer = "OpenDCP 0.0.25"; xml_metadata.creator = "OpenDCP 0.0.25"; xml_metadata.issue_date = "2012-07-17T04:45:18+00:00"; boost::filesystem::remove_all ("build/test/DCP/bar"); boost::filesystem::create_directories ("build/test/DCP/bar"); - libdcp::DCP d ("build/test/DCP/bar"); + dcp::DCP d ("build/test/DCP/bar"); /* Use test/ref/crypt so this test is repeatable */ - libdcp::CertificateChain chain; - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); + dcp::CertificateChain chain; + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/ca.self-signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/intermediate.signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("test/ref/crypt/leaf.signed.pem")))); - shared_ptr<libdcp::Signer> signer ( - new libdcp::Signer ( + shared_ptr<dcp::Signer> signer ( + new dcp::Signer ( chain, "test/ref/crypt/leaf.key" ) ); - shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/DCP/bar", "A Test DCP", libdcp::FEATURE, 24, 24)); + shared_ptr<dcp::CPL> cpl (new dcp::CPL ("A Test DCP", dcp::FEATURE)); - libdcp::Key key; + dcp::Key key; - shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/DCP/bar", "video.mxf")); - mp->set_progress (&d.Progress); - mp->set_edit_rate (24); - mp->set_intrinsic_duration (24); - mp->set_duration (24); - mp->set_size (libdcp::Size (32, 32)); + shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF (dcp::Fraction (24, 1))); mp->set_metadata (mxf_metadata); mp->set_key (key); - mp->create (j2c); - - shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/DCP/bar", "audio.mxf")); - ms->set_progress (&d.Progress); - ms->set_edit_rate (24); - ms->set_intrinsic_duration (24); - mp->set_duration (24); - ms->set_channels (2); - ms->set_metadata (mxf_metadata); - ms->set_key (key); - ms->create (wav); - - cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ()))); - d.add_cpl (cpl); - - d.write_xml (false, xml_metadata, signer); - libdcp::KDM kdm ( + shared_ptr<dcp::PictureMXFWriter> writer = mp->start_write ("build/test/DCP/bar/video.mxf", dcp::SMPTE, false); + dcp::File j2c ("test/data/32x32_red_square.j2c"); + for (int i = 0; i < 24; ++i) { + writer->write (j2c.data (), j2c.size ()); + } + writer->finalize (); + + cpl->add (shared_ptr<dcp::Reel> (new dcp::Reel ( + shared_ptr<dcp::ReelMonoPictureAsset> (new dcp::ReelMonoPictureAsset (mp, 0)), + shared_ptr<dcp::ReelSoundAsset> (), + shared_ptr<dcp::ReelSubtitleAsset> () + ))); + d.add (cpl); + d.write_xml (dcp::SMPTE, xml_metadata, signer); + + dcp::KDM kdm ( cpl, signer, signer->certificates().leaf(), diff --git a/test/error_test.cc b/test/error_test.cc deleted file mode 100644 index eeff4f41..00000000 --- a/test/error_test.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2013 Carl Hetherington <cth@carlh.net> - - 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 <boost/test/unit_test.hpp> -#include "dcp.h" -#include "mono_picture_asset.h" -#include "sound_asset.h" -#include "util.h" -#include "exceptions.h" - -using std::vector; -using std::string; - -/* Check that an exception is thrown when trying to create MXFs from non-existant sources */ -BOOST_AUTO_TEST_CASE (error_test) -{ - /* Create an empty DCP */ - libdcp::DCP d ("build/test/fred"); - - /* Random filename that does not exist */ - vector<boost::filesystem::path> p; - p.push_back ("frobozz"); - - /* Trying to create video/audio MXFs using a non-existant file should throw an exception */ - libdcp::MonoPictureAsset pa ("build/test/fred", "video.mxf"); - BOOST_CHECK_THROW (pa.create (p), libdcp::FileError); - - libdcp::SoundAsset sa ("build/test/fred", "audio.mxf"); - sa.set_channels (1); - BOOST_CHECK_THROW (sa.create (p), libdcp::FileError); -} diff --git a/test/frame_info_test.cc b/test/frame_info_test.cc index db73d7fb..02ff83aa 100644 --- a/test/frame_info_test.cc +++ b/test/frame_info_test.cc @@ -19,14 +19,15 @@ #include <fstream> #include <boost/test/unit_test.hpp> -#include "picture_asset_writer.h" +#include "picture_mxf.h" +#include "picture_mxf_writer.h" using namespace std; /* Test writing and reading of frame_info_test with fstream and stdio */ BOOST_AUTO_TEST_CASE (frame_info_test) { - libdcp::FrameInfo a (8589934592LL, 17179869184LL, "thisisahash"); + dcp::FrameInfo a (8589934592LL, 17179869184LL, "thisisahash"); ofstream o1 ("build/test/frame_info1"); a.write (o1); @@ -48,11 +49,11 @@ BOOST_AUTO_TEST_CASE (frame_info_test) BOOST_CHECK_EQUAL (s1, s2); ifstream l1 ("build/test/frame_info1"); - libdcp::FrameInfo b1 (l1); + dcp::FrameInfo b1 (l1); FILE* l2 = fopen ("build/test/frame_info2", "r"); BOOST_CHECK (l2); - libdcp::FrameInfo b2 (l2); + dcp::FrameInfo b2 (l2); BOOST_CHECK_EQUAL (b1.offset, b2.offset); BOOST_CHECK_EQUAL (b1.size, b2.size); diff --git a/test/kdm_key_test.cc b/test/kdm_key_test.cc index 05b85312..4a84fe3b 100644 --- a/test/kdm_key_test.cc +++ b/test/kdm_key_test.cc @@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE (kdm_key_test) { uint8_t foo[138]; memset (foo, 0, 138); - libdcp::KDMKey kkey (foo, 138); + dcp::KDMKey kkey (foo, 138); uint8_t* raw = new uint8_t[16]; uint8_t* p = raw; diff --git a/test/kdm_test.cc b/test/kdm_test.cc index 0f0db031..a3928f7a 100644 --- a/test/kdm_test.cc +++ b/test/kdm_test.cc @@ -19,19 +19,19 @@ #include <boost/test/unit_test.hpp> #include "kdm.h" -#include "xml/kdm_smpte.h" +#include "kdm_smpte_xml.h" using std::list; using boost::shared_ptr; BOOST_AUTO_TEST_CASE (kdm_test) { - libdcp::KDM kdm ( + dcp::KDM kdm ( "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml", "test/data/private.key" ); - list<libdcp::KDMKey> keys = kdm.keys (); + list<dcp::KDMKey> keys = kdm.keys (); BOOST_CHECK_EQUAL (keys.size(), 2); @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE (kdm_test) /* Check that we can read in a KDM and then write it back out again the same */ BOOST_AUTO_TEST_CASE (kdm_passthrough_test) { - libdcp::xml::DCinemaSecurityMessage kdm ( + dcp::xml::DCinemaSecurityMessage kdm ( "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml" ); diff --git a/test/lut_test.cc b/test/lut_test.cc deleted file mode 100644 index c90dff76..00000000 --- a/test/lut_test.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2013 Carl Hetherington <cth@carlh.net> - - 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 <boost/test/unit_test.hpp> -#include "opendcp_lut.h" -#include "opendcp_lut.cc" -#include "srgb_linearised_gamma_lut.h" -#include "rec709_linearised_gamma_lut.h" -#include "gamma_lut.h" - -/* Check that some of our LUTs match the ones from OpenDCP that - DVD-o-matic uses / once used. -*/ -BOOST_AUTO_TEST_CASE (lut_test) -{ - libdcp::SRGBLinearisedGammaLUT lut_in_srgb (12, 2.4); - for (int i = 0; i < 4096; ++i) { - /* Hmm; 1% isn't exactly great... */ - BOOST_CHECK_CLOSE (opendcp::lut_in[0][i], lut_in_srgb.lut()[i], 1); - } - - libdcp::Rec709LinearisedGammaLUT lut_in_rec709 (12, 1 / 0.45); - for (int i = 0; i < 4096; ++i) { - /* Hmm; 1% isn't exactly great... */ - BOOST_CHECK_CLOSE (opendcp::lut_in[1][i], lut_in_rec709.lut()[i], 1); - } - - libdcp::GammaLUT lut_out (16, 1 / 2.6); - for (int i = 0; i < 65536; ++i) { - BOOST_CHECK_CLOSE (opendcp::lut_out[0][i], lut_out.lut()[i] * 4096, 1); - } -} diff --git a/test/read_dcp_test.cc b/test/read_dcp_test.cc index 0a9ac119..a17b0a01 100644 --- a/test/read_dcp_test.cc +++ b/test/read_dcp_test.cc @@ -27,14 +27,12 @@ using boost::shared_ptr; /* Read DCP that is in git and make sure that basic stuff is read in correctly */ BOOST_AUTO_TEST_CASE (read_dcp) { - libdcp::DCP d ("test/ref/DCP/foo"); + dcp::DCP d ("test/ref/DCP/foo"); d.read (); - list<shared_ptr<libdcp::CPL> > cpls = d.cpls (); + list<shared_ptr<dcp::CPL> > cpls = d.cpls (); BOOST_CHECK_EQUAL (cpls.size(), 1); - BOOST_CHECK_EQUAL (cpls.front()->name(), "A Test DCP"); - BOOST_CHECK_EQUAL (cpls.front()->content_kind(), libdcp::FEATURE); - BOOST_CHECK_EQUAL (cpls.front()->frames_per_second(), 24); - BOOST_CHECK_EQUAL (cpls.front()->length(), 24); + BOOST_CHECK_EQUAL (cpls.front()->annotation_text(), "A Test DCP"); + BOOST_CHECK_EQUAL (cpls.front()->content_kind(), dcp::FEATURE); } diff --git a/test/recovery_test.cc b/test/recovery_test.cc index 42697c37..1d51a711 100644 --- a/test/recovery_test.cc +++ b/test/recovery_test.cc @@ -19,8 +19,8 @@ #include <boost/test/unit_test.hpp> #include <boost/filesystem.hpp> -#include "mono_picture_asset_writer.h" -#include "mono_picture_asset.h" +#include "mono_picture_mxf_writer.h" +#include "mono_picture_mxf.h" #include "KM_util.h" using std::string; @@ -48,14 +48,12 @@ BOOST_AUTO_TEST_CASE (recovery) boost::filesystem::remove_all ("build/test/baz"); boost::filesystem::create_directories ("build/test/baz"); - shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/baz", "video1.mxf")); - mp->set_edit_rate (24); - mp->set_size (libdcp::Size (32, 32)); - shared_ptr<libdcp::PictureAssetWriter> writer = mp->start_write (false); + shared_ptr<dcp::MonoPictureMXF> mp (new dcp::MonoPictureMXF (dcp::Fraction (24, 1))); + shared_ptr<dcp::PictureMXFWriter> writer = mp->start_write ("build/test/baz/video1.mxf", dcp::SMPTE, false); int written_size = 0; for (int i = 0; i < 24; ++i) { - libdcp::FrameInfo info = writer->write (data, size); + dcp::FrameInfo info = writer->write (data, size); written_size = info.size; } @@ -78,10 +76,8 @@ BOOST_AUTO_TEST_CASE (recovery) Kumu::ResetTestRNG (); #endif - mp.reset (new libdcp::MonoPictureAsset ("build/test/baz", "video2.mxf")); - mp->set_edit_rate (24); - mp->set_size (libdcp::Size (32, 32)); - writer = mp->start_write (true); + mp.reset (new dcp::MonoPictureMXF (dcp::Fraction (24, 1))); + writer = mp->start_write ("build/test/baz/video2.mxf", dcp::SMPTE, true); writer->write (data, size); diff --git a/test/rewrite_subs.cc b/test/rewrite_subs.cc index 3a982d1b..3b177b21 100644 --- a/test/rewrite_subs.cc +++ b/test/rewrite_subs.cc @@ -1,15 +1,35 @@ +/* + Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + + 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 <iostream> #include "dcp.h" #include "cpl.h" #include "reel.h" -#include "subtitle_asset.h" +#include "subtitle_content.h" +#include "reel_subtitle_asset.h" #include "exceptions.h" using std::cout; using std::cerr; using std::list; using boost::shared_ptr; -using namespace libdcp; +using namespace dcp; int main (int argc, char* argv[]) @@ -21,7 +41,7 @@ main (int argc, char* argv[]) } DCP* dcp = new DCP (argv[1]); - dcp->read (false); + dcp->read (); list<shared_ptr<CPL> > cpls = dcp->cpls (); for (list<boost::shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) { @@ -30,7 +50,7 @@ main (int argc, char* argv[]) for (list<shared_ptr<Reel> >::iterator j = reels.begin(); j != reels.end(); ++j) { if ((*j)->main_subtitle()) { - (*j)->main_subtitle()->write_xml (); + (*j)->main_subtitle()->subtitle_content()->write_xml (); } } } diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index a6ee2097..e94d8c72 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -17,19 +17,23 @@ */ -#include <iostream> -#include <boost/test/unit_test.hpp> #include "certificates.h" #include "kdm.h" #include "signer.h" -#include "mono_picture_asset.h" -#include "sound_asset.h" +#include "mono_picture_mxf.h" +#include "sound_mxf.h" #include "reel.h" #include "test.h" #include "cpl.h" #include "mono_picture_frame.h" #include "argb_frame.h" #include "signer_chain.h" +#include "mono_picture_mxf_writer.h" +#include "reel_picture_asset.h" +#include "reel_mono_picture_asset.h" +#include "file.h" +#include <boost/test/unit_test.hpp> +#include <iostream> using std::list; using boost::shared_ptr; @@ -39,15 +43,15 @@ BOOST_AUTO_TEST_CASE (round_trip_test) { boost::filesystem::remove_all ("build/test/signer"); boost::filesystem::create_directory ("build/test/signer"); - libdcp::make_signer_chain ("build/test/signer", "openssl"); + dcp::make_signer_chain ("build/test/signer", "openssl"); - libdcp::CertificateChain chain; - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/ca.self-signed.pem")))); - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/intermediate.signed.pem")))); - chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/leaf.signed.pem")))); + dcp::CertificateChain chain; + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("build/test/signer/ca.self-signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("build/test/signer/intermediate.signed.pem")))); + chain.add (shared_ptr<dcp::Certificate> (new dcp::Certificate (boost::filesystem::path ("build/test/signer/leaf.signed.pem")))); - shared_ptr<libdcp::Signer> signer ( - new libdcp::Signer ( + shared_ptr<dcp::Signer> signer ( + new dcp::Signer ( chain, "test/data/signer.key" ) @@ -56,21 +60,25 @@ BOOST_AUTO_TEST_CASE (round_trip_test) boost::filesystem::path work_dir = "build/test/round_trip_test"; boost::filesystem::create_directory (work_dir); - shared_ptr<libdcp::MonoPictureAsset> asset_A (new libdcp::MonoPictureAsset (work_dir, "video.mxf")); - asset_A->set_edit_rate (24); - asset_A->set_intrinsic_duration (24); - asset_A->set_size (libdcp::Size (32, 32)); - asset_A->create (j2c); + shared_ptr<dcp::MonoPictureMXF> mxf_A (new dcp::MonoPictureMXF (dcp::Fraction (24, 1))); + shared_ptr<dcp::PictureMXFWriter> writer = mxf_A->start_write (work_dir / "video.mxf", dcp::SMPTE, false); + dcp::File j2c ("test/data/32x32_red_square.j2c"); + for (int i = 0; i < 24; ++i) { + writer->write (j2c.data (), j2c.size ()); + } + writer->finalize (); - libdcp::Key key; + dcp::Key key; - asset_A->set_key (key); + mxf_A->set_key (key); - shared_ptr<libdcp::CPL> cpl (new libdcp::CPL (work_dir, "A Test DCP", libdcp::FEATURE, 24, 24)); - cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (asset_A, shared_ptr<libdcp::SoundAsset> (), shared_ptr<libdcp::SubtitleAsset> ()))); + shared_ptr<dcp::CPL> cpl (new dcp::CPL ("A Test DCP", dcp::FEATURE)); + shared_ptr<dcp::Reel> reel (new dcp::Reel ()); + reel->add (shared_ptr<dcp::ReelMonoPictureAsset> (new dcp::ReelMonoPictureAsset (mxf_A, 0))); + cpl->add (reel); /* A KDM using our certificate chain's leaf key pair */ - libdcp::KDM kdm_A ( + dcp::KDM kdm_A ( cpl, signer, signer->certificates().leaf(), @@ -85,14 +93,14 @@ BOOST_AUTO_TEST_CASE (round_trip_test) kdm_A.as_xml (kdm_file); /* Reload the KDM, using our private key to decrypt it */ - libdcp::KDM kdm_B (kdm_file, "build/test/signer/leaf.key"); + dcp::KDM kdm_B (kdm_file, "build/test/signer/leaf.key"); /* Check that the decrypted KDMKeys are the same as the ones we started with */ BOOST_CHECK_EQUAL (kdm_A.keys().size(), kdm_B.keys().size()); - list<libdcp::KDMKey> keys_A = kdm_A.keys (); - list<libdcp::KDMKey> keys_B = kdm_B.keys (); - list<libdcp::KDMKey>::const_iterator i = keys_A.begin(); - list<libdcp::KDMKey>::const_iterator j = keys_B.begin(); + list<dcp::KDMKey> keys_A = kdm_A.keys (); + list<dcp::KDMKey> keys_B = kdm_B.keys (); + list<dcp::KDMKey>::const_iterator i = keys_A.begin(); + list<dcp::KDMKey>::const_iterator j = keys_B.begin(); while (i != keys_A.end ()) { BOOST_CHECK (*i == *j); ++i; @@ -100,14 +108,15 @@ BOOST_AUTO_TEST_CASE (round_trip_test) } /* Reload the picture MXF */ - shared_ptr<libdcp::MonoPictureAsset> asset_B ( - new libdcp::MonoPictureAsset (work_dir, "video.mxf") + shared_ptr<dcp::MonoPictureMXF> mxf_B ( + new dcp::MonoPictureMXF (work_dir / "video.mxf") ); - asset_B->set_key (kdm_B.keys().front().key()); + BOOST_CHECK (!kdm_B.keys().empty ()); + mxf_B->set_key (kdm_B.keys().front().key()); - shared_ptr<libdcp::ARGBFrame> frame_A = asset_A->get_frame(0)->argb_frame (); - shared_ptr<libdcp::ARGBFrame> frame_B = asset_B->get_frame(0)->argb_frame (); + shared_ptr<dcp::ARGBFrame> frame_A = mxf_A->get_frame(0)->argb_frame (); + shared_ptr<dcp::ARGBFrame> frame_B = mxf_B->get_frame(0)->argb_frame (); BOOST_CHECK_EQUAL (frame_A->size().width, frame_B->size().width); BOOST_CHECK_EQUAL (frame_A->size().height, frame_B->size().height); BOOST_CHECK_EQUAL (memcmp (frame_A->data(), frame_B->data(), frame_A->size().width * frame_A->size().height), 0); diff --git a/test/subs_in_out.cc b/test/subs_in_out.cc index f0a7e96f..9b2c2e9b 100644 --- a/test/subs_in_out.cc +++ b/test/subs_in_out.cc @@ -1,5 +1,5 @@ #include <iostream> -#include "subtitle_asset.h" +#include "subtitle_content.h" using namespace std; @@ -10,8 +10,7 @@ int main (int argc, char* argv[]) exit (EXIT_FAILURE); } - libdcp::SubtitleAsset s ("foo", "bar", "baz"); - s.read_xml (argv[1]); + dcp::SubtitleContent s (argv[1]); cout << s.xml_as_string (); return 0; } diff --git a/test/subtitle_tests.cc b/test/subtitle_tests.cc index a8fa78b7..77dd29d7 100644 --- a/test/subtitle_tests.cc +++ b/test/subtitle_tests.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> 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 @@ -17,407 +17,408 @@ */ +#include "subtitle_content.h" +#include "subtitle_string.h" #include <boost/test/unit_test.hpp> -#include "subtitle_asset.h" using std::list; using boost::shared_ptr; -/* Load a subtitle asset from XML and check that it is read correctly */ +/* Load some subtitle content from XML and check that it is read correctly */ BOOST_AUTO_TEST_CASE (subtitles1) { - libdcp::SubtitleAsset subs ("test/data", "subs1.xml"); + dcp::SubtitleContent subs ("test/data/subs1.xml"); BOOST_CHECK_EQUAL (subs.language(), "French"); - list<shared_ptr<libdcp::Subtitle> > s = subs.subtitles_at (libdcp::Time (0, 0, 6, 1)); + list<shared_ptr<dcp::SubtitleString> > s = subs.subtitles_at (dcp::Time (0, 0, 6, 1)); BOOST_CHECK_EQUAL (s.size(), 1); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 39, - libdcp::Time (0, 0, 5, 198), - libdcp::Time (0, 0, 7, 115), + dcp::Time (0, 0, 5, 198), + dcp::Time (0, 0, 7, 115), 15, - libdcp::BOTTOM, + dcp::BOTTOM, "My jacket was Idi Amin's", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 1), - libdcp::Time (0, 0, 0, 1) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 1), + dcp::Time (0, 0, 0, 1) )); - s = subs.subtitles_at (libdcp::Time (0, 0, 7, 190)); + s = subs.subtitles_at (dcp::Time (0, 0, 7, 190)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 39, - libdcp::Time (0, 0, 7, 177), - libdcp::Time (0, 0, 11, 31), + dcp::Time (0, 0, 7, 177), + dcp::Time (0, 0, 11, 31), 21, - libdcp::BOTTOM, + dcp::BOTTOM, "My corset was H.M. The Queen's", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 1), - libdcp::Time (0, 0, 0, 1) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 1), + dcp::Time (0, 0, 0, 1) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 39, - libdcp::Time (0, 0, 7, 177), - libdcp::Time (0, 0, 11, 31), + dcp::Time (0, 0, 7, 177), + dcp::Time (0, 0, 11, 31), 15, - libdcp::BOTTOM, + dcp::BOTTOM, "My large wonderbra", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 1), - libdcp::Time (0, 0, 0, 1) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 1), + dcp::Time (0, 0, 0, 1) )); - s = subs.subtitles_at (libdcp::Time (0, 0, 11, 95)); + s = subs.subtitles_at (dcp::Time (0, 0, 11, 95)); BOOST_CHECK_EQUAL (s.size(), 1); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 39, - libdcp::Time (0, 0, 11, 94), - libdcp::Time (0, 0, 13, 63), + dcp::Time (0, 0, 11, 94), + dcp::Time (0, 0, 13, 63), 15, - libdcp::BOTTOM, + dcp::BOTTOM, "Once belonged to the Shah", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 1), - libdcp::Time (0, 0, 0, 1) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 1), + dcp::Time (0, 0, 0, 1) )); - s = subs.subtitles_at (libdcp::Time (0, 0, 14, 42)); + s = subs.subtitles_at (dcp::Time (0, 0, 14, 42)); BOOST_CHECK_EQUAL (s.size(), 1); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 39, - libdcp::Time (0, 0, 13, 104), - libdcp::Time (0, 0, 15, 177), + dcp::Time (0, 0, 13, 104), + dcp::Time (0, 0, 15, 177), 15, - libdcp::BOTTOM, + dcp::BOTTOM, "And these are Roy Hattersley's jeans", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 1), - libdcp::Time (0, 0, 0, 1) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 1), + dcp::Time (0, 0, 0, 1) )); } /** And similarly for another one */ BOOST_AUTO_TEST_CASE (subtitles2) { - libdcp::SubtitleAsset subs ("test/data", "subs2.xml"); + dcp::SubtitleContent subs ("test/data/subs2.xml"); - list<shared_ptr<libdcp::Subtitle> > s = subs.subtitles_at (libdcp::Time (0, 0, 42, 100)); + list<shared_ptr<dcp::SubtitleString> > s = subs.subtitles_at (dcp::Time (0, 0, 42, 100)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 0, 41, 62), - libdcp::Time (0, 0, 43, 52), + dcp::Time (0, 0, 41, 62), + dcp::Time (0, 0, 43, 52), 89, - libdcp::TOP, + dcp::TOP, "At afternoon tea with John Peel", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 0, 41, 62), - libdcp::Time (0, 0, 43, 52), + dcp::Time (0, 0, 41, 62), + dcp::Time (0, 0, 43, 52), 95, - libdcp::TOP, + dcp::TOP, "I enquired if his accent was real", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 0, 50, 50)); + s = subs.subtitles_at (dcp::Time (0, 0, 50, 50)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 0, 50, 42), - libdcp::Time (0, 0, 52, 21), + dcp::Time (0, 0, 50, 42), + dcp::Time (0, 0, 52, 21), 89, - libdcp::TOP, + dcp::TOP, "He said \"out of the house", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 0, 50, 42), - libdcp::Time (0, 0, 52, 21), + dcp::Time (0, 0, 50, 42), + dcp::Time (0, 0, 52, 21), 95, - libdcp::TOP, + dcp::TOP, "I'm incredibly scouse", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 1, 2, 300)); + s = subs.subtitles_at (dcp::Time (0, 1, 2, 300)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 2, 208), - libdcp::Time (0, 1, 4, 10), + dcp::Time (0, 1, 2, 208), + dcp::Time (0, 1, 4, 10), 89, - libdcp::TOP, + dcp::TOP, "At home it depends how I feel.\"", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 2, 208), - libdcp::Time (0, 1, 4, 10), + dcp::Time (0, 1, 2, 208), + dcp::Time (0, 1, 4, 10), 95, - libdcp::TOP, + dcp::TOP, "I spent a long weekend in Brighton", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 1, 15, 50)); + s = subs.subtitles_at (dcp::Time (0, 1, 15, 50)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 15, 42), - libdcp::Time (0, 1, 16, 42), + dcp::Time (0, 1, 15, 42), + dcp::Time (0, 1, 16, 42), 89, - libdcp::TOP, + dcp::TOP, "With the legendary Miss Enid Blyton", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 15, 42), - libdcp::Time (0, 1, 16, 42), + dcp::Time (0, 1, 15, 42), + dcp::Time (0, 1, 16, 42), 95, - libdcp::TOP, + dcp::TOP, "She said \"you be Noddy", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 1, 27, 200)); + s = subs.subtitles_at (dcp::Time (0, 1, 27, 200)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 27, 115), - libdcp::Time (0, 1, 28, 208), + dcp::Time (0, 1, 27, 115), + dcp::Time (0, 1, 28, 208), 89, - libdcp::TOP, + dcp::TOP, "That curious creature the Sphinx", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 27, 115), - libdcp::Time (0, 1, 28, 208), + dcp::Time (0, 1, 27, 115), + dcp::Time (0, 1, 28, 208), 95, - libdcp::TOP, + dcp::TOP, "Is smarter than anyone thinks", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 1, 42, 300)); + s = subs.subtitles_at (dcp::Time (0, 1, 42, 300)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 42, 229), - libdcp::Time (0, 1, 45, 62), + dcp::Time (0, 1, 42, 229), + dcp::Time (0, 1, 45, 62), 89, - libdcp::TOP, + dcp::TOP, "It sits there and smirks", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 42, 229), - libdcp::Time (0, 1, 45, 62), + dcp::Time (0, 1, 42, 229), + dcp::Time (0, 1, 45, 62), 95, - libdcp::TOP, + dcp::TOP, "And you don't think it works", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 1, 45, 200)); + s = subs.subtitles_at (dcp::Time (0, 1, 45, 200)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 45, 146), - libdcp::Time (0, 1, 47, 94), + dcp::Time (0, 1, 45, 146), + dcp::Time (0, 1, 47, 94), 89, - libdcp::TOP, + dcp::TOP, "Then when you're not looking, it winks.", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 45, 146), - libdcp::Time (0, 1, 47, 94), + dcp::Time (0, 1, 45, 146), + dcp::Time (0, 1, 47, 94), 95, - libdcp::TOP, + dcp::TOP, "When it snows you will find Sister Sledge", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 1, 47, 249)); + s = subs.subtitles_at (dcp::Time (0, 1, 47, 249)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 47, 146), - libdcp::Time (0, 1, 48, 167), + dcp::Time (0, 1, 47, 146), + dcp::Time (0, 1, 48, 167), 89, - libdcp::TOP, + dcp::TOP, "Out mooning, at night, on the ledge", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", false, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 1, 47, 146), - libdcp::Time (0, 1, 48, 167), + dcp::Time (0, 1, 47, 146), + dcp::Time (0, 1, 48, 167), 95, - libdcp::TOP, + dcp::TOP, "One storey down", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - s = subs.subtitles_at (libdcp::Time (0, 2, 6, 210)); + s = subs.subtitles_at (dcp::Time (0, 2, 6, 210)); BOOST_CHECK_EQUAL (s.size(), 2); - BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.front().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 2, 5, 208), - libdcp::Time (0, 2, 7, 31), + dcp::Time (0, 2, 5, 208), + dcp::Time (0, 2, 7, 31), 89, - libdcp::TOP, + dcp::TOP, "HELLO", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); - BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + BOOST_CHECK_EQUAL (*(s.back().get()), dcp::SubtitleString ( "Arial", true, - libdcp::Color (255, 255, 255), + dcp::Color (255, 255, 255), 42, - libdcp::Time (0, 2, 5, 208), - libdcp::Time (0, 2, 7, 31), + dcp::Time (0, 2, 5, 208), + dcp::Time (0, 2, 7, 31), 95, - libdcp::TOP, + dcp::TOP, "WORLD", - libdcp::BORDER, - libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 0), - libdcp::Time (0, 0, 0, 0) + dcp::BORDER, + dcp::Color (0, 0, 0), + dcp::Time (0, 0, 0, 0), + dcp::Time (0, 0, 0, 0) )); diff --git a/test/test.cc b/test/test.cc index c58966f4..0b56b903 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; @@ -28,7 +29,7 @@ struct TestConfig { TestConfig() { - libdcp::init (); + dcp::init (); } }; @@ -41,7 +42,7 @@ j2c (int) } boost::filesystem::path -wav (libdcp::Channel) +wav (dcp::Channel) { return "test/data/1s_24-bit_48k_silence.wav"; } diff --git a/test/test.h b/test/test.h index 47a615d8..f139fa28 100644 --- a/test/test.h +++ b/test/test.h @@ -17,6 +17,4 @@ */ -extern boost::filesystem::path j2c (int); -extern boost::filesystem::path wav (libdcp::Channel); extern std::string private_test; diff --git a/test/utc_offset_to_string_test.cc b/test/utc_offset_to_string_test.cc index af9c6533..3b4e0b46 100644 --- a/test/utc_offset_to_string_test.cc +++ b/test/utc_offset_to_string_test.cc @@ -21,12 +21,12 @@ #include "metadata.h" #include "util.h" -/** Test libdcp::utc_offset_to_string */ +/** Test dcp::utc_offset_to_string */ BOOST_AUTO_TEST_CASE (utc_offset_to_string_test) { - BOOST_CHECK_EQUAL (libdcp::utc_offset_to_string (30), "+00:30"); - BOOST_CHECK_EQUAL (libdcp::utc_offset_to_string (60), "+01:00"); - BOOST_CHECK_EQUAL (libdcp::utc_offset_to_string (61), "+01:01"); - BOOST_CHECK_EQUAL (libdcp::utc_offset_to_string (7 * 60), "+07:00"); - BOOST_CHECK_EQUAL (libdcp::utc_offset_to_string (-11 * 60), "-11:00"); + BOOST_CHECK_EQUAL (dcp::utc_offset_to_string (30), "+00:30"); + BOOST_CHECK_EQUAL (dcp::utc_offset_to_string (60), "+01:00"); + BOOST_CHECK_EQUAL (dcp::utc_offset_to_string (61), "+01:01"); + BOOST_CHECK_EQUAL (dcp::utc_offset_to_string (7 * 60), "+07:00"); + BOOST_CHECK_EQUAL (dcp::utc_offset_to_string (-11 * 60), "-11:00"); } diff --git a/test/util_test.cc b/test/util_test.cc index f7114e90..15f22f57 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE (base64_decode_test) } unsigned char decoded[N]; - int const r = libdcp::base64_decode (s, decoded, N); + int const r = dcp::base64_decode (s, decoded, N); BOOST_CHECK_EQUAL (r, N); for (int i = 0; i < N; ++i) { @@ -57,16 +57,59 @@ BOOST_AUTO_TEST_CASE (base64_decode_test) BOOST_AUTO_TEST_CASE (content_kind_test) { - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("feature"), libdcp::FEATURE); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("Feature"), libdcp::FEATURE); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("FeaturE"), libdcp::FEATURE); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("Short"), libdcp::SHORT); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("trailer"), libdcp::TRAILER); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("test"), libdcp::TEST); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("transitional"), libdcp::TRANSITIONAL); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("rating"), libdcp::RATING); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("teaser"), libdcp::TEASER); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("policy"), libdcp::POLICY); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("psa"), libdcp::PUBLIC_SERVICE_ANNOUNCEMENT); - BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("advertisement"), libdcp::ADVERTISEMENT); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("feature"), dcp::FEATURE); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("Feature"), dcp::FEATURE); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("FeaturE"), dcp::FEATURE); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("Short"), dcp::SHORT); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("trailer"), dcp::TRAILER); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("test"), dcp::TEST); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("transitional"), dcp::TRANSITIONAL); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("rating"), dcp::RATING); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("teaser"), dcp::TEASER); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("policy"), dcp::POLICY); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("psa"), dcp::PUBLIC_SERVICE_ANNOUNCEMENT); + BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("advertisement"), dcp::ADVERTISEMENT); +} + +BOOST_AUTO_TEST_CASE (relative_to_root_test) +{ + { + boost::filesystem::path root = "a"; + root /= "b"; + + boost::filesystem::path file = "a"; + file /= "b"; + file /= "c"; + + boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file); + BOOST_CHECK (rel); + BOOST_CHECK_EQUAL (rel.get(), boost::filesystem::path ("c")); + } + + { + boost::filesystem::path root = "a"; + root /= "b"; + root /= "c"; + + boost::filesystem::path file = "a"; + file /= "b"; + + boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file); + BOOST_CHECK (!rel); + } + + { + boost::filesystem::path root = "a"; + + boost::filesystem::path file = "a"; + file /= "b"; + file /= "c"; + + boost::optional<boost::filesystem::path> rel = dcp::relative_to_root (root, file); + BOOST_CHECK (rel); + + boost::filesystem::path check = "b"; + check /= "c"; + BOOST_CHECK_EQUAL (rel.get(), check); + } } diff --git a/test/wscript b/test/wscript index 7bb68252..407765af 100644 --- a/test/wscript +++ b/test/wscript @@ -4,35 +4,33 @@ def configure(conf): else: boost_lib_suffix = '' - conf.check_cxx(fragment = """ - #define BOOST_TEST_MODULE Config test\n - #include <boost/test/unit_test.hpp>\n - int main() {} - """, - msg = 'Checking for boost unit testing library', - lib = 'boost_unit_test_framework%s' % boost_lib_suffix, - uselib_store = 'BOOST_TEST') + conf.check_cxx(fragment=""" + #define BOOST_TEST_MODULE Config test\n + #include <boost/test/unit_test.hpp>\n + int main() {} + """, + msg='Checking for boost unit testing library', + lib='boost_unit_test_framework%s' % boost_lib_suffix, + uselib_store='BOOST_TEST') conf.env.prepend_value('LINKFLAGS', '-Lsrc') def build(bld): - obj = bld(features = 'cxx cxxprogram') + obj = bld(features='cxx cxxprogram') obj.name = 'tests' - obj.uselib = 'BOOST_TEST OPENJPEG CXML XMLSEC1' - obj.use = 'libdcp' + obj.uselib = 'BOOST_TEST OPENJPEG CXML XMLSEC1 SNDFILE' + obj.use = 'libdcp%s' % bld.env.API_VERSION obj.source = """ certificates_test.cc color_test.cc - cpl_sar.cc + cpl_sar_test.cc dcp_test.cc dcp_time_test.cc decryption_test.cc encryption_test.cc - error_test.cc frame_info_test.cc kdm_key_test.cc kdm_test.cc - lut_test.cc read_dcp_test.cc recovery_test.cc round_trip_test.cc @@ -44,18 +42,18 @@ def build(bld): obj.target = 'tests' obj.install_path = '' - obj = bld(features = 'cxx cxxprogram') + obj = bld(features='cxx cxxprogram') obj.name = 'subs_in_out' obj.uselib = 'BOOST_TEST OPENJPEG CXML' - obj.use = 'libdcp' + obj.use = 'libdcp%s' % bld.env.API_VERSION obj.source = 'subs_in_out.cc' obj.target = 'subs_in_out' obj.install_path = '' - obj = bld(features = 'cxx cxxprogram') + obj = bld(features='cxx cxxprogram') obj.name = 'rewrite_subs' obj.uselib = 'BOOST_TEST OPENJPEG CXML' - obj.use = 'libdcp' + obj.use = 'libdcp%s' % bld.env.API_VERSION obj.source = 'rewrite_subs.cc' obj.target = 'rewrite_subs' obj.install_path = '' |
