File: gui_sketch_nav_tree_test.c

package info (click to toggle)
crystal-facet-uml 1.63.3-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 21,640 kB
  • sloc: ansic: 109,610; xml: 3,085; makefile: 138; sh: 113
file content (522 lines) | stat: -rw-r--r-- 21,896 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
/* File: gui_sketch_nav_tree_test.c; Copyright and License: see below */

#include "gui_sketch_nav_tree_test.h"
#include "sketch/gui_sketch_nav_tree.h"
#include "shape/shape_int_rectangle.h"
#include "gui_resources.h"
#include "entity/data_diagram.h"
#include "test_fixture.h"
#include "test_expect.h"
#include "test_environment_assert.h"
#include "test_case_result.h"

static test_fixture_t * set_up();
static void tear_down( test_fixture_t *fix );
static test_case_result_t test_get_object_at_pos_on_no_diagram( test_fixture_t *fix );  /* extreme case */
static test_case_result_t test_get_object_at_pos_on_single_diagram( test_fixture_t *fix );  /* no parent, no siblings, no children */
static test_case_result_t test_get_object_at_pos_on_1parent_1child_diagram( test_fixture_t *fix );  /* standard case, but no siblings */
static test_case_result_t test_get_object_at_pos_on_2parent_2siblings_diagram( test_fixture_t *fix );  /* standard case, but no children */

test_suite_t gui_sketch_nav_tree_test_get_suite(void)
{
    test_suite_t result;
    test_suite_init( &result,
                     "gui_sketch_nav_tree_test_get_suite",
                     TEST_CATEGORY_UNIT | TEST_CATEGORY_CONTINUOUS | TEST_CATEGORY_COVERAGE,
                     &set_up,
                     &tear_down
                   );
    test_suite_add_test_case( &result, "test_get_object_at_pos_on_no_diagram", &test_get_object_at_pos_on_no_diagram );
    test_suite_add_test_case( &result, "test_get_object_at_pos_on_single_diagram", &test_get_object_at_pos_on_single_diagram );
    test_suite_add_test_case( &result, "test_get_object_at_pos_on_1parent_1child_diagram", &test_get_object_at_pos_on_1parent_1child_diagram );
    test_suite_add_test_case( &result, "test_get_object_at_pos_on_2parent_2siblings_diagram", &test_get_object_at_pos_on_2parent_2siblings_diagram );
    return result;
}

static const int LEFT = 100;
static const int TOP = 57;
static const int WIDTH = 50;
static const int HEIGHT = 400;

struct test_fixture_struct {
    gui_resources_t res;
    gui_sketch_texture_t texture_downloader;
    shape_int_rectangle_t bounds;
    data_diagram_t self;
    data_diagram_t parent;
    data_diagram_t child;
    data_diagram_t other_child;

    /* cairo and pango objects */
    cairo_surface_t *surface;
    cairo_t *cr;
    PangoLayout *font_layout;
};
typedef struct test_fixture_struct test_fixture_t;  /* double declaration as reminder */
static test_fixture_t test_fixture;

static test_fixture_t * set_up()
{
    test_fixture_t *fix = &test_fixture;
    /* init cairo and pango objects */
    {
        (*fix).surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, 640, 480 );
        TEST_ENVIRONMENT_ASSERT( CAIRO_STATUS_SUCCESS == cairo_surface_status( (*fix).surface ) );
        (*fix).cr = cairo_create( (*fix).surface );
        TEST_ENVIRONMENT_ASSERT( CAIRO_STATUS_SUCCESS == cairo_status( (*fix).cr ) );
        (*fix).font_layout = pango_cairo_create_layout( (*fix).cr );
    }

    gui_resources_init( &((*fix).res) );
    gui_sketch_texture_init( &((*fix).texture_downloader) );
    shape_int_rectangle_init( &((*fix).bounds), LEFT, TOP, WIDTH, HEIGHT );
    data_diagram_init_empty( &((*fix).parent) );
    data_diagram_set_row_id( &((*fix).parent), 1000 );
    data_diagram_init_empty( &((*fix).self) );
    data_diagram_set_row_id( &((*fix).self), 1001 );
    data_diagram_set_parent_row_id( &((*fix).self), 1000 );
    data_diagram_init_empty( &((*fix).child) );
    data_diagram_set_row_id( &((*fix).child), 1002 );
    data_diagram_set_parent_row_id( &((*fix).child), 1001 );
    data_diagram_init_empty( &((*fix).other_child) );
    data_diagram_set_row_id( &((*fix).other_child), 1003 );
    data_diagram_set_parent_row_id( &((*fix).other_child), 1001 );
    return fix;
}

