-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.py
83 lines (68 loc) · 1.92 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
""" Here'll be all the unit tests.
For now all it does is loading the ROM at argv[1] and two maps """
from bluespider import mapped_gui
from bluespider import mapped
from PyQt4 import QtGui
import sys
import unittest
fn = "/home/jaume/RH/pkmnruby-mgr.gba"
class MapsTest(unittest.TestCase):
def setUp(self):
self.app = QtGui.QApplication([])
self.win = mapped_gui.Window()
self.win.show()
self.win.load_rom(fn)
def tearDown(self):
#app.exec_()
self.win.close()
self.app.deleteLater()
def test(self):
load_all_maps(self.win)
def load_all_maps(w):
rom, rom_data = w.rom_contents, w.rom_data
banks = mapped.get_banks(rom, rom_data)
for bank_n in range(len(banks)):
maps = mapped.get_map_headers(rom, bank_n, banks)
for map_n in range(len(maps)):
print(bank_n, map_n)
w.load_map(bank_n, map_n)
def t_rom_data(w, fn):
w.load_rom(fn)
rom = w.rom_contents
rom_code = mapped.get_rom_code(rom)
rom_data, game = mapped.get_rom_data(rom_code)
if "RUBY" in fn.upper():
assert w.rom_code == rom_code == b"AXVE"
if "FR" in fn.upper():
assert w.rom_code == rom_code == b"BPRE"
def run_tests(w):
print("loading ROM")
fn = sys.argv[1]
t_rom_data(w, fn)
w.load_rom(fn)
try:
t_rom_data(w, fn)
print("passed rom data")
except Exception as e:
print(e)
print("failed rom data")
try:
load_all_maps(w)
except Exception as e:
print(e)
print("failed load_maps")
#print("loading map 0 0")
#w.load_map(0, 0)
#print("loading map 0 1 with the warp function")
#w.go_to_warp(None, 0, 1)
def main():
app = QtGui.QApplication([])
win = mapped_gui.Window()
win.show()
run_tests(win)
win.close()
#app.exec_()
app.deleteLater()
if __name__ == "__main__":
#main()
unittest.main()