Changeset 395

Show
Ignore:
Timestamp:
09/17/07 00:09:00 (1 year ago)
Author:
bjourne
Message:

Add test that checks that GtkAnimView kills its timer.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gtkimageview/tests/test-anim-view.c

    r288 r395  
    1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*- */ 
    2 /*
     1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-  
     2
    33 * This file contains tests that verify that the #GtkAnimView class 
    44 * behaves correctly. 
     
    3737 
    3838/** 
     39 * test_finalize_stops_timer: 
     40 * 
     41 * The objective of this test is to verify that GtkAnimView removes 
     42 * all its sources that it is using when finalized. The test case 
     43 * could be a little simpler if #477653 is fixed, but for now, we rely 
     44 * on brute force and trying to provoke a segfault. 
     45 **/ 
     46static void 
     47test_finalize_stops_timer () 
     48{ 
     49    printf ("test_finalize_stops_timer\n"); 
     50    GtkAnimView *aviews[20]; 
     51    for (int n = 0; n < G_N_ELEMENTS (aviews); n++) 
     52    { 
     53        aviews[n] = (GtkAnimView *) gtk_anim_view_new (); 
     54        g_object_ref (aviews[n]); 
     55        gtk_object_sink (GTK_OBJECT (aviews[n])); 
     56 
     57        AnimWrapper *aw = anim_wrapper_new (2.0); 
     58        // Timer starts here 
     59        gtk_anim_view_set_anim (aviews[n], aw->anim); 
     60    } 
     61    for (int n = 0; n < G_N_ELEMENTS (aviews); n++) 
     62    { 
     63        gtk_widget_destroy (GTK_WIDGET (aviews[n])); 
     64        g_object_unref (aviews[n]); 
     65    } 
     66    // Timers might run, but object is gnome, leads to segfault. 
     67    GMainContext *main_ctx = g_main_context_default (); 
     68    g_usleep (1100 * 1000); 
     69    g_main_context_iteration (main_ctx, TRUE); 
     70} 
     71 
     72/** 
    3973 * test_inherited_default_values: 
    4074 * 
     
    204238 
    205239int 
    206 main (int argc, char *argv[]) 
     240main (int   argc, 
     241      char *argv[]) 
    207242{ 
    208243    gtk_init (&argc, &argv); 
     244    test_finalize_stops_timer (); 
    209245    test_inherited_default_values (); 
    210246    test_get_set_anim (); 
     
    213249    test_stopping_animation (); 
    214250    test_playing_null_anim (); 
    215     printf ("6 tests passed.\n"); 
    216 } 
    217  
     251    printf ("7 tests passed.\n"); 
     252} 
     253