class ResourceTest(unittest.TestCase): def testAsynchLoad(self): self.r = Resource() self.e.addTask(self.r, synchronized=False) 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, synchronized=False) 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, synchronized=False) 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, synchronized=False) 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.appName() + ".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 = Engine() def tearDown(self): self.e.quit()
class ResourceTest(unittest.TestCase): def testAsynchLoad(self): self.r = Resource() self.e.addTask(self.r, synchronized = False) 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, synchronized = False) 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, synchronized = False) 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, synchronized = False) 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, synchronized=False) 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, synchronized=False) 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, synchronized=False) 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, synchronized=False) 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): self.e = Engine() def tearDown(self): self.e.quit()
class ResourceTest(unittest.TestCase): def testAsynchLoad(self): self.r = Resource() self.e.addTask(self.r, synchronized = False) 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, synchronized = False) 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, synchronized = False) 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, synchronized = False) 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): self.e = Engine() def tearDown(self): self.e.quit()