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 #if defined(__linux__) || defined(__DARWIN__)
51 void InstantiationIsAReference()
54 QCOMPARE(p.ref_count(), 1);
57 void CopyAddsReference()
61 QCOMPARE(p.ref_count(), 2);
64 void DestructionRemovesReference()
67 Properties* q = new Properties(p);
68 QCOMPARE(p.ref_count(), 2);
70 QCOMPARE(p.ref_count(), 1);
73 void SetAndGetString()
76 p.set("key", "value");
77 QVERIFY(p.get("key"));
78 QVERIFY(QString(p.get("key")) != QString(""));
79 QCOMPARE(p.get("key"), "value");
87 QCOMPARE(p.get_int("key"), i);
90 void SetAndGetDouble()
95 QCOMPARE(p.get_double("key"), d);
101 int64_t i = 1LL << 32;
103 QCOMPARE(p.get_int64("key"), i);
109 const char *value = "value";
110 char* const s = strdup(value);
111 p.set("key", s, strlen(s), free);
113 QCOMPARE((char*) p.get_data("key", size), value);
114 QCOMPARE(size, int(strlen(value)));
120 const char *s = "-1";
123 QCOMPARE(p.get("key"), s);
125 QCOMPARE(p.get_int("key"), i);
128 void Int64FromString()
131 const char *s = "-1";
134 QCOMPARE(p.get("key"), s);
136 QCOMPARE(p.get_int64("key"), i);
139 void DoubleFromString()
142 const char *s = "-1.23456";
145 QCOMPARE(p.get("key"), s);
147 QCOMPARE(p.get_double("key"), d);
150 void SetNullRemovesProperty()
153 const char *s = NULL;
154 p.set("key", "value");
156 QCOMPARE(p.get("key"), s);
159 void SetAndGetHexColor()
162 const char *hexColorString = "0xaabbccdd";
163 int hexColorInt = 0xaabbccdd;
164 p.set("key", hexColorString);
165 QCOMPARE(p.get_int("key"), hexColorInt);
168 void SetAndGetCssColor()
171 const char *cssColorString = "#aabbcc";
172 int cssColorInt = 0xaabbccff;
173 p.set("key", cssColorString);
174 QCOMPARE(p.get_int("key"), cssColorInt);
176 const char *cssColorAlphaString = "#00aabbcc";
177 int cssColorAlphaInt = 0xaabbcc00;
178 p.set("key", cssColorAlphaString);
179 QCOMPARE(p.get_int("key"), cssColorAlphaInt);
182 void SetAndGetTimeCode()
186 p.set("_profile", profile.get_profile(), 0);
187 const char *timeString = "11:22:33:04";
188 p.set("key", timeString);
189 QCOMPARE(p.get_int("key"), 1023829);
190 p.set("key", 1023829);
191 QCOMPARE(p.get_time("key", mlt_time_smpte), timeString);
194 void SetAndGetTimeClock()
198 p.set("_profile", profile.get_profile(), 0);
199 const char *timeString = "11:22:33.400";
200 p.set("key", timeString);
201 QCOMPARE(p.get_int("key"), 1023835);
202 p.set("key", 1023835);
203 QCOMPARE(p.get_time("key", mlt_time_clock), timeString);
206 void SetSimpleMathExpression()
209 p.set("key", "@16.0/9.0 *2 +3 -1");
210 QCOMPARE(p.get_int("key"), 5);
211 QCOMPARE(p.get_double("key"), 16.0/9.0 *2 +3 -1);
214 void PassOneProperty()
217 const char *s = "value";
219 QCOMPARE(p[1].get("key"), (void*) 0);
220 p[1].pass_property(p[0], "key");
221 QCOMPARE(p[1].get("key"), s);
224 void PassMultipleByPrefix()
227 const char *s = "value";
228 p[0].set("key.one", s);
229 p[0].set("key.two", s);
230 QCOMPARE(p[1].get("key.one"), (void*) 0);
231 QCOMPARE(p[1].get("key.two"), (void*) 0);
232 p[1].pass_values(p[0], "key.");
233 QCOMPARE(p[1].get("one"), s);
234 QCOMPARE(p[1].get("two"), s);
237 void PassMultipleByList()
240 const char *s = "value";
241 p[0].set("key.one", s);
242 p[0].set("key.two", s);
243 QCOMPARE(p[1].get("key.one"), (void*) 0);
244 QCOMPARE(p[1].get("key.two"), (void*) 0);
245 p[1].pass_list(p[0], "key.one key.two");
246 QCOMPARE(p[1].get("key.one"), s);
247 QCOMPARE(p[1].get("key.two"), s);
250 void MirrorProperties()
254 p[0].set("key", "value");
255 QCOMPARE(p[1].get("key"), "value");
258 void InheritProperties()
261 p[0].set("key", "value");
262 QVERIFY(p[1].get("key") == 0);
264 QCOMPARE(p[1].get("key"), "value");
270 QCOMPARE(p.get("key"), (void*) 0);
271 p.parse("key=value");
272 QCOMPARE(p.get("key"), "value");
273 p.parse("key=\"new value\"");
274 QCOMPARE(p.get("key"), "new value");
277 void RenameProperty()
280 p.set("key", "value");
281 QVERIFY(p.get("new key") == 0);
282 p.rename("key", "new key");
283 QCOMPARE(p.get("new key"), "value");
286 void SequenceDetected()
292 QVERIFY(p.is_sequence());
294 QVERIFY(!p.is_sequence());
297 void SerializesToYamlTiny()
300 p[0].set("key1", "value1");
301 p[0].set("key2", "value2");
302 p[1].set("1", "value3");
303 p[1].set("2", "value4");
304 p[0].set("seq", p[1].get_properties(), 0);
305 char* serializedYaml = p[0].serialise_yaml();
306 QCOMPARE(serializedYaml,
314 free(serializedYaml);
317 void RadixRespondsToLocale()
320 p.set_lcnumeric("en_US");
321 p.set("key", "0.125");
322 QCOMPARE(p.get_double("key"), double(1) / double(8));
323 p.set_lcnumeric("de_DE");
324 p.set("key", "0,125");
325 QCOMPARE(p.get_double("key"), double(1) / double(8));
328 void DoubleAnimation()
331 mlt_animation a = mlt_animation_new();
332 struct mlt_animation_item_s item;
334 mlt_animation_parse(a, "50=1; 60=60; 100=0", 100, fps, locale);
335 mlt_animation_remove(a, 60);
336 char *a_serialized = mlt_animation_serialize(a);
337 QCOMPARE(a_serialized, "50=1;100=0");
338 if (a_serialized) free(a_serialized);
339 item.property = mlt_property_init();
341 mlt_animation_get_item(a, &item, 10);
342 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
343 QCOMPARE(item.is_key, 0);
345 mlt_animation_get_item(a, &item, 50);
346 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
347 QCOMPARE(item.is_key, 1);
349 mlt_animation_get_item(a, &item, 75);
350 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.5);
351 QCOMPARE(item.is_key, 0);
353 mlt_animation_get_item(a, &item, 100);
354 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
355 QCOMPARE(item.is_key, 1);
357 mlt_animation_get_item(a, &item, 110);
358 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
359 QCOMPARE(item.is_key, 0);
361 mlt_property_close(item.property);
362 mlt_animation_close(a);
368 mlt_animation a = mlt_animation_new();
369 struct mlt_animation_item_s item;
371 mlt_animation_parse(a, "50=100; 60=60; 100=0", 100, fps, locale);
372 mlt_animation_remove(a, 60);
373 char *a_serialized = mlt_animation_serialize(a);
374 QCOMPARE(a_serialized, "50=100;100=0");
375 if (a_serialized) free(a_serialized);
376 item.property = mlt_property_init();
378 mlt_animation_get_item(a, &item, 10);
379 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
380 QCOMPARE(item.is_key, 0);
382 mlt_animation_get_item(a, &item, 50);
383 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
384 QCOMPARE(item.is_key, 1);
386 mlt_animation_get_item(a, &item, 75);
387 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 50);
388 QCOMPARE(item.is_key, 0);
390 mlt_animation_get_item(a, &item, 100);
391 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
392 QCOMPARE(item.is_key, 1);
394 mlt_animation_get_item(a, &item, 110);
395 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
396 QCOMPARE(item.is_key, 0);
398 mlt_property_close(item.property);
399 mlt_animation_close(a);
402 void AnimationWithTimeValueKeyframes()
405 mlt_animation a = mlt_animation_new();
406 struct mlt_animation_item_s item;
408 mlt_animation_parse(a, ":2.0=1; :4.0=0", 100, fps, locale);
409 char *a_serialized = mlt_animation_serialize(a);
410 // Time serializes to frame units :-\.
411 QCOMPARE(a_serialized, "50=1;100=0");
412 if (a_serialized) free(a_serialized);
413 item.property = mlt_property_init();
415 mlt_animation_get_item(a, &item, 10);
416 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
417 QCOMPARE(item.is_key, 0);
419 mlt_animation_get_item(a, &item, 50);
420 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 1.0);
421 QCOMPARE(item.is_key, 1);
423 mlt_animation_get_item(a, &item, 75);
424 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.5);
425 QCOMPARE(item.is_key, 0);
427 mlt_animation_get_item(a, &item, 100);
428 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
429 QCOMPARE(item.is_key, 1);
431 mlt_animation_get_item(a, &item, 110);
432 QCOMPARE(mlt_property_get_double(item.property, fps, locale), 0.0);
433 QCOMPARE(item.is_key, 0);
435 mlt_property_close(item.property);
436 mlt_animation_close(a);
439 void DiscreteIntAnimation()
442 mlt_animation a = mlt_animation_new();
443 struct mlt_animation_item_s item;
445 mlt_animation_parse(a, "50|=100; 60|=60; 100|=0", 100, fps, locale);
446 char *a_serialized = mlt_animation_serialize(a);
447 QCOMPARE(a_serialized, "50|=100;60|=60;100|=0");
448 if (a_serialized) free(a_serialized);
449 item.property = mlt_property_init();
451 mlt_animation_get_item(a, &item, 10);
452 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
453 QCOMPARE(item.is_key, 0);
455 mlt_animation_get_item(a, &item, 50);
456 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
457 QCOMPARE(item.is_key, 1);
459 mlt_animation_get_item(a, &item, 55);
460 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 100);
461 QCOMPARE(item.is_key, 0);
463 mlt_animation_get_item(a, &item, 60);
464 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 60);
465 QCOMPARE(item.is_key, 1);
467 mlt_animation_get_item(a, &item, 75);
468 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 60);
469 QCOMPARE(item.is_key, 0);
471 mlt_animation_get_item(a, &item, 100);
472 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
473 QCOMPARE(item.is_key, 1);
475 mlt_animation_get_item(a, &item, 110);
476 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
477 QCOMPARE(item.is_key, 0);
479 mlt_property_close(item.property);
480 mlt_animation_close(a);
483 void StringAnimation()
486 mlt_animation a = mlt_animation_new();
487 struct mlt_animation_item_s item;
489 mlt_animation_parse(a, "50=hello world; 60=\"good night\"; 100=bar", 100, fps, locale);
490 char *a_serialized = mlt_animation_serialize(a);
491 QCOMPARE(a_serialized, "50=hello world;60=\"good night\";100=bar");
492 if (a_serialized) free(a_serialized);
493 item.property = mlt_property_init();
495 mlt_animation_get_item(a, &item, 10);
496 QCOMPARE(mlt_property_get_string(item.property), "hello world");
497 QCOMPARE(item.is_key, 0);
499 mlt_animation_get_item(a, &item, 50);
500 QCOMPARE(mlt_property_get_string(item.property), "hello world");
501 QCOMPARE(item.is_key, 1);
503 mlt_animation_get_item(a, &item, 75);
504 QCOMPARE(mlt_property_get_string(item.property), "\"good night\"");
505 QCOMPARE(item.is_key, 0);
507 mlt_animation_get_item(a, &item, 100);
508 QCOMPARE(mlt_property_get_string(item.property), "bar");
509 QCOMPARE(item.is_key, 1);
511 mlt_animation_get_item(a, &item, 110);
512 QCOMPARE(mlt_property_get_string(item.property), "bar");
513 QCOMPARE(item.is_key, 0);
515 mlt_property_close(item.property);
516 mlt_animation_close(a);
519 void test_property_anim_get_double()
523 mlt_property p = mlt_property_init();
524 mlt_property_set_string(p, "10=100; 20=200");
525 QCOMPARE(mlt_property_get_double(p, fps, locale), 10.0);
526 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 0, len), 100.0);
527 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 15, len), 150.0);
528 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 20, len), 200.0);
530 mlt_property_set_string(p, "1.5");
531 QCOMPARE(mlt_property_get_double(p, fps, locale), 1.5);
532 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 10, 100), 1.5);
534 mlt_property_close(p);
537 void test_property_anim_get_int()
541 mlt_property p = mlt_property_init();
542 mlt_property_set_string(p, "10=100; 20=200");
543 QCOMPARE(mlt_property_get_int(p, fps, locale), 10);
544 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 0, len), 100);
545 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 15, len), 150);
546 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 20, len), 200);
548 mlt_property_set_string(p, "1.5");
549 QCOMPARE(mlt_property_get_int(p, fps, locale), 1);
550 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 10, 100), 1);
552 mlt_property_close(p);
555 void SmoothIntAnimation()
558 mlt_animation a = mlt_animation_new();
559 struct mlt_animation_item_s item;
561 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);
562 item.property = mlt_property_init();
563 char *a_serialized = mlt_animation_serialize(a);
564 QCOMPARE(a_serialized, "0=80;10~=80;20~=30;30~=40;40~=28;50=90;60=0;70=60;80=20");
565 if (a_serialized) free(a_serialized);
567 mlt_animation_get_item(a, &item, 10);
568 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 80);
569 QCOMPARE(item.is_key, 1);
571 mlt_animation_get_item(a, &item, 50);
572 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 90);
573 QCOMPARE(item.is_key, 1);
575 mlt_animation_get_item(a, &item, 55);
576 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 45);
577 QCOMPARE(item.is_key, 0);
579 mlt_animation_get_item(a, &item, 60);
580 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 0);
581 QCOMPARE(item.is_key, 1);
583 mlt_animation_get_item(a, &item, 75);
584 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 40);
585 QCOMPARE(item.is_key, 0);
587 mlt_animation_get_item(a, &item, 100);
588 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 20);
589 QCOMPARE(item.is_key, 0);
591 mlt_animation_get_item(a, &item, 110);
592 QCOMPARE(mlt_property_get_int(item.property, fps, locale), 20);
593 QCOMPARE(item.is_key, 0);
595 mlt_property_close(item.property);
596 mlt_animation_close(a);
599 void test_property_anim_set_double()
603 mlt_property p = mlt_property_init();
604 mlt_property_set_string(p, "10=100; 20=200");
605 mlt_property_anim_set_double(p, 1.5, fps, locale, 30, len, mlt_keyframe_linear);
606 QCOMPARE(mlt_property_get_double(p, fps, locale), 10.0);
607 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 0, len), 100.0);
608 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 15, len), 150.0);
609 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 20, len), 200.0);
610 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 25, len), 100.75);
611 QCOMPARE(mlt_property_anim_get_double(p, fps, locale, 30, len), 1.5);
612 mlt_property_close(p);
615 void test_property_anim_set_int()
619 mlt_property p = mlt_property_init();
620 mlt_property_set_string(p, "10=100; 20=200");
621 mlt_property_anim_set_int(p, 300, fps, locale, 30, len, mlt_keyframe_linear);
622 QCOMPARE(mlt_property_get_int(p, fps, locale), 10);
623 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 0, len), 100);
624 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 15, len), 150);
625 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 20, len), 200);
626 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 25, len), 250);
627 QCOMPARE(mlt_property_anim_get_int(p, fps, locale, 30, len), 300);
628 mlt_property_close(p);
631 void PercentAsRatio()
634 p.set("foo", "12.3%");
635 QCOMPARE(p.get_double("foo"), 0.123);
636 p.set("foo", "456 %");
637 QCOMPARE(p.get_double("foo"), 456.0);
640 void PropertiesAnimInt()
643 p.set_lcnumeric("POSIX");
645 // Construct animation from scratch
646 p.anim_set("foo", 0, 0);
647 p.anim_set("foo", 100, 50, -1, mlt_keyframe_smooth);
648 QCOMPARE(p.anim_get_int("foo", 0), 0);
649 QCOMPARE(p.anim_get_int("foo", 25), 50);
650 QCOMPARE(p.anim_get_int("foo", 50), 100);
651 QCOMPARE(p.get("foo"), "0=0;50~=100");
653 // Animation from string value
654 p.set("foo", "10=100;20=200");
655 QCOMPARE(p.anim_get_int("foo", 0), 100);
656 QCOMPARE(p.anim_get_int("foo", 15), 150);
657 QCOMPARE(p.anim_get_int("foo", 20), 200);
659 // Animation from string using time clock values
660 // Need to set a profile so fps can be used to convert time to frames.
661 Profile profile("dv_pal");
662 p.set("_profile", profile.get_profile(), 0);
663 p.set("foo", ":0.0=100; :2.0=200");
664 QCOMPARE(p.anim_get_int("foo", 0), 100);
665 QCOMPARE(p.anim_get_int("foo", 25), 150);
666 QCOMPARE(p.anim_get_int("foo", 50), 200);
669 void PropertiesAnimDouble()
672 p.set_lcnumeric("POSIX");
674 // Construct animation from scratch
675 p.anim_set("foo", 0.0, 0);
676 p.anim_set("foo", 100.0, 50, -1, mlt_keyframe_smooth);
677 QCOMPARE(p.anim_get_double("foo", 0), 0.0);
678 QCOMPARE(p.anim_get_double("foo", 25), 50.0);
679 QCOMPARE(p.anim_get_double("foo", 50), 100.0);
680 QCOMPARE(p.get("foo"), "0=0;50~=100");
682 // Animation from string value
683 p.set("foo", "10=100.2;20=200.8");
684 QCOMPARE(p.anim_get_double("foo", 0), 100.2);
685 QCOMPARE(p.anim_get_double("foo", 15), 150.5);
686 QCOMPARE(p.anim_get_double("foo", 20), 200.8);
688 // Animation from string using time clock values
689 // Need to set a profile so fps can be used to convert time to frames.
690 Profile profile("dv_pal");
691 p.set("_profile", profile.get_profile(), 0);
692 p.set("foo", ":0.0=100; :2.0=200");
693 QCOMPARE(p.anim_get_double("foo", 0), 100.0);
694 QCOMPARE(p.anim_get_double("foo", 25), 150.0);
695 QCOMPARE(p.anim_get_double("foo", 50), 200.0);
698 void PropertiesStringAnimation()
701 p.anim_set("key", "foo", 10);
702 p.anim_set("key", "bar", 30);
703 QCOMPARE(p.get("key"), "10|=foo;30|=bar");
704 p.set("key", "0=; 10=foo bar; 30=hello world");
705 QCOMPARE(p.anim_get("key", 1), "");
706 QCOMPARE(p.anim_get("key", 15), "foo bar");
707 QCOMPARE(p.anim_get("key", 45), "hello world");
712 mlt_property p = mlt_property_init();
713 mlt_rect r = { 1, 2, 3, 4, 5 };
715 mlt_property_set_rect( p, r );
716 QCOMPARE(mlt_property_get_string(p), "1 2 3 4 5");
718 mlt_property_set_rect( p, r );
719 QCOMPARE(mlt_property_get_string(p), "1 2 3 4");
722 mlt_property_set_rect( p, r );
723 QCOMPARE(mlt_property_get_string(p), "1 2");
725 mlt_property_set_string(p, "1.1/2.2:3.3x4.4:5.5");
726 r = mlt_property_get_rect(p, locale);
733 mlt_property_set_string(p, "1.1 2.2");
734 r = mlt_property_get_rect(p, locale);
737 QCOMPARE(r.w, DBL_MIN);
739 mlt_property_set_int64(p, UINT_MAX);
740 r = mlt_property_get_rect(p, locale);
741 QCOMPARE(r.x, double(UINT_MAX));
743 mlt_property_close(p);
756 mlt_rect q = p.get_rect("key");
762 p.set("key", 10, 20, 30, 40);
763 q = p.get_rect("key");
770 void RectFromString()
773 p.set_lcnumeric("POSIX");
774 const char *s = "1.1 2.2 3.3 4.4 5.5";
775 mlt_rect r = { 1.1, 2.2, 3.3, 4.4, 5.5 };
777 QCOMPARE(p.get("key"), s);
779 r = p.get_rect("key");
789 mlt_rect r1 = { 0, 0, 200, 200, 0 };
790 mlt_rect r2 = { 100, 100, 400, 400, 1.0 };
792 p.set_lcnumeric("POSIX");
794 // Construct animation from scratch
795 p.anim_set("key", r1, 0);
796 p.anim_set("key", r2, 50);
797 QCOMPARE(p.anim_get_rect("key", 0).x, 0.0);
798 QCOMPARE(p.anim_get_rect("key", 25).x, 50.0);
799 QCOMPARE(p.anim_get_rect("key", 25).y, 50.0);
800 QCOMPARE(p.anim_get_rect("key", 25).w, 300.0);
801 QCOMPARE(p.anim_get_rect("key", 25).h, 300.0);
802 QCOMPARE(p.anim_get_rect("key", 25).o, 0.5);
803 QCOMPARE(p.anim_get_rect("key", 50).x, 100.0);
804 QCOMPARE(p.get("key"), "0=0 0 200 200 0;50=100 100 400 400 1");
806 // Animation from string value
807 QCOMPARE(p.anim_get_rect("key", 0).x, 0.0);
808 QCOMPARE(p.anim_get_rect("key", 0).y, 0.0);
809 QCOMPARE(p.anim_get_rect("key", 0).w, 200.0);
810 QCOMPARE(p.anim_get_rect("key", 0).h, 200.0);
811 QCOMPARE(p.anim_get_rect("key", 0).o, 0.0);
812 QCOMPARE(p.anim_get_rect("key", 50).x, 100.0);
813 QCOMPARE(p.anim_get_rect("key", 50).y, 100.0);
814 QCOMPARE(p.anim_get_rect("key", 50).w, 400.0);
815 QCOMPARE(p.anim_get_rect("key", 50).h, 400.0);
816 QCOMPARE(p.anim_get_rect("key", 50).o, 1.0);
817 QCOMPARE(p.anim_get_rect("key", 15).x, 30.0);
818 QCOMPARE(p.anim_get_rect("key", 15).y, 30.0);
819 QCOMPARE(p.anim_get_rect("key", 15).w, 260.0);
820 QCOMPARE(p.anim_get_rect("key", 15).h, 260.0);
821 QCOMPARE(p.anim_get_rect("key", 15).o, 0.3);
824 p.set("key", "0~=0/0:200x200:0; 50=100/100:400x400:1");
825 QCOMPARE(p.anim_get_rect("key", 0).x, 0.0);
826 QCOMPARE(p.anim_get_rect("key", 0).y, 0.0);
827 QCOMPARE(p.anim_get_rect("key", 0).w, 200.0);
828 QCOMPARE(p.anim_get_rect("key", 0).h, 200.0);
829 QCOMPARE(p.anim_get_rect("key", 0).o, 0.0);
830 QCOMPARE(p.anim_get_rect("key", 50).x, 100.0);
831 QCOMPARE(p.anim_get_rect("key", 50).y, 100.0);
832 QCOMPARE(p.anim_get_rect("key", 50).w, 400.0);
833 QCOMPARE(p.anim_get_rect("key", 50).h, 400.0);
834 QCOMPARE(p.anim_get_rect("key", 50).o, 1.0);
835 QCOMPARE(p.anim_get_rect("key", 15).x, 25.8);
836 QCOMPARE(p.anim_get_rect("key", 15).y, 25.8);
837 QCOMPARE(p.anim_get_rect("key", 15).w, 251.6);
838 QCOMPARE(p.anim_get_rect("key", 15).h, 251.6);
839 QCOMPARE(p.anim_get_rect("key", 15).o, 0.258);
842 p.set("key", "0=0 0; 50=100% 200%");
843 QCOMPARE(p.anim_get_rect("key", 25).x, 0.5);
844 QCOMPARE(p.anim_get_rect("key", 25).y, 1.0);
850 p.set_lcnumeric("POSIX");
851 p.set("key", (int) 0xaabbccdd);
852 mlt_color color = p.get_color("key");
853 QCOMPARE(color.r, quint8(0xaa));
854 QCOMPARE(color.g, quint8(0xbb));
855 QCOMPARE(color.b, quint8(0xcc));
856 QCOMPARE(color.a, quint8(0xdd));
858 QCOMPARE(p.get_int("key"), int(0xaabbccdd));
861 void ColorFromString()
864 p.set_lcnumeric("POSIX");
866 mlt_color color = p.get_color("key");
867 QCOMPARE(color.r, quint8(0xff));
868 QCOMPARE(color.g, quint8(0x00));
869 QCOMPARE(color.b, quint8(0x00));
870 QCOMPARE(color.a, quint8(0xff));
871 p.set("key", "#deadd00d");
872 color = p.get_color("key");
873 QCOMPARE(color.r, quint8(0xad));
874 QCOMPARE(color.g, quint8(0xd0));
875 QCOMPARE(color.b, quint8(0x0d));
876 QCOMPARE(color.a, quint8(0xde));
879 void SetIntAndGetAnim()
882 p.set_lcnumeric("POSIX");
884 QCOMPARE(p.anim_get_int("key", 10, 50), 123);
886 QCOMPARE(p.anim_get_int("key", 10, 50), 123);
889 void SetDoubleAndGetAnim()
892 p.set_lcnumeric("POSIX");
894 QCOMPARE(p.anim_get_double("key", 10, 50), 123.0);
896 QCOMPARE(p.anim_get_double("key", 10, 50), 123.0);
899 void AnimNegativeTimevalue()
902 Profile profile("dv_pal");
903 p.set("_profile", profile.get_profile(), 0);
904 p.set_lcnumeric("POSIX");
905 p.set("key", "0=100; -1=200");
906 QCOMPARE(p.anim_get_int("key", 75, 100), 175);
907 p.set("key", "0=100; -1:=200");
908 QCOMPARE(p.anim_get_int("key", 75, 125), 175);
912 QTEST_APPLESS_MAIN(TestProperties)
914 #include "test_properties.moc"