]> git.sesse.net Git - mlt/blobdiff - src/tests/test_properties/test_properties.cpp
Add mlt_property_set_double_pos() and mlt_property_set_int_pos().
[mlt] / src / tests / test_properties / test_properties.cpp
index 1aac05cf9133bb476aaaee56f3eb3683f08ae561..d496e4c84cc35986a82d85b52277f6ee5d180372 100644 (file)
@@ -611,6 +611,44 @@ private Q_SLOTS:
         mlt_property_close(item.property);
         mlt_animation_close(a);
     }
+
+    void test_property_set_double_pos()
+    {
+        locale_t locale;
+#if defined(__linux__) || defined(__DARWIN__)
+        locale = newlocale( LC_NUMERIC_MASK, "POSIX", NULL );
+#endif
+        double fps = 25.0;
+        mlt_property p = mlt_property_init();
+        mlt_property_set_string(p, "10=100; 20=200");
+        mlt_property_set_double_pos(p, 1.5, fps, locale, mlt_keyframe_linear, 30, 100);
+        QCOMPARE(mlt_property_get_double(p, fps, locale), 10.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 0, 100), 100.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 15, 100), 150.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 20, 100), 200.0);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 25, 100), 100.75);
+        QCOMPARE(mlt_property_get_double_pos(p, fps, locale, 30, 100), 1.5);
+        mlt_property_close(p);
+    }
+
+    void test_property_set_int_pos()
+    {
+        locale_t locale;
+#if defined(__linux__) || defined(__DARWIN__)
+        locale = newlocale( LC_NUMERIC_MASK, "POSIX", NULL );
+#endif
+        double fps = 25.0;
+        mlt_property p = mlt_property_init();
+        mlt_property_set_string(p, "10=100; 20=200");
+        mlt_property_set_int_pos(p, 300, fps, locale, mlt_keyframe_linear, 30, 100);
+        QCOMPARE(mlt_property_get_int(p, fps, locale), 10);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 0, 100), 100);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 15, 100), 150);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 20, 100), 200);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 25, 100), 250);
+        QCOMPARE(mlt_property_get_int_pos(p, fps, locale, 30, 100), 300);
+        mlt_property_close(p);
+    }
 };
 
 QTEST_APPLESS_MAIN(TestProperties)