diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-16 01:58:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-26 17:20:25 +0100 |
| commit | 24728b74693bb84d79474e014cdb952abc8a79f2 (patch) | |
| tree | b18a95441b7fcf53232958b364c84bcee67f1695 /test | |
| parent | d7f6ab91208cb4a562ccd668ca2cc8135f124053 (diff) | |
Give ownership of info files to ReelWriters (#2912).v2.18.2
The motivation here is to stop a pattern where we create a file, close
it, and then re-open it (many times) as I think there are problems on
Windows when a virus scanner sees the new file, opens it for checking,
and then we can't re-open it.
This also makes things a fair bit simpler, as a lock is removed and we
don't try to differentiate read/write cases by opening the file in
different ways; it's now always writeable.
Diffstat (limited to 'test')
| -rw-r--r-- | test/reel_writer_test.cc | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/test/reel_writer_test.cc b/test/reel_writer_test.cc index 411de9b1f..cb5ad349e 100644 --- a/test/reel_writer_test.cc +++ b/test/reel_writer_test.cc @@ -47,7 +47,7 @@ using std::string; using boost::optional; -static bool equal(J2KFrameInfo a, shared_ptr<InfoFileHandle> file, Frame frame, Eyes eyes) +static bool equal(J2KFrameInfo a, dcp::File& file, Frame frame, Eyes eyes) { auto b = J2KFrameInfo(file, frame, eyes); return a.offset == b.offset && a.size == b.size && a.hash == b.hash; @@ -58,49 +58,38 @@ BOOST_AUTO_TEST_CASE (write_frame_info_test) { auto film = new_test_film("write_frame_info_test"); dcpomatic::DCPTimePeriod const period (dcpomatic::DCPTime(0), dcpomatic::DCPTime(96000)); - ReelWriter writer(film, period, shared_ptr<Job>(), 0, 1, false, "foo"); - - /* Write the first one */ J2KFrameInfo info1(0, 123, "12345678901234567890123456789012"); - info1.write(film->info_file_handle(period, false), 0, Eyes::LEFT); - { - auto file = film->info_file_handle(period, true); - BOOST_CHECK(equal(info1, file, 0, Eyes::LEFT)); - } - - /* Write some more */ - J2KFrameInfo info2(596, 14921, "123acb789f1234ae782012n456339522"); - info2.write(film->info_file_handle(period, false), 5, Eyes::RIGHT); - - { - auto file = film->info_file_handle(period, true); - BOOST_CHECK(equal(info1, file, 0, Eyes::LEFT)); - BOOST_CHECK(equal(info2, file, 5, Eyes::RIGHT)); - } - J2KFrameInfo info3(12494, 99157123, "xxxxyyyyabc12356ffsfdsf456339522"); - info3.write(film->info_file_handle(period, false), 10, Eyes::LEFT); + J2KFrameInfo info4(55512494, 123599157123, "ABCDEFGyabc12356ffsfdsf4563395ZZ"); { - auto file = film->info_file_handle(period, true); - BOOST_CHECK(equal(info1, file, 0, Eyes::LEFT)); - BOOST_CHECK(equal(info2, file, 5, Eyes::RIGHT)); - BOOST_CHECK(equal(info3, file, 10, Eyes::LEFT)); + ReelWriter writer(film, period, shared_ptr<Job>(), 0, 1, false, "foo"); + info1.write(writer._info_file, 0, Eyes::LEFT); + info2.write(writer._info_file, 5, Eyes::RIGHT); + info3.write(writer._info_file, 10, Eyes::LEFT); } - /* Overwrite one */ - - J2KFrameInfo info4(55512494, 123599157123, "ABCDEFGyabc12356ffsfdsf4563395ZZ"); - info4.write(film->info_file_handle(period, false), 5, Eyes::RIGHT); + auto file1 = dcp::File(film->info_file(period), "rb"); + BOOST_CHECK(equal(info1, file1, 0, Eyes::LEFT)); + BOOST_CHECK(equal(info1, file1, 0, Eyes::LEFT)); + BOOST_CHECK(equal(info2, file1, 5, Eyes::RIGHT)); + BOOST_CHECK(equal(info1, file1, 0, Eyes::LEFT)); + BOOST_CHECK(equal(info2, file1, 5, Eyes::RIGHT)); + BOOST_CHECK(equal(info3, file1, 10, Eyes::LEFT)); { - auto file = film->info_file_handle(period, true); - BOOST_CHECK(equal(info1, file, 0, Eyes::LEFT)); - BOOST_CHECK(equal(info4, file, 5, Eyes::RIGHT)); - BOOST_CHECK(equal(info3, file, 10, Eyes::LEFT)); + ReelWriter writer(film, period, shared_ptr<Job>(), 0, 1, false, "foo"); + + /* Overwrite one */ + info4.write(writer._info_file, 5, Eyes::RIGHT); } + + auto file2 = dcp::File(film->info_file(period), "rb"); + BOOST_CHECK(equal(info1, file2, 0, Eyes::LEFT)); + BOOST_CHECK(equal(info4, file2, 5, Eyes::RIGHT)); + BOOST_CHECK(equal(info3, file2, 10, Eyes::LEFT)); } |
