2 * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with consumer library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <mlt++/Mlt.h>
27 #include <framework/mlt_property.h>
28 #include <framework/mlt_animation.h>
32 class TestProperties: public QObject
39 #if defined(__linux__) || defined(__DARWIN__)
40 locale = newlocale( LC_NUMERIC_MASK, "POSIX", NULL );
45 void InstantiationIsAReference()
48 QCOMPARE(p.ref_count(), 1);
51 void CopyAddsReference()
55 QCOMPARE(p.ref_count(), 2);
58 void DestructionRemovesReference()
61 Properties* q = new Properties(p);
62 QCOMPARE(p.ref_count(), 2);
64 QCOMPARE(p.ref_count(), 1);
67 void SetAndGetString()
70 p.set("key", "value");
71 QVERIFY(p.get("key"));
72 QVERIFY(QString(p.get("key")) != QString(""));
73 QCOMPARE(p.get("key"), "value");
81 QCOMPARE(p.get_int("key"), i);
84 void SetAndGetDouble()
89 QCOMPARE(p.get_double("key"), d);
95 int64_t i = 1LL << 32;
97 QCOMPARE(p.get_int64("key"), i);
103 const char *value = "value";
104 char* const s = strdup(value);
105 p.set("key", s, strlen(s), free);
107 QCOMPARE((char*) p.get_data("key", size), value);
108 QCOMPARE(size, int(strlen(value)));
114 const char *s = "-1";
117 QCOMPARE(p.get("key"), s);
119 QCOMPARE(p.get_int("key"), i);
122 void Int64FromString()
125 const char *s = "-1";
128 QCOMPARE(p.get("key"), s);
130 QCOMPARE(p.get_int64("key"), i);
133 void DoubleFromString()
136 const char *s = "-1.23456";
139 QCOMPARE(p.get("key"), s);
141 QCOMPARE(p.get_double("key"), d);
144 void SetNullRemovesProperty()
147 const char *s = NULL;
148 p.set("key", "value");
150 QCOMPARE(p.get("key"), s);
153 void SetAndGetHexColor()
156 const char *hexColorString = "0xaabbccdd";
157 int hexColorInt = 0xaabbccdd;
158 p.set("key", hexColorString);
159 QCOMPARE(p.get_int("key"), hexColorInt);
162 void SetAndGetCssColor()
165 const char *cssColorString = "#aabbcc";
166 int cssColorInt = 0xaabbccff;
167 p.set("key", cssColorString);
168 QCOMPARE(p.get_int("key"), cssColorInt);
170 const char *cssColorAlphaString = "#00aabbcc";
171 int cssColorAlphaInt = 0xaabbcc00;
172 p.set("key", cssColorAlphaString);
173 QCOMPARE(p.get_int("key"), cssColorAlphaInt);
176 void SetAndGetTimeCode()
180 p.set("_profile", profile.get_profile(), 0);
181 const char *timeString = "11:22:33:04";
182 p.set("key", timeString);
183 QCOMPARE(p.get_int("key"), 1023829);
184 p.set("key", 1023829);
185 QCOMPARE(p.get_time("key", mlt_time_smpte), timeString);
188 void SetAndGetTimeClock()
192 p.set("_profile", profile.get_profile(), 0);
193 const char *timeString = "11:22:33.400";
194 p.set("key", timeString);
195 QCOMPARE(p.get_int("key"), 1023835);
196 p.set("key", 1023835);
197 QCOMPARE(p.get_time("key", mlt_time_clock), timeString);
200 void SetSimpleMathExpression()
203 p.set("key", "@16.0/9.0 *2 +3 -1");
204 QCOMPARE(p.get_int("key"), 5);
205 QCOMPARE(p.get_double("key"), 16.0/9.0 *2 +3 -1);
208 void PassOneProperty()
211 const char *s = "value";
213 QCOMPARE(p[1].get("key"), (void*) 0);
214 p[1].pass_property(p[0], "key");
215 QCOMPARE(p[1].get("key"), s);
218 void PassMultipleByPrefix()
221 const char *s = "value";
222 p[0].set("key.one", s);
223 p[0].set("key.two", s);
224 QCOMPARE(p[1].get("key.one"), (void*) 0);
225 QCOMPARE(p[1].get("key.two"), (void*) 0);
226 p[1].pass_values(p[0], "key.");
227 QCOMPARE(p[1].get("one"), s);
228 QCOMPARE(p[1].get("two"), s);
231 void PassMultipleByList()
234 const char *s = "value";
235 p[0].set("key.one", s);
236 p[0].set("key.two", s);
237 QCOMPARE(p[1].get("key.one"), (void*) 0);
238 QCOMPARE(p[1].get("key.two"), (void*) 0);
239 p[1].pass_list(p[0], "key.one key.two");
240 QCOMPARE(p[1].get("key.one"), s);
241 QCOMPARE(p[1].get("key.two"), s);
244 void MirrorProperties()
248 p[0].set("key", "value");
249 QCOMPARE(p[1].get("key"), "value");
252 void InheritProperties()
255 p[0].set("key", "value");
256 QVERIFY(p[1].get("key") == 0);
258 QCOMPARE(p[1].get("key"), "value");
264 QCOMPARE(p.get("key"), (void*) 0);
265 p.parse("key=value");
266 QCOMPARE(p.get("key"), "value");
267 p.parse("key=\"new value\"");
268 QCOMPARE(p.get("key"), "new value");
271 void RenameProperty()
274 p.set("key", "value");
275 QVERIFY(p.get("new key") == 0);
276 p.rename("key", "new key");
277 QCOMPARE(p.get("new key"), "value");
280 void SequenceDetected()
286 QVERIFY(p.is_sequence());
288 QVERIFY(!p.is_sequence());
291 void SerializesToYamlTiny()
294 p[0].set("key1", "value1");
295 p[0].set("key2", "value2");
296 p[1].set("1", "value3");
297 p[1].set("2", "value4");
298 p[0].set("seq", p[1].get_properties(), 0);
299 QCOMPARE(p[0].serialise_yaml(),
309 void RadixRespondsToLocale()
312 p.set_lcnumeric("en_US");
313 p.set("key", "0.125");
314 QCOMPARE(p.get_double("key"), double(1) / double(8));
315 p.set_lcnumeric("de_DE");
316 p.set("key", "0,125");
317 QCOMPARE(p.get_double("key"), double(1) / double(8));
320 void DoubleAnimation()
323 mlt_animation a = mlt_animation_new();
324 struct mlt_animation_item_s item;
326 mlt_animation_parse(a, "50=1; 60=60; 100=0", 100, fps, locale);
327 mlt_animation_remove(a, 60);
328 char *a_serialized = mlt_animation_serialize(a);
329 QCOMPARE(a_serialized, "50=1;100=0");
330 if (a_serialized) free(a_serialized);
331 item.property = mlt_property_init();
333 mlt_animation_get_item(a, &item, 10);
334 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
335 QCOMPARE(item.is_key, 0);
337 mlt_animation_get_item(a, &item, 50);
338 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
339 QCOMPARE(item.is_key, 1);
341 mlt_animation_get_item(a, &item, 75);
342 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.5);
343 QCOMPARE(item.is_key, 0);
345 mlt_animation_get_item(a, &item, 100);
346 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
347 QCOMPARE(item.is_key, 1);
349 mlt_animation_get_item(a, &item, 110);
350 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
351 QCOMPARE(item.is_key, 0);
353 mlt_property_close(item.property);
354 mlt_animation_close(a);
360 mlt_animation a = mlt_animation_new();
361 struct mlt_animation_item_s item;
363 mlt_animation_parse(a, "50=100; 60=60; 100=0", 100, fps, locale);
364 mlt_animation_remove(a, 60);
365 char *a_serialized = mlt_animation_serialize(a);
366 QCOMPARE(a_serialized, "50=100;100=0");
367 if (a_serialized) free(a_serialized);
368 item.property = mlt_property_init();
370 mlt_animation_get_item(a, &item, 10);
371 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
372 QCOMPARE(item.is_key, 0);
374 mlt_animation_get_item(a, &item, 50);
375 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
376 QCOMPARE(item.is_key, 1);
378 mlt_animation_get_item(a, &item, 75);
379 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 50);
380 QCOMPARE(item.is_key, 0);
382 mlt_animation_get_item(a, &item, 100);
383 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
384 QCOMPARE(item.is_key, 1);
386 mlt_animation_get_item(a, &item, 110);
387 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
388 QCOMPARE(item.is_key, 0);
390 mlt_property_close(item.property);
391 mlt_animation_close(a);
394 void AnimationWithTimeValueKeyframes()
397 mlt_animation a = mlt_animation_new();
398 struct mlt_animation_item_s item;
400 mlt_animation_parse(a, ":2.0=1; :4.0=0", 100, fps, locale);
401 char *a_serialized = mlt_animation_serialize(a);
402 // Time serializes to frame units :-\.
403 QCOMPARE(a_serialized, "50=1;100=0");
404 if (a_serialized) free(a_serialized);
405 item.property = mlt_property_init();
407 mlt_animation_get_item(a, &item, 10);
408 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
409 QCOMPARE(item.is_key, 0);
411 mlt_animation_get_item(a, &item, 50);
412 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
413 QCOMPARE(item.is_key, 1);
415 mlt_animation_get_item(a, &item, 75);
416 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.5);
417 QCOMPARE(item.is_key, 0);
419 mlt_animation_get_item(a, &item, 100);
420 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
421 QCOMPARE(item.is_key, 1);
423 mlt_animation_get_item(a, &item, 110);
424 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
425 QCOMPARE(item.is_key, 0);
427 mlt_property_close(item.property);
428 mlt_animation_close(a);
431 void DiscreteIntAnimation()
434 mlt_animation a = mlt_animation_new();
435 struct mlt_animation_item_s item;
437 mlt_animation_parse(a, "50|=100; 60|=60; 100|=0", 100, fps, locale);
438 char *a_serialized = mlt_animation_serialize(a);
439 QCOMPARE(a_serialized, "50|=100;60|=60;100|=0");
440 if (a_serialized) free(a_serialized);
441 item.property = mlt_property_init();
443 mlt_animation_get_item(a, &item, 10);
444 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
445 QCOMPARE(item.is_key, 0);
447 mlt_animation_get_item(a, &item, 50);
448 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
449 QCOMPARE(item.is_key, 1);
451 mlt_animation_get_item(a, &item, 55);
452 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
453 QCOMPARE(item.is_key, 0);
455 mlt_animation_get_item(a, &item, 60);
456 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 60);
457 QCOMPARE(item.is_key, 1);
459 mlt_animation_get_item(a, &item, 75);
460 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 60);
461 QCOMPARE(item.is_key, 0);
463 mlt_animation_get_item(a, &item, 100);
464 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
465 QCOMPARE(item.is_key, 1);
467 mlt_animation_get_item(a, &item, 110);
468 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
469 QCOMPARE(item.is_key, 0);
471 mlt_property_close(item.property);
472 mlt_animation_close(a);
475 void StringAnimation()
478 mlt_animation a = mlt_animation_new();
479 struct mlt_animation_item_s item;
481 mlt_animation_parse(a, "50=hello world; 60=\"good night\"; 100=bar", 100, fps, locale);
482 char *a_serialized = mlt_animation_serialize(a);
483 QCOMPARE(a_serialized, "50=hello world;60=\"good night\";100=bar");
484 if (a_serialized) free(a_serialized);
485 item.property = mlt_property_init();
487 mlt_animation_get_item(a, &item, 10);
488 QCOMPARE(mlt_property_get_string(item.property), "hello world");
489 QCOMPARE(item.is_key, 0);
491 mlt_animation_get_item(a, &item, 50);
492 QCOMPARE(mlt_property_get_string(item.property), "hello world");
493 QCOMPARE(item.is_key, 1);
495 mlt_animation_get_item(a, &item, 75);
496 QCOMPARE(mlt_property_get_string(item.property), "\"good night\"");
497 QCOMPARE(item.is_key, 0);
499 mlt_animation_get_item(a, &item, 100);
500 QCOMPARE(mlt_property_get_string(item.property), "bar");
501 QCOMPARE(item.is_key, 1);
503 mlt_animation_get_item(a, &item, 110);
504 QCOMPARE(mlt_property_get_string(item.property), "bar");
505 QCOMPARE(item.is_key, 0);
507 mlt_property_close(item.property);
508 mlt_animation_close(a);
511 void test_property_anim_get_double()
515 mlt_property p = mlt_property_init();
516 mlt_property_set_string(p, "10=100; 20=200");
517 QCOMPARE(mlt_property_get_double(p, fps, locale), 10.0);
518 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 0, len), 100.0);
519 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 15, len), 150.0);
520 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 20, len), 200.0);
522 mlt_property_set_string(p, "1.5");
523 QCOMPARE(mlt_property_get_double(p, fps, locale), 1.5);
524 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 10, 100), 1.5);
526 mlt_property_close(p);
529 void test_property_anim_get_int()
533 mlt_property p = mlt_property_init();
534 mlt_property_set_string(p, "10=100; 20=200");
535 QCOMPARE(mlt_property_get_int(p, fps, locale), 10);
536 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 0, len), 100);
537 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 15, len), 150);
538 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 20, len), 200);
540 mlt_property_set_string(p, "1.5");
541 QCOMPARE(mlt_property_get_int(p, fps, locale), 1);
542 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 10, 100), 1);
544 mlt_property_close(p);
547 void SmoothIntAnimation()
550 mlt_animation a = mlt_animation_new();
551 struct mlt_animation_item_s item;
553 mlt_animation_parse(a, "0=80;10~=80; 20~=30; 30~=40; 40~=28; 50=90; 60=0; 70=60; 80=20", 100, fps, locale);
554 item.property = mlt_property_init();
555 char *a_serialized = mlt_animation_serialize(a);
556 QCOMPARE(a_serialized, "0=80;10~=80;20~=30;30~=40;40~=28;50=90;60=0;70=60;80=20");
557 if (a_serialized) free(a_serialized);
559 mlt_animation_get_item(a, &item, 10);
560 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 80);
561 QCOMPARE(item.is_key, 1);
563 mlt_animation_get_item(a, &item, 50);
564 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 90);
565 QCOMPARE(item.is_key, 1);
567 mlt_animation_get_item(a, &item, 55);
568 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 45);
569 QCOMPARE(item.is_key, 0);
571 mlt_animation_get_item(a, &item, 60);
572 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
573 QCOMPARE(item.is_key, 1);
575 mlt_animation_get_item(a, &item, 75);
576 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 40);
577 QCOMPARE(item.is_key, 0);
579 mlt_animation_get_item(a, &item, 100);
580 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 20);
581 QCOMPARE(item.is_key, 0);
583 mlt_animation_get_item(a, &item, 110);
584 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 20);
585 QCOMPARE(item.is_key, 0);
587 mlt_property_close(item.property);
588 mlt_animation_close(a);
591 void test_property_anim_set_double()
595 mlt_property p = mlt_property_init();
596 mlt_property_set_string(p, "10=100; 20=200");
597 mlt_property_anim_set_double(p, 1.5, fps, locale, mlt_keyframe_linear, 30, len);
598 QCOMPARE(mlt_property_get_double(p, fps, locale), 10.0);
599 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 0, len), 100.0);
600 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 15, len), 150.0);
601 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 20, len), 200.0);
602 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 25, len), 100.75);
603 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 30, len), 1.5);
604 mlt_property_close(p);
607 void test_property_anim_set_int()
611 mlt_property p = mlt_property_init();
612 mlt_property_set_string(p, "10=100; 20=200");
613 mlt_property_anim_set_int(p, 300, fps, locale, mlt_keyframe_linear, 30, len);
614 QCOMPARE(mlt_property_get_int(p, fps, locale), 10);
615 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 0, len), 100);
616 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 15, len), 150);
617 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 20, len), 200);
618 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 25, len), 250);
619 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 30, len), 300);
620 mlt_property_close(p);
623 void PercentAsRatio()
626 p.set("foo", "12.3%");
627 QCOMPARE(p.get_double("foo"), 0.123);
628 p.set("foo", "456 %");
629 QCOMPARE(p.get_double("foo"), 456.0);
632 void PropertiesAnimInt()
635 p.set_lcnumeric("POSIX");
637 // Construct animation from scratch
638 p.anim_set("foo", 0, 0);
639 p.anim_set("foo", 100, 50, -1, mlt_keyframe_smooth);
640 QCOMPARE(p.anim_get_int("foo", 0), 0);
641 QCOMPARE(p.anim_get_int("foo", 25), 50);
642 QCOMPARE(p.anim_get_int("foo", 50), 100);
643 QCOMPARE(p.get("foo"), "0=0;50~=100");
645 // Animation from string value
646 p.set("foo", "10=100;20=200");
647 QCOMPARE(p.anim_get_int("foo", 0), 100);
648 QCOMPARE(p.anim_get_int("foo", 15), 150);
649 QCOMPARE(p.anim_get_int("foo", 20), 200);
651 // Animation from string using time clock values
652 // Need to set a profile so fps can be used to convert time to frames.
653 Profile profile("dv_pal");
654 p.set("_profile", profile.get_profile(), 0);
655 p.set("foo", ":0.0=100; :2.0=200");
656 QCOMPARE(p.anim_get_int("foo", 0), 100);
657 QCOMPARE(p.anim_get_int("foo", 25), 150);
658 QCOMPARE(p.anim_get_int("foo", 50), 200);
661 void PropertiesAnimDouble()
664 p.set_lcnumeric("POSIX");
666 // Construct animation from scratch
667 p.anim_set("foo", 0.0, 0);
668 p.anim_set("foo", 100.0, 50, -1, mlt_keyframe_smooth);
669 QCOMPARE(p.anim_get_double("foo", 0), 0.0);
670 QCOMPARE(p.anim_get_double("foo", 25), 50.0);
671 QCOMPARE(p.anim_get_double("foo", 50), 100.0);
672 QCOMPARE(p.get("foo"), "0=0;50~=100");
674 // Animation from string value
675 p.set("foo", "10=100.2;20=200.8");
676 QCOMPARE(p.anim_get_double("foo", 0), 100.2);
677 QCOMPARE(p.anim_get_double("foo", 15), 150.5);
678 QCOMPARE(p.anim_get_double("foo", 20), 200.8);
680 // Animation from string using time clock values
681 // Need to set a profile so fps can be used to convert time to frames.
682 Profile profile("dv_pal");
683 p.set("_profile", profile.get_profile(), 0);
684 p.set("foo", ":0.0=100; :2.0=200");
685 QCOMPARE(p.anim_get_double("foo", 0), 100.0);
686 QCOMPARE(p.anim_get_double("foo", 25), 150.0);
687 QCOMPARE(p.anim_get_double("foo", 50), 200.0);
690 void PropertiesStringAnimation()
693 p.anim_set("key", "foo", 10);
694 p.anim_set("key", "bar", 30);
695 QCOMPARE(p.get("key"), "10|=foo;30|=bar");
696 p.set("key", "0=; 10=foo bar; 30=hello world");
697 QCOMPARE(p.anim_get("key", 1), "");
698 QCOMPARE(p.anim_get("key", 15), "foo bar");
699 QCOMPARE(p.anim_get("key", 45), "hello world");
704 mlt_property p = mlt_property_init();
705 mlt_rect r = { 1, 2, 3, 4, 5 };
707 mlt_property_set_rect( p, r );
708 QCOMPARE(mlt_property_get_string(p), "1 2 3 4 5");
710 mlt_property_set_rect( p, r );
711 QCOMPARE(mlt_property_get_string(p), "1 2 3 4");
714 mlt_property_set_rect( p, r );
715 QCOMPARE(mlt_property_get_string(p), "1 2");
717 mlt_property_set_string(p, "1.1/2.2:3.3x4.4:5.5");
718 r = mlt_property_get_rect(p, locale);
725 mlt_property_set_string(p, "1.1 2.2");
726 r = mlt_property_get_rect(p, locale);
729 QCOMPARE(r.w, DBL_MIN);
731 mlt_property_set_int64(p, UINT_MAX);
732 r = mlt_property_get_rect(p, locale);
733 QCOMPARE(r.x, double(UINT_MAX));
735 mlt_property_close(p);
748 mlt_rect q = p.get_rect("key");
754 p.set("key", 10, 20, 30, 40);
755 q = p.get_rect("key");
762 void RectFromString()
765 p.set_lcnumeric("POSIX");
766 const char *s = "1.1 2.2 3.3 4.4 5.5";
767 mlt_rect r = { 1.1, 2.2, 3.3, 4.4, 5.5 };
769 QCOMPARE(p.get("key"), s);
771 r = p.get_rect("key");
781 mlt_rect r1 = { 0, 0, 200, 200, 0 };
782 mlt_rect r2 = { 100, 100, 400, 400, 1.0 };
784 p.set_lcnumeric("POSIX");
786 // Construct animation from scratch
787 p.anim_set("key", r1, 0);
788 p.anim_set("key", r2, 50);
789 QCOMPARE(p.anim_get_rect("key", 0).x, 0.0);
790 QCOMPARE(p.anim_get_rect("key", 25).x, 50.0);
791 QCOMPARE(p.anim_get_rect("key", 25).y, 50.0);
792 QCOMPARE(p.anim_get_rect("key", 25).w, 300.0);
793 QCOMPARE(p.anim_get_rect("key", 25).h, 300.0);
794 QCOMPARE(p.anim_get_rect("key", 25).o, 0.5);
795 QCOMPARE(p.anim_get_rect("key", 50).x, 100.0);
796 QCOMPARE(p.get("key"), "0=0 0 200 200 0;50=100 100 400 400 1");
798 // Animation from string value
799 QCOMPARE(p.anim_get_rect("key", 0).x, 0.0);
800 QCOMPARE(p.anim_get_rect("key", 0).y, 0.0);
801 QCOMPARE(p.anim_get_rect("key", 0).w, 200.0);
802 QCOMPARE(p.anim_get_rect("key", 0).h, 200.0);
803 QCOMPARE(p.anim_get_rect("key", 0).o, 0.0);
804 QCOMPARE(p.anim_get_rect("key", 50).x, 100.0);
805 QCOMPARE(p.anim_get_rect("key", 50).y, 100.0);
806 QCOMPARE(p.anim_get_rect("key", 50).w, 400.0);
807 QCOMPARE(p.anim_get_rect("key", 50).h, 400.0);
808 QCOMPARE(p.anim_get_rect("key", 50).o, 1.0);
809 QCOMPARE(p.anim_get_rect("key", 15).x, 30.0);
810 QCOMPARE(p.anim_get_rect("key", 15).y, 30.0);
811 QCOMPARE(p.anim_get_rect("key", 15).w, 260.0);
812 QCOMPARE(p.anim_get_rect("key", 15).h, 260.0);
813 QCOMPARE(p.anim_get_rect("key", 15).o, 0.3);
816 p.set("key", "0~=0/0:200x200:0; 50=100/100:400x400:1");
817 QCOMPARE(p.anim_get_rect("key", 0).x, 0.0);
818 QCOMPARE(p.anim_get_rect("key", 0).y, 0.0);
819 QCOMPARE(p.anim_get_rect("key", 0).w, 200.0);
820 QCOMPARE(p.anim_get_rect("key", 0).h, 200.0);
821 QCOMPARE(p.anim_get_rect("key", 0).o, 0.0);
822 QCOMPARE(p.anim_get_rect("key", 50).x, 100.0);
823 QCOMPARE(p.anim_get_rect("key", 50).y, 100.0);
824 QCOMPARE(p.anim_get_rect("key", 50).w, 400.0);
825 QCOMPARE(p.anim_get_rect("key", 50).h, 400.0);
826 QCOMPARE(p.anim_get_rect("key", 50).o, 1.0);
827 QCOMPARE(p.anim_get_rect("key", 15).x, 25.8);
828 QCOMPARE(p.anim_get_rect("key", 15).y, 25.8);
829 QCOMPARE(p.anim_get_rect("key", 15).w, 251.6);
830 QCOMPARE(p.anim_get_rect("key", 15).h, 251.6);
831 QCOMPARE(p.anim_get_rect("key", 15).o, 0.258);
834 p.set("key", "0=0 0; 50=100% 200%");
835 QCOMPARE(p.anim_get_rect("key", 25).x, 0.5);
836 QCOMPARE(p.anim_get_rect("key", 25).y, 1.0);
842 p.set_lcnumeric("POSIX");
843 p.set("key", (int) 0xaabbccdd);
844 mlt_color color = p.get_color("key");
845 QCOMPARE(color.r, quint8(0xaa));
846 QCOMPARE(color.g, quint8(0xbb));
847 QCOMPARE(color.b, quint8(0xcc));
848 QCOMPARE(color.a, quint8(0xdd));
849 p.set("key", *((int*) &color));
850 QCOMPARE(p.get_int("key"), int(0xddccbbaa));
853 void ColorFromString()
856 p.set_lcnumeric("POSIX");
858 mlt_color color = p.get_color("key");
859 QCOMPARE(color.r, quint8(0xff));
860 QCOMPARE(color.g, quint8(0x00));
861 QCOMPARE(color.b, quint8(0x00));
862 QCOMPARE(color.a, quint8(0xff));
863 p.set("key", "#deadd00d");
864 color = p.get_color("key");
865 QCOMPARE(color.r, quint8(0xad));
866 QCOMPARE(color.g, quint8(0xd0));
867 QCOMPARE(color.b, quint8(0x0d));
868 QCOMPARE(color.a, quint8(0xde));
871 void SetIntAndGetAnim()
874 p.set_lcnumeric("POSIX");
876 QCOMPARE(p.anim_get_int("key", 10, 50), 123);
878 QCOMPARE(p.anim_get_int("key", 10, 50), 123);
881 void SetDoubleAndGetAnim()
884 p.set_lcnumeric("POSIX");
886 QCOMPARE(p.anim_get_double("key", 10, 50), 123.0);
888 QCOMPARE(p.anim_get_double("key", 10, 50), 123.0);
891 void AnimNegativeTimevalue()
894 Profile profile("dv_pal");
895 p.set("_profile", profile.get_profile(), 0);
896 p.set_lcnumeric("POSIX");
897 p.set("key", "0=100; -1=200");
898 QCOMPARE(p.anim_get_int("key", 75, 100), 175);
899 p.set("key", "0=100; -1:=200");
900 QCOMPARE(p.anim_get_int("key", 75, 125), 175);
904 QTEST_APPLESS_MAIN(TestProperties)
906 #include "test_properties.moc"