| 1 |
#!/usr/bin/env python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# #################################################################### |
| 5 |
# Copyright (C) 2005-2019 by the FIFE team |
| 6 |
# http://www.fifengine.net |
| 7 |
# This file is part of FIFE. |
| 8 |
# |
| 9 |
# FIFE is free software; you can redistribute it and/or |
| 10 |
# modify it under the terms of the GNU Lesser General Public |
| 11 |
# License as published by the Free Software Foundation; either |
| 12 |
# version 2.1 of the License, or (at your option) any later version. |
| 13 |
# |
| 14 |
# This library is distributed in the hope that it will be useful, |
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
# Lesser General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU Lesser General Public |
| 20 |
# License along with this library; if not, write to the |
| 21 |
# Free Software Foundation, Inc., |
| 22 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 |
# #################################################################### |
| 24 |
|
| 25 |
import sys |
| 26 |
from .swig_test_utils import * |
| 27 |
|
| 28 |
class TestImgMgr(unittest.TestCase): |
| 29 |
|
| 30 |
def setUp(self): |
| 31 |
self.engine = getEngine() |
| 32 |
|
| 33 |
def tearDown(self): |
| 34 |
self.engine.destroy() |
| 35 |
|
| 36 |
def testImageImgMgr(self): |
| 37 |
imgMgr = self.engine.getImageManager() |
| 38 |
self.assert_(imgMgr) |
| 39 |
self.assert_(imgMgr.getTotalResources() == 0) |
| 40 |
img = imgMgr.create('tests/data/beach_e1.png') |
| 41 |
self.assertEqual(imgMgr.getTotalResourcesLoaded(), 0) |
| 42 |
self.assertEqual(imgMgr.getTotalResourcesCreated(), 1) |
| 43 |
img = imgMgr.get(img.getHandle()) |
| 44 |
self.assertEqual(imgMgr.getTotalResourcesLoaded(), 1) |
| 45 |
self.assertEqual(imgMgr.getTotalResourcesCreated(), 0) |
| 46 |
|
| 47 |
def testImageImgMgrFail(self): |
| 48 |
imgMgr = self.engine.getImageManager() |
| 49 |
# TODO: This test fails as imgMgr.load doesn't throw an exception as expected |
| 50 |
# self.assertRaises(RuntimeError,imgMgr.load,'does_not_exist.png') |
| 51 |
|
| 52 |
|
| 53 |
TEST_CLASSES = [TestImgMgr] |
| 54 |
|
| 55 |
if __name__ == '__main__': |
| 56 |
unittest.main() |