Use $HOME rather than hard-coded user name.
[dcpomatic.git] / test / create_cli_test.cc
index 8da07d5d5d9402637edbbb965752855a79d9acf4..aae5fb6de051d81b83719ba8275918d80c47cde5 100644 (file)
@@ -102,15 +102,26 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
 
        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);
 
@@ -217,10 +228,14 @@ BOOST_AUTO_TEST_CASE(create_cli_template_test)
 
        Config::override_path = "test/data";
 
-       auto cc = run("dcpomatic2_create test/data/flat_red.png --template 2d");
+       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());
@@ -232,5 +247,66 @@ BOOST_AUTO_TEST_CASE(create_cli_template_test)
        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");
 }