static void tear_down( test_fixture_t *fix )
{
    assert( fix != NULL );
    data_diagram_destroy( &((*fix).parent) );
    data_diagram_destroy( &((*fix).self) );
    data_diagram_destroy( &((*fix).child) );
    data_diagram_destroy( &((*fix).other_child) );
    shape_int_rectangle_destroy( &((*fix).bounds) );
    gui_sketch_texture_destroy( &((*fix).texture_downloader) );
    gui_resources_destroy( &((*fix).res) );

    /* destroy cairo and pango objects */
    {
        g_object_unref( (*fix).font_layout );
        cairo_destroy( (*fix).cr );
        cairo_surface_finish( (*fix).surface );
        cairo_surface_destroy( (*fix).surface );
    }
}

test_case_result_t get_node_coords( const gui_sketch_nav_tree_t *testee, uint32_t idx, int32_t *out_x, int32_t *out_y )
{
    const uint32_t cnt = gui_sketch_nav_tree_get_node_count( testee );
    TEST_EXPECT( idx < cnt );
    const pos_nav_tree_node_t *pos = gui_sketch_nav_tree_get_node_pos_const( testee, idx );
    const shape_int_rectangle_t *pos_icon = pos_nav_tree_node_get_icon_box_const( pos );
    *out_x = shape_int_rectangle_get_left(pos_icon) + 1;
    *out_y = shape_int_rectangle_get_top(pos_icon) + 1;
    /* printf("x:%d,y:%d\n",*out_x,*out_y); */
    return TEST_CASE_RESULT_OK;
}

static test_case_result_t test_get_object_at_pos_on_no_diagram( test_fixture_t *fix )
{
    assert( fix != NULL );

    /* init the testee, because a gui_sketch_nav_tree_t contains some hundred diagrams, each abobe 10kB */
    static gui_sketch_nav_tree_t testee;
    {
        gui_sketch_nav_tree_init( &testee, &((*fix).res), &((*fix).texture_downloader) );
        gui_sketch_nav_tree_set_bounds( &testee, ((*fix).bounds) );
        gui_sketch_nav_tree_do_layout( &testee, (*fix).cr );
    }

    /* get position */
    int32_t x = 0;
    int32_t y = 0;
    const test_case_result_t res = get_node_coords( &testee, 0, &x, &y );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    TEST_EXPECT_EQUAL_INT( 1, gui_sketch_nav_tree_get_node_count( &testee ) );

    /* test button type */
    gui_sketch_action_t action_id;

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x, y, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NEW_ROOT_DIAGRAM, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x, (y-2), &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, LEFT-1, y, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    /* test object id */
    data_id_t selected_id;
    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x, y, &selected_id );
    TEST_EXPECT( ! data_id_is_valid(&selected_id) );

    /* test gap info */
    gui_error_t g_err;
    data_id_t parent_id;
    int32_t list_order;
    shape_int_rectangle_t gap_line;

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x, y, &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_OUT_OF_BOUNDS, g_err );

    /* destroy the testee */
    gui_sketch_nav_tree_destroy( &testee );
    return TEST_CASE_RESULT_OK;
}

