summaryrefslogtreecommitdiff
path: root/test/open_caption_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-28 17:46:42 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-28 17:46:42 +0200
commit85eebdf558ca89ce53bb59a0127f1c804e82981b (patch)
treebb7e6c654ed281ced61cece92452481a7f396288 /test/open_caption_test.cc
parent632fd6b46be907c044474a09ffffad6cccb14d08 (diff)
Diffstat (limited to 'test/open_caption_test.cc')
-rw-r--r--test/open_caption_test.cc73
1 files changed, 73 insertions, 0 deletions
diff --git a/test/open_caption_test.cc b/test/open_caption_test.cc
new file mode 100644
index 00000000..f0dce3f7
--- /dev/null
+++ b/test/open_caption_test.cc
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp 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.
+
+ libdcp 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 libdcp. If not, see <http://www.gnu.org/licenses/>.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of portions of this program with the
+ OpenSSL library under certain conditions as described in each
+ individual source file, and distribute linked combinations
+ including the two.
+
+ You must obey the GNU General Public License in all respects
+ for all of the code used other than OpenSSL. If you modify
+ file(s) with this exception, you may extend this exception to your
+ version of the file(s), but you are not obligated to do so. If you
+ do not wish to do so, delete this exception statement from your
+ version. If you delete this exception statement from all source
+ files in the program, then also delete it here.
+*/
+
+
+#include "cpl.h"
+#include "reel.h"
+#include "reel_smpte_caption_asset.h"
+#include "smpte_subtitle_asset.h"
+#include "test.h"
+#include <boost/test/unit_test.hpp>
+
+
+using std::make_shared;
+
+
+BOOST_AUTO_TEST_CASE(create_open_caption_test)
+{
+ auto subs = make_shared<dcp::SMPTESubtitleAsset>("test/data/subs.mxf");
+ auto reel_asset = make_shared<dcp::ReelSMPTECaptionAsset>(subs, dcp::Fraction{24, 1}, 480, 0, dcp::TextType::OPEN);
+
+ auto reel = make_shared<dcp::Reel>();
+ reel->add(reel_asset);
+
+ auto cpl = make_shared<dcp::CPL>("Foo", dcp::ContentKind::FEATURE, dcp::Standard::SMPTE);
+ cpl->add(reel);
+
+ auto dcp_dir = boost::filesystem::path("build/test/create_open_caption_test");
+ boost::system::error_code ec;
+ boost::filesystem::remove_all(dcp_dir, ec);
+ boost::filesystem::create_directories(dcp_dir);
+
+ cpl->write_xml("build/test/create_open_caption_test/cpl.xml", {});
+ check_xml(dcp::file_to_string("test/data/create_open_caption_test.xml"), dcp::file_to_string("build/test/create_open_caption_test/cpl.xml"), {"Id", "IssueDate", "LabelText"});
+
+ /* XXX */
+
+ auto dcp = make_simple(dcp_dir, 1, 24 * 60 * 5, dcp::Standard::SMPTE, {});
+ boost::filesystem::copy_file(*subs->file(), dcp_dir / "subs.mxf");
+ subs->set_file(dcp_dir / "subs.mxf");
+ dcp->cpls()[0]->reels()[0]->add(reel_asset);
+ dcp->write_xml();
+}
+