Changeset 661

Show
Ignore:
Timestamp:
04/05/09 13:03:23 (4 years ago)
Author:
bjourne
Message:

Add test for get_draw_rect() when the view is not allocated.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pygtkimageview/tests/test_module.py

    r659 r661  
    192192    assert rect.x == 25 and rect.y == 25 
    193193    assert rect.width == 50 and rect.height == 50 
     194 
     195def test_draw_rect_unallocated(): 
     196    ''' 
     197    Ensure that get_draw_rect() always return a zero rectangle when 
     198    the view is not allocated. 
     199    ''' 
     200    pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, False, 8, 50, 50) 
     201    view = gtkimageview.ImageView() 
     202    view.set_pixbuf(pixbuf) 
     203    for x_ofs, y_ofs in [(30, 30), (-10, 20), (0, 0), (5, 10)]: 
     204        view.set_offset(x_ofs, y_ofs) 
     205        rect = view.get_draw_rect() 
     206        assert rect.x == 0 
     207        assert rect.y == 0 
     208        assert rect.width == 0 
     209        assert rect.height == 0 
    194210 
    195211def test_set_offset():