Exemple #1
0
static void
test_qof_object_is_dirty( Fixture *fixture, gconstpointer pData )
{
    QofBook *book = NULL;
    gint32 list_length;

    g_test_message( "Test null check returns false" );
    g_assert( qof_object_is_dirty( NULL ) == FALSE );

    g_test_message( "Test with no objects" );
    book = qof_book_new();
    g_assert( book );
    object_dirty_struct.call_count = 0;
    g_assert( qof_object_is_dirty( book ) == FALSE );
    g_assert_cmpint( object_dirty_struct.call_count, == , 0 );

    list_length = generate_and_register_objects( 1, MOCK_OBJECT_DIRTY );

    g_test_message( "Test with registered objects and suppose all collections are clean" );
    object_dirty_struct.objects = get_object_modules();
    object_dirty_struct.result = FALSE;
    g_assert( qof_object_is_dirty( book ) == FALSE );
    g_assert_cmpint( object_dirty_struct.call_count, == , list_length );

    g_test_message( "Test with registered objects and suppose first collection is dirty" );
    object_dirty_struct.objects = get_object_modules();
    object_dirty_struct.result = TRUE;
    object_dirty_struct.call_count = 0;
    g_assert( qof_object_is_dirty( book ) == TRUE );
    g_assert_cmpint( object_dirty_struct.call_count, == , 1 ); /* should break on first */

    qof_book_destroy( book );
}
Exemple #2
0
gboolean
qof_book_not_saved (const QofBook *book)
{
    if (!book) return FALSE;

    return(qof_instance_get_dirty_flag(book) || qof_object_is_dirty(book));
}