From: Shinwoo Kim Date: Tue, 13 Dec 2016 10:00:35 +0000 (+0900) Subject: at_spi2_tool: return node pointer, relation flow to/from information X-Git-Tag: accepted/tizen/common/20170102.152347^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fat-spi2-core.git;a=commitdiff_plain;h=2658d2c2bdf3a8d50d10bb290151151652caf369 at_spi2_tool: return node pointer, relation flow to/from information Do not abort even though the information is too long. It was not possilbe to get next launchpad-loader application. Change-Id: Ia7e5c6ad7a989bff3425b922ef4d80cf7667be1c --- diff --git a/test/at_spi2_tool.c b/test/at_spi2_tool.c index 7a7b9a5..b8f051f 100644 --- a/test/at_spi2_tool.c +++ b/test/at_spi2_tool.c @@ -6,7 +6,7 @@ #include #define ERROR_STATE -1 -#define SAFE_BUFFER_SIZE 255 +#define SAFE_BUFFER_SIZE 2048 #define CHECK_OUTPUT_WIDTH 42 #define MINIMAL_MODULE_WIDTH 3 #define ATTR_WIDTH 50 @@ -99,7 +99,7 @@ static char *_multiply_string(char c, unsigned number) static void _print_module_legend() { - printf("\n[[node role name],[attributes list],[x,y,width,height],[node name],[states list]]\n\n"); + printf("\n[[node],[node role name],[attributes list],[x,y,width,height],[node name],[states list][flow to node, flow from node]\n\n"); } static void _print_atspi_states_legend() @@ -277,7 +277,7 @@ static char *_get_attributes(AtspiAccessible *node) int ret = snprintf(attributes_string, ATTR_WIDTH, "(%s=%s)", (char*)attr_key, (char*)attr_value); if (ret >= ATTR_WIDTH) { fprintf(stderr, "_get_attributes: generated string is too long. Buffer overflow"); - abort(); + attributes_string[ATTR_WIDTH - 1] = '\n'; } _combine_strings(&result, attributes_string); } @@ -286,6 +286,31 @@ static char *_get_attributes(AtspiAccessible *node) return result; } +static AtspiAccessible *_get_object_in_relation(AtspiAccessible * source, AtspiRelationType search_type) +{ + GArray *relations; + AtspiAccessible *ret = NULL; + AtspiRelation *relation; + AtspiRelationType type; + int i; + if (source) { + relations = atspi_accessible_get_relation_set(source, NULL); + if (relations) { + for (i = 0; i < relations->len; i++) { + relation = g_array_index(relations, AtspiRelation *, i); + type = atspi_relation_get_relation_type(relation); + + if (type == search_type) { + ret = atspi_relation_get_target(relation, 0); + break; + } + } + g_array_free(relations, TRUE); + } + } + return ret; +} + static char *_get_info(AtspiAccessible *node, int length_limit) { if (!node) @@ -301,19 +326,22 @@ static char *_get_info(AtspiAccessible *node, int length_limit) _truncate_string(states, length_limit); char result[SAFE_BUFFER_SIZE]; - int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s],[%s],[%s,%s,%s,%s],[%s],[%s]]", - node_role_name, - attributes, - box_size->x, - box_size->y, - box_size->width, - box_size->height, - node_name, - states); + int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%p],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%p,%p]]", + node, + node_role_name, + attributes, + box_size->x, + box_size->y, + box_size->width, + box_size->height, + node_name, + states, + _get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO), + _get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM)); if (ret >= SAFE_BUFFER_SIZE) { fprintf(stderr, "_get_info: generated string is too long. Buffer overflow"); - abort(); + result[SAFE_BUFFER_SIZE - 1] = '\n'; } free(node_name);