class ViewTest(unittest.TestCase): def testTransition(self): l1 = TestLayer() l2 = TestLayer() l3 = TestLayer() v = self.e.view v.pushLayer(l1) v.pushLayer(l2) v.pushLayer(l3) while l3.visibility < 1.0: self.e.run() v.popLayer(l3) v.popLayer(l2) v.popLayer(l1) while l1 in v.layers or l2 in v.layers or l3 in v.layers: self.e.run() assert not v.layers def setUp(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True) self.e = GameEngine(config) def tearDown(self): self.e.quit()
class ViewTest(unittest.TestCase): def testTransition(self): l1 = TestLayer() l2 = TestLayer() l3 = TestLayer() v = self.e.view v.pushLayer(l1) v.pushLayer(l2) v.pushLayer(l3) while l3.visibility < 1.0: self.e.run() v.popLayer(l3) v.popLayer(l2) v.popLayer(l1) while l1 in v.layers or l2 in v.layers or l3 in v.layers: self.e.run() assert not v.layers def setUp(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True) self.e = GameEngine(config) def tearDown(self): self.e.quit()
class ResourceTest(unittest.TestCase): def testAsynchLoad(self): self.r = Resource() self.e.addTask(self.r) self.r.load(self, "result", lambda: loader()) while not self.result: self.e.run() assert self.result == 0xDADA def testSynchLoad(self): self.r = Resource() self.e.addTask(self.r) assert self.r.load(self, "result2", loader, synch=True) == 0xDADA assert self.result2 == 0xDADA def testAsynchLoadSeries(self): self.r = Resource() self.e.addTask(self.r) for i in range(10): self.r.load(self, "result%d" % i, loader) while not self.result9: self.e.run() assert self.result9 == 0xDADA def testCallback(self): self.r = Resource() self.e.addTask(self.r) self.quux = None def loaded(r): self.quux = r self.r.load(self, "fuuba", loader, onLoad=loaded).join() while not self.fuuba: self.e.run() assert self.fuuba == self.quux def setUp(self): Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True) # Resource expects game_priority to be an integer, # Config won't know unless we define it as such. Config.define("performance", "game_priority", int, 2) self.e = GameEngine() def tearDown(self): self.e.quit()
class ResourceTest(unittest.TestCase): def testAsynchLoad(self): self.r = Resource() self.e.addTask(self.r) self.r.load(self, "result", lambda: loader()) while not self.result: self.e.run() assert self.result == 0xdada def testSynchLoad(self): self.r = Resource() self.e.addTask(self.r) assert self.r.load(self, "result2", loader, synch=True) == 0xdada assert self.result2 == 0xdada def testAsynchLoadSeries(self): self.r = Resource() self.e.addTask(self.r) for i in range(10): self.r.load(self, "result%d" % i, loader) while not self.result9: self.e.run() assert self.result9 == 0xdada def testCallback(self): self.r = Resource() self.e.addTask(self.r) self.quux = None def loaded(r): self.quux = r self.r.load(self, "fuuba", loader, onLoad=loaded).join() while not self.fuuba: self.e.run() assert self.fuuba == self.quux def setUp(self): Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True) # Resource expects game_priority to be an integer, # Config won't know unless we define it as such. Config.define("performance", "game_priority", int, 2) self.e = GameEngine() def tearDown(self): self.e.quit()
class DialogTestInteractive(unittest.TestCase): def testGetTest(self): text = getText(self.e, "Please enter your name:", "Wario") def setUp(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True) self.e = GameEngine(config) def tearDown(self): self.e.quit()
class DialogTestInteractive(unittest.TestCase): def testGetTest(self): text = getText(self.e, "Please enter your name:", "Wario") def setUp(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True) self.e = GameEngine(config) def tearDown(self): self.e.quit()
class MenuTest(unittest.TestCase): def testMenuNavigation(self): m = Menu(self.e, rootMenu) self.e.view.pushLayer(m) def setUp(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True) self.e = GameEngine(config) def tearDown(self): self.e.quit()
def testNetworking(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True) e1 = GameEngine(config) e1.startServer() session1 = e1.connect("localhost") session2 = e1.connect("localhost") while not session1.isConnected() or not session2.isConnected(): e1.run() session1.world.createPlayer("mario") session2.world.createPlayer("luigi") for i in range(10): e1.run() assert len(e1.server.world.players) == 2 assert len(session1.world.players) == 2 assert len(session2.world.players) == 2 session3 = e1.connect("localhost") for i in range(10): e1.run() assert len(session3.world.players) == 2 session1.disconnect() for i in range(10): e1.run() assert len(e1.server.world.players) == 1 assert len(session2.world.players) == 1 e1.quit()
def testNetworking(self): config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True) e1 = GameEngine(config) e1.startServer() session1 = e1.connect("localhost") session2 = e1.connect("localhost") while not session1.isConnected() or not session2.isConnected(): e1.run() session1.world.createPlayer("mario") session2.world.createPlayer("luigi") for i in range(10): e1.run() assert len(e1.server.world.players) == 2 assert len(session1.world.players) == 2 assert len(session2.world.players) == 2 session3 = e1.connect("localhost") for i in range(10): e1.run() assert len(session3.world.players) == 2 session1.disconnect() for i in range(10): e1.run() assert len(e1.server.world.players) == 1 assert len(session2.world.players) == 1 e1.quit()