Back to index

im-sdk  12.3.91
basic.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <iiimcf.h>
00004 #include "common.h"
00005 
00006 IIIMCF_context context;
00007 
00008 static void
00009 create_context()
00010 {
00011     IIIMF_status st;
00012 
00013     st = iiimcf_create_context(handle, IIIMCF_ATTR_NULL, &context);
00014     if (st != IIIMF_STATUS_SUCCESS) test_iiimf_error(st);
00015 }
00016 
00017 static void
00018 destroy_context(
00019     IIIMCF_context c
00020 )
00021 {
00022     IIIMF_status st;
00023 
00024     st = iiimcf_destroy_context(c);
00025     if (st != IIIMF_STATUS_SUCCESS) test_iiimf_error(st);
00026 }
00027 
00028 static char attr_teststr[] = "teststr";
00029 
00030 static void
00031 set_context_attr(
00032     IIIMCF_context c
00033 )
00034 {
00035     IIIMCF_attr attr;
00036 
00037     check(iiimcf_context_get_attr(c, &attr));
00038     check(iiimcf_attr_put_integer_value(attr, IIIMCF_ATTR_PRIVATE_START + 1,
00039                                    10));
00040     check(iiimcf_attr_put_ptr_value(attr, IIIMCF_ATTR_PRIVATE_START + 2,
00041                                 set_context_attr));
00042     check(iiimcf_attr_put_string_value(attr, IIIMCF_ATTR_PRIVATE_START + 3,
00043                                    attr_teststr));
00044 }
00045 
00046 static void
00047 check_context_attr(
00048     IIIMCF_context c
00049 )
00050 {
00051     IIIMCF_attr attr;
00052     int i;
00053     void *p;
00054     const char* str;
00055 
00056     check(iiimcf_context_get_attr(c, &attr));
00057     check(iiimcf_attr_get_integer_value(attr, IIIMCF_ATTR_PRIVATE_START + 1, &i));
00058     test_assert(i == 10);
00059     check(iiimcf_attr_get_ptr_value(attr, IIIMCF_ATTR_PRIVATE_START + 2, &p));
00060     test_assert(p == set_context_attr);
00061     check(iiimcf_attr_get_string_value(attr, IIIMCF_ATTR_PRIVATE_START + 3, &str));
00062     test_assert(str == attr_teststr);
00063 }
00064 
00065 int
00066 main(
00067     int argc,
00068     char **argv
00069 )
00070 {
00071     test_init();
00072     test_show_version_info(handle);
00073     test_show_input_methods();
00074     test_show_objects();
00075     create_context();
00076     set_context_attr(context);
00077     check_context_attr(context);
00078 
00079     test_seticfocus(context);
00080     test_unseticfocus(context);
00081     check(iiimcf_reset_context(context));
00082     test_seticfocus(context);
00083     test_unseticfocus(context);
00084 
00085     destroy_context(context);
00086     test_uninit();
00087 
00088     return 0;
00089 }
00090 
00091 /* Local Variables: */
00092 /* c-file-style: "iiim-project" */
00093 /* End: */