| 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 |
from .swig_test_utils import * |
| 26 |
import time |
| 27 |
|
| 28 |
class TestView(unittest.TestCase): |
| 29 |
|
| 30 |
def setUp(self): |
| 31 |
self.engine = getEngine() |
| 32 |
self.model = self.engine.getModel() |
| 33 |
|
| 34 |
self.imgMgr = self.engine.getImageManager() |
| 35 |
self.animMgr = self.engine.getAnimationManager() |
| 36 |
|
| 37 |
frame_delay = 100 |
| 38 |
|
| 39 |
#create the animation... messy I know |
| 40 |
self.cursor_anim = self.animMgr.create("cursor_anim") |
| 41 |
|
| 42 |
imgs = [] |
| 43 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_000.png')) |
| 44 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0001.png')) |
| 45 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0002.png')) |
| 46 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0003.png')) |
| 47 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0004.png')) |
| 48 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0005.png')) |
| 49 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0006.png')) |
| 50 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0007.png')) |
| 51 |
imgs.append(self.imgMgr.load('tests/data/crate/full_s_0008.png')) |
| 52 |
|
| 53 |
for img in imgs: |
| 54 |
self.cursor_anim.addFrame(img, frame_delay) |
| 55 |
|
| 56 |
|
| 57 |
#create the drag animation... messy I know |
| 58 |
self.cursor_drag_anim = self.animMgr.create("cursor_drag_anim") |
| 59 |
|
| 60 |
imgs = [] |
| 61 |
imgs.append(self.imgMgr.load('tests/data/wolf_walk/gfx/run_e_1.png')) |
| 62 |
imgs.append(self.imgMgr.load('tests/data/wolf_walk/gfx/run_e_2.png')) |
| 63 |
imgs.append(self.imgMgr.load('tests/data/wolf_walk/gfx/run_e_3.png')) |
| 64 |
imgs.append(self.imgMgr.load('tests/data/wolf_walk/gfx/run_e_4.png')) |
| 65 |
imgs.append(self.imgMgr.load('tests/data/wolf_walk/gfx/run_e_5.png')) |
| 66 |
|
| 67 |
for img in imgs: |
| 68 |
self.cursor_drag_anim.addFrame(img, frame_delay) |
| 69 |
|
| 70 |
self.cursor = self.engine.getCursor() |
| 71 |
self.cursor.set(self.cursor_anim) |
| 72 |
self.cursor.setDrag(self.cursor_drag_anim, 50, 50) |
| 73 |
|
| 74 |
self.engine.initializePumping() |
| 75 |
|
| 76 |
def tearDown(self): |
| 77 |
self.engine.finalizePumping() |
| 78 |
self.engine.destroy() |
| 79 |
|
| 80 |
def testAnimatedCursor(self): |
| 81 |
for i in range(500): |
| 82 |
self.engine.pump() |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
TEST_CLASSES = [TestView] |
| 88 |
|
| 89 |
if __name__ == '__main__': |
| 90 |
unittest.main() |
| 91 |
|