gstreamer_core/tsrc/check/pipelines/parse-launch/src/parse-launch.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    35 #include "std_log_result.h" 
    35 #include "std_log_result.h" 
    36 #define LOG_FILENAME_LINE __FILE__, __LINE__
    36 #define LOG_FILENAME_LINE __FILE__, __LINE__
    37 
    37 
    38 void create_xml(int result)
    38 void create_xml(int result)
    39 {
    39 {
    40 
       
    41     if(result)
    40     if(result)
    42     {
       
    43         assert_failed = 1;
    41         assert_failed = 1;
    44     } 
    42     
    45 
       
    46     testResultXml(xmlfile);
    43     testResultXml(xmlfile);
    47     close_log_file();
    44     close_log_file();
    48 
    45 }
    49     if(result)
    46 
    50     {
       
    51         exit (-1);
       
    52     }    
       
    53 
       
    54 }
       
    55 
       
    56 IMPORT_C GType gst_parse_test_element_get_type (void);
       
    57 #define GST_TYPE_PARSE_TEST_ELEMENT (gst_parse_test_element_get_type())
    47 #define GST_TYPE_PARSE_TEST_ELEMENT (gst_parse_test_element_get_type())
    58 
    48 static GType gst_parse_test_element_get_type (void);
    59 
    49 
    60 static GstElement *
    50 static GstElement *
    61 setup_pipeline (const gchar * pipe_descr)
    51 setup_pipeline (const gchar * pipe_descr)
    62 {
    52 {
    63   GstElement *pipeline;
    53   GstElement *pipeline;
   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();
   699 leaking_fail_pipes();
   578 leaking_fail_pipes();
   700 delayed_link();
   579 delayed_link();
   701 }
   580 }
   702 #endif
   581 #endif
   703 
   582 
   704 void (*fn[]) (void) = {
   583 void (*fn[5]) (void) = {
   705 test_launch_lines,
   584 test_launch_lines,
   706 test_launch_lines2,
   585 test_launch_lines2,
   707 expected_to_fail_pipes,
   586 expected_to_fail_pipes,
   708 leaking_fail_pipes,
   587 leaking_fail_pipes,
   709 delayed_link,
   588 delayed_link
   710 test_missing_elements,
       
   711 test_flags
       
   712 };
   589 };
   713 
   590 
   714 char *args[] = {
   591 char *args[] = {
   715 "test_launch_lines",
   592 "test_launch_lines",
   716 "test_launch_lines2",
   593 "test_launch_lines2",
   717 "expected_to_fail_pipes",
   594 "expected_to_fail_pipes",
   718 "leaking_fail_pipes",
   595 "leaking_fail_pipes",
   719 "delayed_link",
   596 "delayed_link"
   720 "test_missing_elements",
       
   721 "test_flags"
       
   722 };
   597 };
   723 
   598 
   724 GST_CHECK_MAIN (parse-launch);
   599 GST_CHECK_MAIN (parse-launch);