*/
+
+#include "lib/config.h"
#include "lib/create_cli.h"
+#include "lib/film.h"
#include "lib/ratio.h"
#include "lib/dcp_content_type.h"
#include "test.h"
#include <boost/algorithm/string/predicate.hpp>
#include <iostream>
+
using std::string;
+
static CreateCLI
run (string cmd)
{
cc = run ("dcpomatic2_create x --name frobozz --template bar");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL (cc.name, "frobozz");
- BOOST_REQUIRE (cc.template_name);
- BOOST_CHECK_EQUAL (*cc.template_name, "bar");
+ BOOST_CHECK_EQUAL(cc._name, "frobozz");
+ BOOST_REQUIRE(cc._template_name);
+ BOOST_CHECK_EQUAL(*cc._template_name, "bar");
cc = run ("dcpomatic2_create x --dcp-content-type FTR");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL (cc.dcp_content_type, DCPContentType::from_isdcf_name("FTR"));
+ BOOST_CHECK_EQUAL(cc._dcp_content_type, DCPContentType::from_isdcf_name("FTR"));
cc = run ("dcpomatic2_create x --dcp-frame-rate 30");
BOOST_CHECK (!cc.error);
cc = run ("dcpomatic2_create x --container-ratio 185");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL (cc.container_ratio, Ratio::from_id("185"));
+ BOOST_CHECK_EQUAL(cc._container_ratio, Ratio::from_id("185"));
cc = run ("dcpomatic2_create x --container-ratio XXX");
BOOST_CHECK (cc.error);
cc = run ("dcpomatic2_create x --still-length 42");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL (cc.still_length, 42);
+ BOOST_CHECK_EQUAL(cc.still_length.get_value_or(0), 42);
cc = run ("dcpomatic2_create x --standard SMPTE");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL (cc.standard, dcp::Standard::SMPTE);
+ BOOST_REQUIRE(cc._standard);
+ BOOST_CHECK_EQUAL(*cc._standard, dcp::Standard::SMPTE);
cc = run ("dcpomatic2_create x --standard interop");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL (cc.standard, dcp::Standard::INTEROP);
+ BOOST_REQUIRE(cc._standard);
+ BOOST_CHECK_EQUAL(*cc._standard, dcp::Standard::INTEROP);
cc = run ("dcpomatic2_create x --standard SMPTEX");
BOOST_CHECK (cc.error);
+ cc = run("dcpomatic2_create x --no-encrypt");
+ BOOST_CHECK(cc._no_encrypt);
+
+ cc = run("dcpomatic2_create x --encrypt");
+ BOOST_CHECK(cc._encrypt);
+
+ cc = run("dcpomatic2_create x --no-encrypt --encrypt");
+ BOOST_CHECK(cc.error);
+
+ cc = run("dcpomatic2_create x --twod");
+ BOOST_CHECK(cc._twod);
+
+ cc = run("dcpomatic2_create x --threed");
+ BOOST_CHECK(cc._threed);
+
+ cc = run("dcpomatic2_create x --twod --threed");
+ BOOST_CHECK(cc.error);
+
cc = run ("dcpomatic2_create x --config foo/bar");
BOOST_CHECK (!cc.error);
BOOST_REQUIRE (cc.config_dir);
BOOST_CHECK (!cc.error);
BOOST_REQUIRE (cc.config_dir);
BOOST_CHECK_EQUAL (*cc.config_dir, "foo/bar");
- BOOST_CHECK_EQUAL (cc.still_length, 42);
+ BOOST_CHECK_EQUAL(cc.still_length.get_value_or(0), 42);
BOOST_REQUIRE (cc.output_dir);
BOOST_CHECK_EQUAL (*cc.output_dir, "flaps");
BOOST_REQUIRE_EQUAL (cc.content.size(), 3U);
BOOST_CHECK_EQUAL (cc.content[0].frame_type, VideoFrameType::THREE_D_LEFT);
BOOST_CHECK_EQUAL (cc.content[1].path, "right.mp4");
BOOST_CHECK_EQUAL (cc.content[1].frame_type, VideoFrameType::THREE_D_RIGHT);
- BOOST_CHECK_EQUAL (cc.fourk, false);
+ BOOST_CHECK_EQUAL(cc._fourk, false);
cc = run ("dcpomatic2_create --twok foo.mp4");
BOOST_REQUIRE_EQUAL (cc.content.size(), 1U);
BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4");
- BOOST_CHECK_EQUAL (cc.twok, true);
+ BOOST_CHECK_EQUAL(cc._twok, true);
BOOST_CHECK (!cc.error);
cc = run ("dcpomatic2_create --fourk foo.mp4");
BOOST_REQUIRE_EQUAL (cc.content.size(), 1U);
BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4");
- BOOST_CHECK_EQUAL (cc.fourk, true);
+ BOOST_CHECK_EQUAL(cc._fourk, true);
BOOST_CHECK (!cc.error);
cc = run ("dcpomatic2_create --j2k-bandwidth 120 foo.mp4");
BOOST_REQUIRE_EQUAL (cc.content.size(), 1U);
BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4");
- BOOST_REQUIRE (cc.j2k_bandwidth);
- BOOST_CHECK_EQUAL (*cc.j2k_bandwidth, 120000000);
+ BOOST_REQUIRE(cc._j2k_bandwidth);
+ BOOST_CHECK_EQUAL(*cc._j2k_bandwidth, 120000000);
BOOST_CHECK (!cc.error);
cc = run ("dcpomatic2_create --channel L fred.wav --channel R jim.wav sheila.wav");
BOOST_CHECK_EQUAL(cc.content[0].path, "dcp");
BOOST_REQUIRE(static_cast<bool>(cc.content[0].cpl));
BOOST_CHECK_EQUAL(*cc.content[0].cpl, "123456-789-0");
+
+ cc = run("dcpomatic2_create -s SMPTE sheila.wav");
+ BOOST_CHECK(!cc.still_length);
+ BOOST_CHECK(cc.error);
}
+
+
+BOOST_AUTO_TEST_CASE(create_cli_template_test)
+{
+ ConfigRestorer cr;
+
+ Config::override_path = "test/data";
+
+ auto cc = run("dcpomatic2_create test/data/flat_red.png");
+ auto film = cc.make_film();
+ BOOST_CHECK(!film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 2d");
+ film = cc.make_film();
+ BOOST_CHECK(!film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 2d --threed");
+ film = cc.make_film();
+ BOOST_CHECK(film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 3d");
+ film = cc.make_film();
+ BOOST_CHECK(film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template 3d --twod");
+ film = cc.make_film();
+ BOOST_CHECK(!film->three_d());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png");
+ film = cc.make_film();
+ BOOST_CHECK(!film->encrypted());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template unencrypted");
+ film = cc.make_film();
+ BOOST_CHECK(!film->encrypted());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template unencrypted --encrypt");
+ film = cc.make_film();
+ BOOST_CHECK(film->encrypted());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template encrypted");
+ film = cc.make_film();
+ BOOST_CHECK(film->encrypted());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template encrypted --no-encrypt");
+ film = cc.make_film();
+ BOOST_CHECK(!film->encrypted());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png");
+ film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template interop");
+ film = cc.make_film();
+ BOOST_CHECK(film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template interop --standard SMPTE");
+ film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template smpte");
+ film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template smpte --standard interop");
+ film = cc.make_film();
+ BOOST_CHECK(film->interop());
+}
+
+
+BOOST_AUTO_TEST_CASE(create_cli_defaults_test)
+{
+ ConfigRestorer cr;
+
+ /* I think on balance dcpomatic2_create should not use the defaults from Config;
+ * it seems a bit surprising that settings from a GUI tool can change the behaviour of
+ * a CLI tool, and at some point we're probably going to remove all the default config
+ * options from the main DoM anyway (in favour of a default template).
+ */
+ Config::instance()->set_default_interop(true);
+ auto cc = run("dcpomatic2_create test/data/flat_red.png");
+ auto film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ Config::instance()->set_default_dcp_content_type(DCPContentType::from_isdcf_name("FT"));
+ cc = run("dcpomatic2_create test/data/flat_red.png");
+ film = cc.make_film();
+ BOOST_CHECK_EQUAL(film->dcp_content_type()->isdcf_name(), "TST");
+}
+