Module ViewTest
[hide private]
[frames] | no frames]

Source Code for Module ViewTest

 1  #####################################################################
 
 2  # -*- coding: iso-8859-1 -*-                                        #
 
 3  #                                                                   #
 
 4  # Frets on Fire                                                     #
 
 5  # Copyright (C) 2006 Sami Kyöstilä                                  #
 
 6  #                                                                   #
 
 7  # This program is free software; you can redistribute it and/or     #
 
 8  # modify it under the terms of the GNU General Public License       #
 
 9  # as published by the Free Software Foundation; either version 2    #
 
10  # of the License, or (at your option) any later version.            #
 
11  #                                                                   #
 
12  # This program is distributed in the hope that it will be useful,   #
 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of    #
 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     #
 
15  # GNU General Public License for more details.                      #
 
16  #                                                                   #
 
17  # You should have received a copy of the GNU General Public License #
 
18  # along with this program; if not, write to the Free Software       #
 
19  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,        #
 
20  # MA  02110-1301, USA.                                              #
 
21  #####################################################################
 
22  
 
23  import unittest 
24  from GameEngine import GameEngine 
25  from View import View, Layer 
26  
 
27 -class TestLayer(Layer):
28 - def __init__(self):
29 self.visibility = 0 30 self.topMost = False
31
32 - def render(self, visibility, topMost):
33 self.visibility = visibility 34 self.topMost = topMost
35
36 - def __repr__(self):
37 return "Layer(%x)" % abs(id(self))
38
39 -class ViewTest(unittest.TestCase):
40 - def testTransition(self):
41 l1 = TestLayer() 42 l2 = TestLayer() 43 l3 = TestLayer() 44 v = self.e.view 45 46 v.pushLayer(l1) 47 v.pushLayer(l2) 48 v.pushLayer(l3) 49 50 while l3.visibility < 1.0: 51 self.e.run() 52 53 v.popLayer(l3) 54 v.popLayer(l2) 55 v.popLayer(l1) 56 57 while l1 in v.layers or l2 in v.layers or l3 in v.layers: 58 self.e.run() 59 60 assert not v.layers
61
62 - def setUp(self):
63 self.e = GameEngine()
64
65 - def tearDown(self):
66 self.e.quit()
67 68 if __name__ == "__main__": 69 unittest.main() 70