summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-02-14 23:11:50 +0000
committerCarl Hetherington <cth@carlh.net>2016-02-14 23:11:50 +0000
commitc009f6795d133e8dfe0662042e0b3c90dde0e25b (patch)
tree7f9f67aa62a958a4097636dd54c02ab52b5e3947 /test
parent4e38f823324b020761a12ab5d479155d6a43a4d2 (diff)
Limit values that we use for <ScreenAspectRatio> tags in Interop
CPLs to the list allowed by the standard.
Diffstat (limited to 'test')
-rw-r--r--test/cpl_sar_test.cc69
1 files changed, 50 insertions, 19 deletions
diff --git a/test/cpl_sar_test.cc b/test/cpl_sar_test.cc
index 3f5b07d1..095920ec 100644
--- a/test/cpl_sar_test.cc
+++ b/test/cpl_sar_test.cc
@@ -24,10 +24,25 @@
#include <libxml++/libxml++.h>
#include <boost/test/unit_test.hpp>
+using std::string;
using boost::shared_ptr;
+static void
+check (shared_ptr<dcp::ReelMonoPictureAsset> pa, dcp::Fraction far, string sar)
+{
+ pa->set_screen_aspect_ratio (far);
+ xmlpp::Document doc;
+ xmlpp::Element* el = doc.create_root_node ("Test");
+ pa->write_to_cpl (el, dcp::INTEROP);
+
+ cxml::Node node (el);
+ BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), sar);
+}
+
/** Test for a reported bug where <ScreenAspectRatio> in Interop files uses
* excessive decimal places and (sometimes) the wrong decimal point character.
+ * Also check that we correctly use one of the allowed <ScreenAspectRatio>
+ * values with Interop.
*/
BOOST_AUTO_TEST_CASE (cpl_sar)
{
@@ -38,23 +53,39 @@ BOOST_AUTO_TEST_CASE (cpl_sar)
)
);
- {
- pa->set_screen_aspect_ratio (dcp::Fraction (1998, 1080));
- xmlpp::Document doc;
- xmlpp::Element* el = doc.create_root_node ("Test");
- pa->write_to_cpl (el, dcp::INTEROP);
-
- cxml::Node node (el);
- BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "1.85");
- }
-
- {
- pa->set_screen_aspect_ratio (dcp::Fraction (2048, 858));
- xmlpp::Document doc;
- xmlpp::Element* el = doc.create_root_node ("Test");
- pa->write_to_cpl (el, dcp::INTEROP);
-
- cxml::Node node (el);
- BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "2.39");
- }
+ /* Easy ones */
+ check (pa, dcp::Fraction (1998, 1080), "1.85");
+ check (pa, dcp::Fraction (2048, 858), "2.39");
+
+ /* Check the use of the allowed values */
+
+ /* Just less then, equal to and just more than 1.33 */
+ check (pa, dcp::Fraction (1200, 1000), "1.33");
+ check (pa, dcp::Fraction (1330, 1000), "1.33");
+ check (pa, dcp::Fraction (1430, 1000), "1.33");
+
+ /* Same for 1.66 */
+ check (pa, dcp::Fraction (1600, 1000), "1.66");
+ check (pa, dcp::Fraction (1660, 1000), "1.66");
+ check (pa, dcp::Fraction (1670, 1000), "1.66");
+
+ /* 1.77 */
+ check (pa, dcp::Fraction (1750, 1000), "1.77");
+ check (pa, dcp::Fraction (1770, 1000), "1.77");
+ check (pa, dcp::Fraction (1800, 1000), "1.77");
+
+ /* 1.85 */
+ check (pa, dcp::Fraction (1820, 1000), "1.85");
+ check (pa, dcp::Fraction (1850, 1000), "1.85");
+ check (pa, dcp::Fraction (1910, 1000), "1.85");
+
+ /* 2.00 */
+ check (pa, dcp::Fraction (1999, 1000), "2.00");
+ check (pa, dcp::Fraction (2000, 1000), "2.00");
+ check (pa, dcp::Fraction (2001, 1000), "2.00");
+
+ /* 2.39 */
+ check (pa, dcp::Fraction (2350, 1000), "2.39");
+ check (pa, dcp::Fraction (2390, 1000), "2.39");
+ check (pa, dcp::Fraction (2500, 1000), "2.39");
}