455 gst_object_unref (pipe); |
445 gst_object_unref (pipe); |
456 } |
446 } |
457 |
447 |
458 void delayed_link() |
448 void delayed_link() |
459 { |
449 { |
460 GstElement* pa; |
|
461 xmlfile = "delayed_link"; |
450 xmlfile = "delayed_link"; |
462 std_log(LOG_FILENAME_LINE, "Test Started delayed_link"); |
451 std_log(LOG_FILENAME_LINE, "Test Started delayed_link"); |
463 fail_unless (gst_element_register (NULL, "parsetestelement", |
452 fail_unless (gst_element_register (NULL, "parsetestelement", |
464 GST_RANK_NONE, GST_TYPE_PARSE_TEST_ELEMENT)); |
453 GST_RANK_NONE, GST_TYPE_PARSE_TEST_ELEMENT)); |
465 |
454 |
466 /* This tests the delayed linking support in parse_launch by creating |
455 /* This tests the delayed linking support in parse_launch by creating |
467 * a test element based on bin, which contains a fakesrc and a sometimes |
456 * a test element based on bin, which contains a fakesrc and a sometimes |
468 * pad-template, and trying to link to a fakesink. When the bin transitions |
457 * pad-template, and trying to link to a fakesink. When the bin transitions |
469 * to paused it adds a pad, which should get linked to the fakesink */ |
458 * to paused it adds a pad, which should get linked to the fakesink */ |
470 |
|
471 pa = gst_element_factory_make ("parsetestelement", NULL); |
|
472 gst_object_unref (pa); |
|
473 //g_free (pa); |
|
474 run_delayed_test |
459 run_delayed_test |
475 ("parsetestelement name=src ! fakesink silent=true name=sink", "sink", |
460 ("parsetestelement name=src ! fakesink silent=true name=sink", "sink", |
476 TRUE); |
461 TRUE); |
477 |
462 |
478 /* Test, but this time specifying both pad names */ |
463 /* Test, but this time specifying both pad names */ |
581 } |
566 } |
582 |
567 |
583 return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); |
568 return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); |
584 } |
569 } |
585 |
570 |
586 void test_missing_elements() |
|
587 { |
|
588 GstParseContext *ctx; |
|
589 GstElement *element; |
|
590 GError *err = NULL; |
|
591 gchar **arr; |
|
592 |
|
593 xmlfile = "test_missing_elements"; |
|
594 std_log(LOG_FILENAME_LINE, "Test Started test_missing_elements"); |
|
595 /* avoid misleading 'no such element' error debug messages when using cvs */ |
|
596 if (!g_getenv ("GST_DEBUG")) |
|
597 gst_debug_set_default_threshold (GST_LEVEL_NONE); |
|
598 |
|
599 /* one missing element */ |
|
600 ctx = gst_parse_context_new (); |
|
601 element = gst_parse_launch_full ("fakesrc ! coffeesink", ctx, |
|
602 GST_PARSE_FLAG_FATAL_ERRORS, &err); |
|
603 fail_unless (err != NULL, "expected error"); |
|
604 fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); |
|
605 fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); |
|
606 arr = gst_parse_context_get_missing_elements (ctx); |
|
607 fail_unless (arr != NULL, "expected missing elements"); |
|
608 fail_unless_equals_string (arr[0], "coffeesink"); |
|
609 fail_unless (arr[1] == NULL); |
|
610 g_strfreev (arr); |
|
611 gst_parse_context_free (ctx); |
|
612 g_error_free (err); |
|
613 err = NULL; |
|
614 |
|
615 /* multiple missing elements */ |
|
616 ctx = gst_parse_context_new (); |
|
617 element = gst_parse_launch_full ("fakesrc ! bogusenc ! identity ! goomux ! " |
|
618 "fakesink", ctx, GST_PARSE_FLAG_FATAL_ERRORS, &err); |
|
619 fail_unless (err != NULL, "expected error"); |
|
620 fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); |
|
621 fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); |
|
622 arr = gst_parse_context_get_missing_elements (ctx); |
|
623 fail_unless (arr != NULL, "expected missing elements"); |
|
624 fail_unless_equals_string (arr[0], "bogusenc"); |
|
625 fail_unless_equals_string (arr[1], "goomux"); |
|
626 fail_unless (arr[2] == NULL); |
|
627 g_strfreev (arr); |
|
628 gst_parse_context_free (ctx); |
|
629 g_error_free (err); |
|
630 err = NULL; |
|
631 |
|
632 /* multiple missing elements, different link pattern */ |
|
633 ctx = gst_parse_context_new (); |
|
634 element = gst_parse_launch_full ("fakesrc ! bogusenc ! mux.sink " |
|
635 "blahsrc ! goomux name=mux ! fakesink fakesrc ! goosink", ctx, |
|
636 GST_PARSE_FLAG_FATAL_ERRORS, &err); |
|
637 fail_unless (err != NULL, "expected error"); |
|
638 fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); |
|
639 fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); |
|
640 arr = gst_parse_context_get_missing_elements (ctx); |
|
641 fail_unless (arr != NULL, "expected missing elements"); |
|
642 fail_unless_equals_string (arr[0], "bogusenc"); |
|
643 fail_unless_equals_string (arr[1], "blahsrc"); |
|
644 fail_unless_equals_string (arr[2], "goomux"); |
|
645 fail_unless_equals_string (arr[3], "goosink"); |
|
646 fail_unless (arr[4] == NULL); |
|
647 g_strfreev (arr); |
|
648 gst_parse_context_free (ctx); |
|
649 g_error_free (err); |
|
650 err = NULL; |
|
651 |
|
652 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
653 create_xml(0); |
|
654 } |
|
655 |
|
656 |
|
657 void test_flags() |
|
658 { |
|
659 GstElement *element; |
|
660 GError *err = NULL; |
|
661 |
|
662 xmlfile = "test_flags"; |
|
663 std_log(LOG_FILENAME_LINE, "Test Started test_flags"); |
|
664 |
|
665 /* avoid misleading 'no such element' error debug messages when using cvs */ |
|
666 if (!g_getenv ("GST_DEBUG")) |
|
667 gst_debug_set_default_threshold (GST_LEVEL_NONE); |
|
668 |
|
669 /* default behaviour is to return any already constructed bins/elements */ |
|
670 element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, 0, &err); |
|
671 fail_unless (err != NULL, "expected error"); |
|
672 fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); |
|
673 fail_unless (element != NULL, "expected partial pipeline/element"); |
|
674 g_error_free (err); |
|
675 err = NULL; |
|
676 gst_object_unref (element); |
|
677 |
|
678 /* test GST_PARSE_FLAG_FATAL_ERRORS */ |
|
679 element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, |
|
680 GST_PARSE_FLAG_FATAL_ERRORS, &err); |
|
681 fail_unless (err != NULL, "expected error"); |
|
682 fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT); |
|
683 fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); |
|
684 g_error_free (err); |
|
685 err = NULL; |
|
686 |
|
687 std_log(LOG_FILENAME_LINE, "Test Successful"); |
|
688 create_xml(0); |
|
689 } |
|
690 |
|
691 |
|
692 # if 0 |
571 # if 0 |
693 void |
572 void |
694 parse_suite (void) |
573 parse_suite (void) |
695 { |
574 { |
696 test_launch_lines(); |
575 test_launch_lines(); |