static test_case_result_t test_get_object_at_pos_on_single_diagram( test_fixture_t *fix )
{
    assert( fix != NULL );

    /* init the testee, because a gui_sketch_nav_tree_t contains some hundred diagrams, each abobe 10kB */
    static gui_sketch_nav_tree_t testee;
    {
        gui_sketch_nav_tree_init( &testee, &((*fix).res), &((*fix).texture_downloader) );
        gui_sketch_nav_tree_set_bounds( &testee, (*fix).bounds );
        {
            testee.ancestors_count = 1;
            testee.ancestor_diagrams[0] = (*fix).parent;
            testee.siblings_count = 1;
            testee.sibling_diagrams[0] = (*fix).parent;
            testee.siblings_self_index = 0;
        }
        gui_sketch_nav_tree_do_layout( &testee, (*fix).cr );
    }

    /* node positions */
    test_case_result_t res;
    int32_t x0 = 0;
    int32_t y0 = 0;
    res = get_node_coords( &testee, 0, &x0, &y0 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x1 = 0;
    int32_t y1 = 0;
    res = get_node_coords( &testee, 1, &x1, &y1 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    TEST_EXPECT_EQUAL_INT( 2, gui_sketch_nav_tree_get_node_count( &testee ) );

    /* test button type */
    gui_sketch_action_t action_id;

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x0, y0, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x1, y1, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NEW_CHILD_DIAGRAM, action_id );

    /* test object id */
    data_id_t selected_id;

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x0, y0, &selected_id );
    TEST_EXPECT( data_id_is_valid(&selected_id) );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x1, y1, &selected_id );
    TEST_EXPECT( ! data_id_is_valid(&selected_id) );

    /* test gap info */
    gui_error_t g_err;
    data_id_t parent_id;
    int32_t list_order;
    shape_int_rectangle_t gap_line;

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x0, (y0-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT( ! data_id_is_valid(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x1, (y1-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT( data_id_is_valid(&parent_id) );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x1, y1+(y1-y0), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT( data_id_is_valid(&parent_id) );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&parent_id) );  /* same gap as above */

    /* destroy the testee */
    gui_sketch_nav_tree_destroy( &testee );
    return TEST_CASE_RESULT_OK;
}

static test_case_result_t test_get_object_at_pos_on_1parent_1child_diagram( test_fixture_t *fix )
{
    assert( fix != NULL );

    /* init the testee, because a gui_sketch_nav_tree_t contains some hundred diagrams, each abobe 10kB */
    static gui_sketch_nav_tree_t testee;
    {
        gui_sketch_nav_tree_init( &testee, &((*fix).res), &((*fix).texture_downloader) );
        gui_sketch_nav_tree_set_bounds( &testee, (*fix).bounds );
        {
            testee.ancestors_count = 2;
            testee.ancestor_diagrams[0] = (*fix).self;
            testee.ancestor_diagrams[1] = (*fix).parent;
            testee.siblings_count = 1;
            testee.sibling_diagrams[0] = (*fix).self;
            testee.siblings_self_index = 0;
            testee.children_count = 1;
            testee.child_diagrams[0] = (*fix).child;
        }
        gui_sketch_nav_tree_do_layout( &testee, (*fix).cr );
    }

    /* node positions */
    test_case_result_t res;
    int32_t x0 = 0;
    int32_t y0 = 0;
    res = get_node_coords( &testee, 0, &x0, &y0 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x1 = 0;
    int32_t y1 = 0;
    res = get_node_coords( &testee, 1, &x1, &y1 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x2 = 0;
    int32_t y2 = 0;
    res = get_node_coords( &testee, 2, &x2, &y2 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x3 = 0;
    int32_t y3 = 0;
    res = get_node_coords( &testee, 3, &x3, &y3 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x4 = 0;
    int32_t y4 = 0;
    res = get_node_coords( &testee, 4, &x4, &y4 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    TEST_EXPECT_EQUAL_INT( 5, gui_sketch_nav_tree_get_node_count( &testee ) );

    /* test button type */
    gui_sketch_action_t action_id;

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x0, y0, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x1, y1, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x2, y2, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x3, y3, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NEW_CHILD_DIAGRAM, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x4, y4, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NEW_SIBLING_DIAGRAM, action_id );

    /* test object id */
    data_id_t selected_id;

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x0, y0, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x1, y1, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x2, y2, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1002, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x3, y3, &selected_id );
    TEST_EXPECT( ! data_id_is_valid(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x4, y4, &selected_id );
    TEST_EXPECT( ! data_id_is_valid(&selected_id) );

    /* test gap info */
    gui_error_t g_err;
    data_id_t parent_id;
    int32_t list_order;
    shape_int_rectangle_t gap_line;

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x0, (y0-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT( ! data_id_is_valid(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x1, (y1-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x2, (y2-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x3, (y3-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x4, (y4-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x4, y4+(y4-y3), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&parent_id) );  /* same gap as above */

    /* destroy the testee */
    gui_sketch_nav_tree_destroy( &testee );
    return TEST_CASE_RESULT_OK;
}

static test_case_result_t test_get_object_at_pos_on_2parent_2siblings_diagram( test_fixture_t *fix )
{
    assert( fix != NULL );

    /* init the testee, because a gui_sketch_nav_tree_t contains some hundred diagrams, each abobe 10kB */
    static gui_sketch_nav_tree_t testee;
    {
        gui_sketch_nav_tree_init( &testee, &((*fix).res), &((*fix).texture_downloader) );
        gui_sketch_nav_tree_set_bounds( &testee, ((*fix).bounds) );
        {
            testee.ancestors_count = 3;
            testee.ancestor_diagrams[0] = (*fix).child;
            testee.ancestor_diagrams[1] = (*fix).self;
            testee.ancestor_diagrams[2] = (*fix).parent;
            testee.siblings_count = 3;
            testee.sibling_diagrams[0] = (*fix).other_child;
            testee.sibling_diagrams[1] = (*fix).child;
            testee.sibling_diagrams[2] = (*fix).other_child;
            testee.siblings_self_index = 1;
        }
        gui_sketch_nav_tree_do_layout( &testee, (*fix).cr );
    }

    /* node positions */
    test_case_result_t res;
    int32_t x0 = 0;
    int32_t y0 = 0;
    res = get_node_coords( &testee, 0, &x0, &y0 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x1 = 0;
    int32_t y1 = 0;
    res = get_node_coords( &testee, 1, &x1, &y1 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x2 = 0;
    int32_t y2 = 0;
    res = get_node_coords( &testee, 2, &x2, &y2 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x3 = 0;
    int32_t y3 = 0;
    res = get_node_coords( &testee, 3, &x3, &y3 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x4 = 0;
    int32_t y4 = 0;
    res = get_node_coords( &testee, 4, &x4, &y4 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x5 = 0;
    int32_t y5 = 0;
    res = get_node_coords( &testee, 5, &x5, &y5 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    int32_t x6 = 0;
    int32_t y6 = 0;
    res = get_node_coords( &testee, 6, &x6, &y6 );
    TEST_EXPECT_EQUAL_INT( TEST_CASE_RESULT_OK, res );
    TEST_EXPECT_EQUAL_INT( 7, gui_sketch_nav_tree_get_node_count( &testee ) );

    /* test button type */
    gui_sketch_action_t action_id;

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x0, y0, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x1, y1, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x2, y2, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x3, y3, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x4, y4, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NEW_CHILD_DIAGRAM, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x5, y5, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NONE, action_id );

    gui_sketch_nav_tree_get_button_at_pos ( &testee, x6, y6, &action_id );
    TEST_EXPECT_EQUAL_INT( GUI_SKETCH_ACTION_NEW_SIBLING_DIAGRAM, action_id );

    /* test object id */
    data_id_t selected_id;

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x0, y0, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x1, y1, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x2, y2, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1003, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x3, y3, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1002, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x4, y4, &selected_id );
    TEST_EXPECT( ! data_id_is_valid(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x5, y5, &selected_id );
    TEST_EXPECT_EQUAL_INT( 1003, data_id_get_row_id(&selected_id) );

    gui_sketch_nav_tree_get_object_id_at_pos ( &testee, x6, y6, &selected_id );
    TEST_EXPECT( ! data_id_is_valid(&selected_id) );

    /* test gap info */
    gui_error_t g_err;
    data_id_t parent_id;
    int32_t list_order;
    shape_int_rectangle_t gap_line;

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x0, (y0-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT( ! data_id_is_valid(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x1, (y1-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1000, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x2, (y2-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x3, (y3-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x4, (y4-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1002, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x5, (y5-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x6, (y6-2), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );

    g_err = gui_sketch_nav_tree_get_gap_info_at_pos ( &testee, x6, y6+(y6-y5), &parent_id, &list_order, &gap_line );
    TEST_EXPECT_EQUAL_INT( GUI_ERROR_NONE, g_err );
    TEST_EXPECT_EQUAL_INT( 1001, data_id_get_row_id(&parent_id) );  /* same gap as above */

    /* destroy the testee */
    gui_sketch_nav_tree_destroy( &testee );
    return TEST_CASE_RESULT_OK;
}


/*
 * Copyright 2019-2025 Andreas Warnke
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */