00001 00012 #define GITK_TESTS_WIDGET_C 00013 00014 #include "libgitk.h" 00015 00016 00020 static void test_setup(void) { 00021 gitk_log("-- beg -----------------------"); 00022 } 00023 00027 static void test_teardown(void) { 00028 gitk_log("-- end -----------------------\n\n"); 00029 } 00030 00031 00034 static gchar *dialog1_desc=\ 00035 "<?xml version=\"1.0\" ?>"\ 00036 "<!DOCTYPE giml SYSTEM \"http://gitk.sourceforge.net/giml.dtd\">"\ 00037 "<giml xmlns=\""GITK_NS_URL"\""\ 00038 " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""\ 00039 " xmlns:i18n=\""I18N_NS_URL"\""\ 00040 " >"\ 00041 " <dialog>"\ 00042 " <meta>"\ 00043 " <dc:title><i18n:text>dialog 1</i18n:text></dc:title>"\ 00044 " </meta>"\ 00045 " <widgetgroup>"\ 00046 " <widget id=\"Name\" type=\"characterinput_alphabetic\">"\ 00047 " <label><i18n:text>name</i18n:text></label>"\ 00048 " <disabled>true</disabled>"\ 00049 " </widget>"\ 00050 " </widgetgroup>"\ 00051 " </dialog>"\ 00052 "</giml>"; 00053 00057 START_TEST(test_gitk_widget_set_get_value) { 00058 GitkDialogPtr dialog1; 00059 00060 gitk_init(&test_argc,&test_argvptr,PACKAGE,LOCALEDIR); 00061 if((dialog1=gitk_dialog_new_from_string(dialog1_desc))) { 00062 00063 mark_point(); 00064 if(gitk_dialog_show(dialog1,FALSE)) { 00065 gchar *str_in="new content",*str_out; 00066 00067 mark_point(); 00068 gitk_widget_set_value(dialog1,"Name","value",str_in); 00069 mark_point(); 00070 str_out=gitk_widget_get_value(dialog1,"Name","value"); 00071 fail_unless(str_out!=NULL,"empty result"); 00072 00073 snprintf(errormsg,ERROR_STR_LENGTH,"value in widget[Name].value => \"%s\" , value expected => \"%s\"",str_out,str_in); 00074 fail_unless((!strcmp(str_in,str_out)),errormsg); 00075 xmlFree(str_out); 00076 gitk_dialog_hide(dialog1); 00077 } 00078 else { 00079 snprintf(errormsg,ERROR_STR_LENGTH,"error showing dialog => %d : %s",gitk_get_error_code(),gitk_get_error_str()); 00080 fail(errormsg); 00081 } 00082 gitk_dialog_free(dialog1); 00083 } 00084 else { 00085 snprintf(errormsg,ERROR_STR_LENGTH,"error parsing dialog => %d : %s",gitk_get_error_code(),gitk_get_error_str()); 00086 fail(errormsg); 00087 } 00088 gitk_done(); 00089 } 00090 END_TEST 00091 00092 00096 TCase *libgitk_widget_tcase(void) { 00097 TCase *tc = tcase_create("Control"); 00098 00099 tcase_add_test(tc,test_gitk_widget_set_get_value); 00100 tcase_add_unchecked_fixture(tc, test_setup, test_teardown); 00101 return(tc); 00102 }