def test_import_and_render(self): importer = memory_importer.MemoryImporter() mem = importer.read_ram('testdata/full-image.mem') self.args.output = self.args.tmpfile('full-image.png') a = app.Application() a.create_output(mem, self.args, 'horizontal') self.assert_equal_image(self.args.output, 'testdata/full-image.png')
def test_output(self): img = Image.open('testdata/full-image.png') self.process_image(img) a = app.Application() a.create_output(self.ppu_memory, self.args, 'horizontal') actual_file = self.args.compile expect_file = 'testdata/full-image-rom.nes' self.assert_file_eq(actual_file, expect_file)
def test_output_square_small_with_locked_tiles(self): img = Image.open('testdata/full-image-small-square.png') self.args.is_locked_tiles = True self.process_image(img) a = app.Application() a.create_output(self.ppu_memory, self.args, 'horizontal') actual_file = self.args.compile expect_file = 'testdata/full-image-rom-small-square-locked-tiles.nes' self.assert_file_eq(actual_file, expect_file)
def test_import_by_kind(self): importer = memory_importer.MemoryImporter() mem = importer.read('testdata/full-image.mem', 'ram') a = app.Application() a.create_output(mem, self.args, 'horizontal') self.assert_output_result('chr') self.assert_output_result('nametable') self.assert_output_result('palette') self.assert_output_result('attribute')
def test_output_from_memory_dump(self): """Memory can be imported then split into components.""" memfile = 'testdata/full-image-mem.bin' a = app.Application() a.read_memory(memfile, 'ram', self.args) self.assert_output_result('chr') self.assert_output_result('nametable') self.assert_output_result('palette') self.assert_output_result('attribute')
def test_views(self): """Create views of the input.""" img = Image.open('testdata/full-image.png') self.process_image(img) a = app.Application() a.create_views(self.ppu_memory, self.args, img) self.assert_file_eq(self.args.palette_view, self.golden('pal', 'png')) self.assert_file_eq(self.args.colorization_view, self.golden('color', 'png')) self.assert_file_eq(self.args.reuse_view, self.golden('reuse', 'png')) self.assert_file_eq(self.args.nametable_view, self.golden('nt', 'png')) self.assert_file_eq(self.args.chr_view, self.golden('chr', 'png')) self.assert_file_eq(self.args.grid_view, self.golden('grid', 'png'))
def test_view_for_free_sprite_hard(self): """View for the zones in free sprites with hard areas.""" img = Image.open('testdata/free-sprites-hard.png') self.args.bg_color = bg_color_spec.build('00=30') self.args.is_sprite = True self.args.traversal = 'free' self.args.clear_views() self.args.free_zone_view = self.args.tmppng('free-zone-hard') self.process_image(img) a = app.Application() a.create_views(self.ppu_memory, self.args, img) self.golden_file_prefix = 'free-zone-hard' self.assert_file_eq(self.args.free_zone_view, self.golden('view', 'png'))
def test_views_sprite(self): """Create views for a sprite image.""" img = Image.open('testdata/reticule.png') self.args.bg_color = bg_color_spec.build('30') self.args.is_sprite = True self.args.nametable_view = None self.args.colorization_view = None self.process_image(img) a = app.Application() a.create_views(self.ppu_memory, self.args, img) self.golden_file_prefix = 'reticule' self.assert_file_eq(self.args.palette_view, self.golden('pal-view', 'png')) self.assert_file_eq(self.args.reuse_view, self.golden('reuse-view', 'png')) self.assert_file_eq(self.args.chr_view, self.golden('chr-view', 'png')) self.assert_file_eq(self.args.grid_view, self.golden('grid-view', 'png'))
def create_output(self): a = app.Application() if self.args.bg_color.fill: self.ppu_memory.override_bg_color(self.args.bg_color.fill) a.create_output(self.ppu_memory, self.args, self.args.traversal)