Exemple #1
0
static void
_adg_behavior_misc(void)
{
    AdgContainer *container;
    AdgEntity *entity1, *entity2;
    GSList *children;

    container = adg_container_new();
    entity1 = ADG_ENTITY(adg_toy_text_new("Testing..."));
    entity2 = ADG_ENTITY(adg_title_block_new());

    children = adg_container_children(container);
    g_assert_null(children);

    adg_container_add(container, entity1);
    children = adg_container_children(container);
    g_assert_nonnull(children);
    g_assert_cmpint(g_slist_length(children), ==, 1);
    g_slist_free(children);

    adg_container_add(container, entity2);
    children = adg_container_children(container);
    g_assert_nonnull(children);
    g_assert_cmpint(g_slist_length(children), ==, 2);
    g_slist_free(children);

    adg_entity_destroy(entity1);
    children = adg_container_children(container);
    g_assert_nonnull(children);
    g_assert_cmpint(g_slist_length(children), ==, 1);
    g_slist_free(children);

    adg_entity_destroy(entity2);
    children = adg_container_children(container);
    g_assert_null(children);

    adg_entity_destroy(ADG_ENTITY(container));
}
Exemple #2
0
static void
_adg_behavior_entity(void)
{
    AdgCanvas *canvas;
    const CpmlExtents *extents;
    AdgTitleBlock *title_block;

    canvas = ADG_CANVAS(adg_test_canvas());

    adg_entity_arrange(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_true(extents->is_defined);
    adg_assert_isapprox(extents->size.x, 1);
    adg_assert_isapprox(extents->size.y, 1);

    adg_entity_invalidate(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_false(extents->is_defined);

    title_block = adg_title_block_new();
    adg_canvas_set_title_block(canvas, title_block);
    adg_entity_arrange(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_true(extents->is_defined);
    g_assert_cmpfloat(extents->size.x, >, 1);
    g_assert_cmpfloat(extents->size.y, >, 1);
    g_assert_cmpfloat(extents->size.x, <, 5000);
    g_assert_cmpfloat(extents->size.y, <, 5000);

    adg_canvas_set_size_explicit(canvas, 5000, 5000);
    adg_entity_arrange(ADG_ENTITY(canvas));
    extents = adg_entity_get_extents(ADG_ENTITY(canvas));
    g_assert_true(extents->is_defined);
    adg_assert_isapprox(extents->size.x, 5000);
    adg_assert_isapprox(extents->size.y, 5000);

    adg_entity_destroy(ADG_ENTITY(canvas));
}