Pass options only to jobs that need them.
[dcpomatic.git] / test / test.cc
index a7023b8411d47b7fbbf6643ac40f4ed22cd6fbb3..5aed18c523043512729a14533c85fbb9ccc56350 100644 (file)
@@ -258,13 +258,15 @@ BOOST_AUTO_TEST_CASE (md5_digest_test)
 BOOST_AUTO_TEST_CASE (paths_test)
 {
        FilmState s;
-       s.directory = "build/test/a/b/c/d/e";
-       s.thumbs.push_back (42);
+       s.set_directory ("build/test/a/b/c/d/e");
+       vector<int> thumbs;
+       thumbs.push_back (42);
+       s.set_thumbs (thumbs);
        BOOST_CHECK_EQUAL (s.thumb_file (0), "build/test/a/b/c/d/e/thumbs/00000042.png");
 
-       s.content = "/foo/bar/baz";
+       s._content = "/foo/bar/baz";
        BOOST_CHECK_EQUAL (s.content_path(), "/foo/bar/baz");
-       s.content = "foo/bar/baz";
+       s._content = "foo/bar/baz";
        BOOST_CHECK_EQUAL (s.content_path(), "build/test/a/b/c/d/e/foo/bar/baz");
 }
 
@@ -282,7 +284,6 @@ do_remote_encode (shared_ptr<DCPVideoFrame> frame, ServerDescription* descriptio
 BOOST_AUTO_TEST_CASE (client_server_test)
 {
        shared_ptr<Image> image (new CompactImage (PIX_FMT_RGB24, Size (1998, 1080)));
-
        uint8_t* p = image->data()[0];
        
        for (int y = 0; y < 1080; ++y) {
@@ -293,16 +294,29 @@ BOOST_AUTO_TEST_CASE (client_server_test)
                }
        }
 
+       shared_ptr<Image> sub_image (new CompactImage (PIX_FMT_RGBA, Size (100, 200)));
+       p = sub_image->data()[0];
+       for (int y = 0; y < 200; ++y) {
+               for (int x = 0; x < 100; ++x) {
+                       *p++ = y % 256;
+                       *p++ = x % 256;
+                       *p++ = (x + y) % 256;
+                       *p++ = 1;
+               }
+       }
+
+       shared_ptr<Subtitle> subtitle (new Subtitle (Position (50, 60), sub_image));
+
        FileLog log ("build/test/client_server_test.log");
 
        shared_ptr<DCPVideoFrame> frame (
                new DCPVideoFrame (
                        image,
-                       shared_ptr<Subtitle> (),
+                       subtitle,
                        Size (1998, 1080),
                        0,
                        0,
-                       0,
+                       1,
                        Scaler::from_id ("bicubic"),
                        0,
                        24,
@@ -389,31 +403,31 @@ BOOST_AUTO_TEST_CASE (make_dcp_with_range_test)
 BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
 {
        FilmState fs;
-       fs.frames_per_second = 24;
+       fs.set_frames_per_second (24);
 
-       fs.audio_sample_rate = 48000;
+       fs.set_audio_sample_rate (48000);
        BOOST_CHECK_EQUAL (fs.target_sample_rate(), 48000);
 
-       fs.audio_sample_rate = 44100;
+       fs.set_audio_sample_rate (44100);
        BOOST_CHECK_EQUAL (fs.target_sample_rate(), 48000);
 
-       fs.audio_sample_rate = 80000;
+       fs.set_audio_sample_rate (80000);
        BOOST_CHECK_EQUAL (fs.target_sample_rate(), 96000);
 
-       fs.frames_per_second = 23.976;
-       fs.audio_sample_rate = 48000;
+       fs.set_frames_per_second (23.976);
+       fs.set_audio_sample_rate (48000);
        BOOST_CHECK_EQUAL (fs.target_sample_rate(), 47952);
 
-       fs.frames_per_second = 29.97;
-       fs.audio_sample_rate = 48000;
+       fs.set_frames_per_second (29.97);
+       fs.set_audio_sample_rate (48000);
        BOOST_CHECK_EQUAL (fs.target_sample_rate(), 47952);
 }
 
 class TestJob : public Job
 {
 public:
-       TestJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
-               : Job (s, o, l, req)
+       TestJob (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
+               : Job (s, l, req)
        {
 
        }
@@ -443,11 +457,10 @@ public:
 BOOST_AUTO_TEST_CASE (job_manager_test)
 {
        shared_ptr<const FilmState> s;
-       shared_ptr<const Options> o;
        FileLog log ("build/test/job_manager_test.log");
 
        /* Single job, no dependency */
-       shared_ptr<TestJob> a (new TestJob (s, o, &log, shared_ptr<Job> ()));
+       shared_ptr<TestJob> a (new TestJob (s, &log, shared_ptr<Job> ()));
 
        JobManager::instance()->add (a);
        dvdomatic_sleep (1);
@@ -457,8 +470,8 @@ BOOST_AUTO_TEST_CASE (job_manager_test)
        BOOST_CHECK_EQUAL (a->finished_ok(), true);
 
        /* Two jobs, dependency */
-       a.reset (new TestJob (s, o, &log, shared_ptr<Job> ()));
-       shared_ptr<TestJob> b (new TestJob (s, o, &log, a));
+       a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
+       shared_ptr<TestJob> b (new TestJob (s, &log, a));
 
        JobManager::instance()->add (a);
        JobManager::instance()->add (b);
@@ -474,8 +487,8 @@ BOOST_AUTO_TEST_CASE (job_manager_test)
        BOOST_CHECK_EQUAL (b->finished_ok(), true);
 
        /* Two jobs, dependency, first fails */
-       a.reset (new TestJob (s, o, &log, shared_ptr<Job> ()));
-       b.reset (new TestJob (s, o, &log, a));
+       a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
+       b.reset (new TestJob (s, &log, a));
 
        JobManager::instance()->add (a);
        JobManager::instance()->add (b);
@@ -487,3 +500,16 @@ BOOST_AUTO_TEST_CASE (job_manager_test)
        BOOST_CHECK_EQUAL (a->finished_in_error(), true);
        BOOST_CHECK_EQUAL (b->running(), false);
 }
+
+BOOST_AUTO_TEST_CASE (stream_test)
+{
+       AudioStream a ("4 9 hello there world");
+       BOOST_CHECK_EQUAL (a.id(), 4);
+       BOOST_CHECK_EQUAL (a.channels(), 9);
+       BOOST_CHECK_EQUAL (a.name(), "hello there world");
+       BOOST_CHECK_EQUAL (a.to_string(), "4 9 hello there world");
+
+       SubtitleStream s ("5 a b c");
+       BOOST_CHECK_EQUAL (s.id(), 5);
+       BOOST_CHECK_EQUAL (s.name(), "a b c");
+}