glib/tests/app-name.c
changeset 72 403e7f6ed6c5
parent 50 79045913e4e9
equal deleted inserted replaced
71:28ccaba883f4 72:403e7f6ed6c5
    16 #undef G_DISABLE_ASSERT
    16 #undef G_DISABLE_ASSERT
    17 #undef G_LOG_DOMAIN
    17 #undef G_LOG_DOMAIN
    18 
    18 
    19 #include <glib.h>
    19 #include <glib.h>
    20 #include <errno.h>
    20 #include <errno.h>
    21 #define LOG_FILE "c:\\logs\\app_name_log.txt"
    21 #include <sys/stat.h>
    22 #include "std_log_result.h"
    22 #include <glib/gprintf.h>
    23 #define LOG_FILENAME_LINE __FILE__, __LINE__
    23 #ifdef __SYMBIAN32__
    24 
    24 #include "mrt2_glib2_test.h"
    25 void create_xml(int result)
    25 #endif /*__SYMBIAN32__*/
    26 {
       
    27     if(result)
       
    28         assert_failed = 1;
       
    29     
       
    30     testResultXml("app_name_log");
       
    31     close_log_file();
       
    32 }
       
    33 
    26 
    34 int main (int argc, char *argv[])
    27 int main (int argc, char *argv[])
    35 {
    28 {
    36     char appName[] = "TestApp";
    29     char appName[] = "TestApp";
    37     const char *retAppName;
    30     const char *retAppName;
       
    31     #ifdef __SYMBIAN32__
       
    32     g_log_set_handler (NULL,  G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
       
    33     g_set_print_handler(mrtPrintHandler);
       
    34     #endif /*__SYMBIAN32__*/
    38     
    35     
       
    36     g_print("Test app-name Start");
    39     g_set_application_name(appName);
    37     g_set_application_name(appName);
    40     
    38     
    41     retAppName = g_get_application_name();
    39     retAppName = g_get_application_name();
    42 	
    40 	
    43 	if(retAppName != NULL)
    41 	if(retAppName != NULL)
    44 	    {
    42 	    {
    45         if(g_strcmp0(appName, retAppName) !=0 )
    43         if(g_strcmp0(appName, retAppName) !=0 )
    46             {
    44             {
    47             std_log(LOG_FILENAME_LINE, "g_get_application_name returned wrong name");
    45             g_print( "g_get_application_name returned wrong name");
    48             assert_failed = 1;
    46             assert_failed = 1;
    49             }
    47             }
    50 	    }
    48 	    }
    51 	else
    49 	else
    52 	    {
    50 	    {
    53         std_log(LOG_FILENAME_LINE, "g_get_application_name returned NULL. errno  = %d", errno);
    51         g_print( "g_get_application_name returned NULL. errno  = %d", errno);
    54         assert_failed = 1;
    52         assert_failed = 1;
    55 	    }
    53 	    }
    56 	
    54 	
    57 	g_free((void *)retAppName);
    55 	g_free((void *)retAppName);
    58 	
    56 	
    59 	if(assert_failed)
    57 	if(assert_failed)
    60           std_log(LOG_FILENAME_LINE,"Test Failed");
    58           g_print("Test app-name Failed");
    61     else
    59     else
    62           std_log(LOG_FILENAME_LINE,"Test Successful");
    60           g_print("Test app-name Successful");
    63 	
    61 	
    64     create_xml(0);
    62     #if __SYMBIAN32__
       
    63 	testResultXml("app-name");
       
    64     #endif /* EMULATOR */
    65 
    65 
    66 	return 0;
    66 	return 0;
    67 }
    67 }