| | 271 | |
|---|
| | 272 | def test_get_draw_method(): |
|---|
| | 273 | ''' |
|---|
| | 274 | Sanity test for the PixbufDrawCache.get_method() classmethod. |
|---|
| | 275 | ''' |
|---|
| | 276 | obj = gtkimageview.PixbufDrawCache() |
|---|
| | 277 | assert hasattr(obj, 'get_method') |
|---|
| | 278 | opts = gtkimageview.PixbufDrawOpts() |
|---|
| | 279 | gtkimageview.PixbufDrawCache.get_method(opts, opts) |
|---|
| | 280 | |
|---|
| | 281 | def test_return_of_get_draw_method(): |
|---|
| | 282 | ''' |
|---|
| | 283 | Ensure that PixbufDrawCache.get_method() returns either |
|---|
| | 284 | DRAW_METHOD_CONTAINS, DRAW_METHOD_SCALE or DRAW_METHOD_SCROLL. |
|---|
| | 285 | ''' |
|---|
| | 286 | obj = gtkimageview.PixbufDrawCache() |
|---|
| | 287 | opts = gtkimageview.PixbufDrawOpts() |
|---|
| | 288 | ret = obj.get_method(opts, opts) |
|---|
| | 289 | assert ret in (gtkimageview.DRAW_METHOD_CONTAINS, |
|---|
| | 290 | gtkimageview.DRAW_METHOD_SCALE, |
|---|
| | 291 | gtkimageview.DRAW_METHOD_SCROLL) |
|---|
| | 292 | |
|---|
| | 293 | def test_type_error_for_draw_method(): |
|---|
| | 294 | ''' |
|---|
| | 295 | Ensure that TypeError is raised if PixbufDrawCache.get_method() is |
|---|
| | 296 | called with an argument that is not a PixbufDrawOpts object. |
|---|
| | 297 | ''' |
|---|
| | 298 | arg_pairs = [(None, None), |
|---|
| | 299 | (gtkimageview.PixbufDrawOpts(), None), |
|---|
| | 300 | (None, gtkimageview.PixbufDrawOpts()), |
|---|
| | 301 | ("Hello", "Foo")] |
|---|
| | 302 | for last_opts, new_opts in arg_pairs: |
|---|
| | 303 | try: |
|---|
| | 304 | gtkimageview.PixbufDrawCache.get_method(last_opts, new_opts) |
|---|
| | 305 | assert False |
|---|
| | 306 | except TypeError: |
|---|
| | 307 | assert True |
|---|