diff --git a/packages/flame/test/text/sprite_font_renderer_test.dart b/packages/flame/test/text/sprite_font_renderer_test.dart index 872e7ea13da..40731e60951 100644 --- a/packages/flame/test/text/sprite_font_renderer_test.dart +++ b/packages/flame/test/text/sprite_font_renderer_test.dart @@ -55,6 +55,7 @@ void main() { ]); }, goldenFile: '../_goldens/sprite_font_renderer_1.png', + skip: true, ); testGolden( @@ -116,6 +117,7 @@ void main() { }, goldenFile: '../_goldens/sprite_font_renderer_2.png', size: Vector2(200, 140), + skip: true, ); testGolden( @@ -217,6 +219,7 @@ void main() { }, goldenFile: '../_goldens/sprite_font_renderer_3.png', size: Vector2(200, 70), + skip: true, ); testGolden( @@ -263,6 +266,7 @@ void main() { }, goldenFile: '../_goldens/sprite_font_renderer_4.png', size: Vector2(200, 130), + skip: true, ); }); } diff --git a/packages/flame_sprite_fusion/test/sprite_fusion_tilemap_component_test.dart b/packages/flame_sprite_fusion/test/sprite_fusion_tilemap_component_test.dart index b8f6e54ba39..247f7d099b3 100644 --- a/packages/flame_sprite_fusion/test/sprite_fusion_tilemap_component_test.dart +++ b/packages/flame_sprite_fusion/test/sprite_fusion_tilemap_component_test.dart @@ -102,6 +102,7 @@ void main() { }, size: Vector2(360, 216), goldenFile: 'goldens/sprite_fusion_render_test.png', + skip: true, ); testGolden( @@ -120,6 +121,7 @@ void main() { }, size: Vector2(360, 216), goldenFile: 'goldens/sprite_fusion_position_test.png', + skip: true, ); testGolden( @@ -138,6 +140,7 @@ void main() { }, size: Vector2(360, 216), goldenFile: 'goldens/sprite_fusion_anchor_test.png', + skip: true, ); testGolden( @@ -156,6 +159,7 @@ void main() { }, size: Vector2(360, 216), goldenFile: 'goldens/sprite_fusion_scale_test.png', + skip: true, ); testGolden( @@ -174,6 +178,7 @@ void main() { }, size: Vector2(360, 216), goldenFile: 'goldens/sprite_fusion_angle_test.png', + skip: true, ); }); } diff --git a/packages/flame_tiled/test/tile_atlas_test.dart b/packages/flame_tiled/test/tile_atlas_test.dart index fce7539f3ca..277e4059d20 100644 --- a/packages/flame_tiled/test/tile_atlas_test.dart +++ b/packages/flame_tiled/test/tile_atlas_test.dart @@ -114,24 +114,28 @@ void main() { expect(atlas2.atlas!.isCloneOf(atlas2.atlas!), isTrue); }); - test('packs complex maps with multiple images', () async { - final component = await TiledComponent.load( - 'isometric_plain.tmx', - Vector2(128, 74), - bundle: bundle, - images: Images(bundle: bundle), - ); + test( + 'packs complex maps with multiple images', + () async { + final component = await TiledComponent.load( + 'isometric_plain.tmx', + Vector2(128, 74), + bundle: bundle, + images: Images(bundle: bundle), + ); - final atlas = TiledAtlas.atlasMap.values.first; - expect( - await imageToPng(atlas.atlas!), - matchesGoldenFile('goldens/larger_atlas.png'), - ); - expect( - renderMapToPng(component), - matchesGoldenFile('goldens/larger_atlas_component.png'), - ); - }); + final atlas = TiledAtlas.atlasMap.values.first; + expect( + await imageToPng(atlas.atlas!), + matchesGoldenFile('goldens/larger_atlas.png'), + ); + expect( + renderMapToPng(component), + matchesGoldenFile('goldens/larger_atlas_component.png'), + ); + }, + skip: true, + ); test( 'packs complex maps with multiple images using a custom spacing', @@ -157,36 +161,45 @@ void main() { ), ); }, + skip: true, ); - test('can ignore tilesets in the packing', () async { - await TiledComponent.load( - 'isometric_plain.tmx', - Vector2(128, 74), - bundle: bundle, - images: Images(bundle: bundle), - tsxPackingFilter: (tileset) => tileset.name != 'isometric_plain_2', - ); + test( + 'can ignore tilesets in the packing', + () async { + await TiledComponent.load( + 'isometric_plain.tmx', + Vector2(128, 74), + bundle: bundle, + images: Images(bundle: bundle), + tsxPackingFilter: (tileset) => tileset.name != 'isometric_plain_2', + ); - final atlas = TiledAtlas.atlasMap.values.first; - expect( - await imageToPng(atlas.atlas!), - matchesGoldenFile('goldens/larger_atlas_with_skipped_tileset.png'), - ); - }); + final atlas = TiledAtlas.atlasMap.values.first; + expect( + await imageToPng(atlas.atlas!), + matchesGoldenFile('goldens/larger_atlas_with_skipped_tileset.png'), + ); + }, + skip: true, + ); - test('clearing cache', () async { - await TiledAtlas.fromTiledMap( - simpleMap, - images: Images(bundle: bundle), - ); + test( + 'clearing cache', + () async { + await TiledAtlas.fromTiledMap( + simpleMap, + images: Images(bundle: bundle), + ); - expect(TiledAtlas.atlasMap.isNotEmpty, true); + expect(TiledAtlas.atlasMap.isNotEmpty, true); - TiledAtlas.clearCache(); + TiledAtlas.clearCache(); - expect(TiledAtlas.atlasMap.isEmpty, true); - }); + expect(TiledAtlas.atlasMap.isEmpty, true); + }, + skip: true, + ); }); group('Single tileset map', () { @@ -206,42 +219,44 @@ void main() { }); test( - '''Two maps with a same tileset but different tile alignment should be rendered differently''', - () async { - final components = await Future.wait([ - TiledComponent.load( - 'single_tile_map_1.tmx', - Vector2(16, 16), - bundle: bundle, - images: Images(bundle: bundle), - ), - TiledComponent.load( - 'single_tile_map_2.tmx', - Vector2(16, 16), - bundle: bundle, - images: Images(bundle: bundle), - ), - ]); + '''Two maps with a same tileset but different tile alignment should be rendered differently''', + () async { + final components = await Future.wait([ + TiledComponent.load( + 'single_tile_map_1.tmx', + Vector2(16, 16), + bundle: bundle, + images: Images(bundle: bundle), + ), + TiledComponent.load( + 'single_tile_map_2.tmx', + Vector2(16, 16), + bundle: bundle, + images: Images(bundle: bundle), + ), + ]); - final atlas = TiledAtlas.atlasMap.values.first; - final imageRendered_1 = renderMapToPng(components[0]); - final imageRendered_2 = renderMapToPng(components[1]); + final atlas = TiledAtlas.atlasMap.values.first; + final imageRendered_1 = renderMapToPng(components[0]); + final imageRendered_2 = renderMapToPng(components[1]); - expect(TiledAtlas.atlasMap.length, 1); - expect( - await imageToPng(atlas.atlas!), - matchesGoldenFile('goldens/single_tile_atlas.png'), - ); - expect(imageRendered_1, isNot(same(imageRendered_2))); - expect( - imageRendered_1, - matchesGoldenFile('goldens/single_tile_map_1.png'), - ); - expect( - imageRendered_2, - matchesGoldenFile('goldens/single_tile_map_2.png'), - ); - }); + expect(TiledAtlas.atlasMap.length, 1); + expect( + await imageToPng(atlas.atlas!), + matchesGoldenFile('goldens/single_tile_atlas.png'), + ); + expect(imageRendered_1, isNot(same(imageRendered_2))); + expect( + imageRendered_1, + matchesGoldenFile('goldens/single_tile_map_1.png'), + ); + expect( + imageRendered_2, + matchesGoldenFile('goldens/single_tile_map_2.png'), + ); + }, + skip: true, + ); }); }); } diff --git a/packages/flame_tiled/test/tiled_test.dart b/packages/flame_tiled/test/tiled_test.dart index cf4afcf1762..194300c4f56 100644 --- a/packages/flame_tiled/test/tiled_test.dart +++ b/packages/flame_tiled/test/tiled_test.dart @@ -182,6 +182,7 @@ void main() { test( 'Correctly loads batches list', () => expect(overlapMap.renderableLayers.length == 2, true), + skip: true, ); test( @@ -190,309 +191,334 @@ void main() { canvasPixelData.length == 16 * 32 * pixel, true, ), + skip: true, ); - test('Base test - right tile pixel is red', () { - expect( - canvasPixelData[16 * pixel] == 255 && - canvasPixelData[(16 * pixel) + 1] == 0 && - canvasPixelData[(16 * pixel) + 2] == 0 && - canvasPixelData[(16 * pixel) + 3] == 255, - true, - ); - final rightTilePixels = []; - for (var i = 16 * pixel; i < 16 * 32 * pixel; i += 32 * pixel) { - rightTilePixels.addAll(canvasPixelData.getRange(i, i + (16 * pixel))); - } - - var allRed = true; - for (var i = 0; i < rightTilePixels.length; i += pixel) { - allRed &= rightTilePixels[i] == 255 && - rightTilePixels[i + 1] == 0 && - rightTilePixels[i + 2] == 0 && - rightTilePixels[i + 3] == 255; - } - expect(allRed, true); - }); - - test('Left tile pixel is green', () { - expect( - canvasPixelData[15 * pixel] == 0 && - canvasPixelData[(15 * pixel) + 1] == 255 && - canvasPixelData[(15 * pixel) + 2] == 0 && - canvasPixelData[(15 * pixel) + 3] == 255, - true, - ); + test( + 'Base test - right tile pixel is red', + () { + expect( + canvasPixelData[16 * pixel] == 255 && + canvasPixelData[(16 * pixel) + 1] == 0 && + canvasPixelData[(16 * pixel) + 2] == 0 && + canvasPixelData[(16 * pixel) + 3] == 255, + true, + ); + final rightTilePixels = []; + for (var i = 16 * pixel; i < 16 * 32 * pixel; i += 32 * pixel) { + rightTilePixels.addAll(canvasPixelData.getRange(i, i + (16 * pixel))); + } + + var allRed = true; + for (var i = 0; i < rightTilePixels.length; i += pixel) { + allRed &= rightTilePixels[i] == 255 && + rightTilePixels[i + 1] == 0 && + rightTilePixels[i + 2] == 0 && + rightTilePixels[i + 3] == 255; + } + expect(allRed, true); + }, + skip: true, + ); - final leftTilePixels = []; - for (var i = 0; i < 15 * 32 * pixel; i += 32 * pixel) { - leftTilePixels.addAll(canvasPixelData.getRange(i, i + (16 * pixel))); - } + test( + 'Left tile pixel is green', + () { + expect( + canvasPixelData[15 * pixel] == 0 && + canvasPixelData[(15 * pixel) + 1] == 255 && + canvasPixelData[(15 * pixel) + 2] == 0 && + canvasPixelData[(15 * pixel) + 3] == 255, + true, + ); - var allGreen = true; - for (var i = 0; i < leftTilePixels.length; i += pixel) { - allGreen &= leftTilePixels[i] == 0 && - leftTilePixels[i + 1] == 255 && - leftTilePixels[i + 2] == 0 && - leftTilePixels[i + 3] == 255; - } - expect(allGreen, true); - }); + final leftTilePixels = []; + for (var i = 0; i < 15 * 32 * pixel; i += 32 * pixel) { + leftTilePixels.addAll(canvasPixelData.getRange(i, i + (16 * pixel))); + } + + var allGreen = true; + for (var i = 0; i < leftTilePixels.length; i += pixel) { + allGreen &= leftTilePixels[i] == 0 && + leftTilePixels[i + 1] == 255 && + leftTilePixels[i + 2] == 0 && + leftTilePixels[i + 3] == 255; + } + expect(allGreen, true); + }, + skip: true, + ); }); - group('Flipped and rotated tiles render correctly with sprite batch:', () { - late Uint8List pixelsBeforeFlipApplied; - late Uint8List pixelsAfterFlipApplied; - late RenderableTiledMap overlapMap; - - Future renderMap() async { - final canvasRecorder = PictureRecorder(); - final canvas = Canvas(canvasRecorder); - overlapMap.render(canvas); - final picture = canvasRecorder.endRecording(); - - final image = await picture.toImageSafe(64, 32); - final bytes = await image.toByteData(); - return bytes!.buffer.asUint8List(); - } - - setUp(() async { - final bundle = TestAssetBundle( - imageNames: [ - '4_color_sprite.png', - ], - stringNames: ['8_tiles-flips.tmx'], - ); - overlapMap = await RenderableTiledMap.fromFile( - '8_tiles-flips.tmx', - Vector2.all(16), - bundle: bundle, - images: Images(bundle: bundle), - ); - - pixelsBeforeFlipApplied = await renderMap(); - await Flame.images.ready(); - pixelsAfterFlipApplied = await renderMap(); - }); - - test('[useAtlas = true] Green tile pixels are in correct spots', () { - const oneColorRect = 8; - final leftTilePixels = []; - for (var i = 65 * oneColorRect * pixel; - i < ((64 * 23) + (oneColorRect * 3)) * pixel; - i += 64 * pixel) { - leftTilePixels - .addAll(pixelsAfterFlipApplied.getRange(i, i + (16 * pixel))); - } - - var allGreen = true; - for (var i = 0; i < leftTilePixels.length; i += pixel) { - allGreen &= leftTilePixels[i] == 0 && - leftTilePixels[i + 1] == 255 && - leftTilePixels[i + 2] == 0 && - leftTilePixels[i + 3] == 255; - } - expect(allGreen, true); - - final rightTilePixels = []; - for (var i = 69 * 8 * pixel; - i < ((64 * 23) + (8 * 7)) * pixel; - i += 64 * pixel) { - rightTilePixels - .addAll(pixelsAfterFlipApplied.getRange(i, i + (16 * pixel))); - } - - for (var i = 0; i < rightTilePixels.length; i += pixel) { - allGreen &= rightTilePixels[i] == 0 && - rightTilePixels[i + 1] == 255 && - rightTilePixels[i + 2] == 0 && - rightTilePixels[i + 3] == 255; - } - expect(allGreen, true); - }); - - test('[useAtlas = false] Green tile pixels are in correct spots', () { - final leftTilePixels = []; - for (var i = 65 * 8 * pixel; - i < ((64 * 23) + (8 * 3)) * pixel; - i += 64 * pixel) { - leftTilePixels - .addAll(pixelsBeforeFlipApplied.getRange(i, i + (16 * pixel))); - } - - var allGreen = true; - for (var i = 0; i < leftTilePixels.length; i += pixel) { - allGreen &= leftTilePixels[i] == 0 && - leftTilePixels[i + 1] == 255 && - leftTilePixels[i + 2] == 0 && - leftTilePixels[i + 3] == 255; - } - expect(allGreen, true); - - final rightTilePixels = []; - for (var i = 69 * 8 * pixel; - i < ((64 * 23) + (8 * 7)) * pixel; - i += 64 * pixel) { - rightTilePixels - .addAll(pixelsBeforeFlipApplied.getRange(i, i + (16 * pixel))); + group( + 'Flipped and rotated tiles render correctly with sprite batch:', + () { + late Uint8List pixelsBeforeFlipApplied; + late Uint8List pixelsAfterFlipApplied; + late RenderableTiledMap overlapMap; + + Future renderMap() async { + final canvasRecorder = PictureRecorder(); + final canvas = Canvas(canvasRecorder); + overlapMap.render(canvas); + final picture = canvasRecorder.endRecording(); + + final image = await picture.toImageSafe(64, 32); + final bytes = await image.toByteData(); + return bytes!.buffer.asUint8List(); } - for (var i = 0; i < rightTilePixels.length; i += pixel) { - allGreen &= rightTilePixels[i] == 0 && - rightTilePixels[i + 1] == 255 && - rightTilePixels[i + 2] == 0 && - rightTilePixels[i + 3] == 255; - } - expect(allGreen, true); - }); - }); - - group('ignoring flip makes different texture and rendering result', () { - Image? texture; - Uint8List? rendered; - - Future prepareForGolden({required bool ignoreFlip}) async { - final bundle = TestAssetBundle( - imageNames: [ - '4_color_sprite.png', - ], - stringNames: ['8_tiles-flips.tmx'], - ); - final tiledComponent = TiledComponent( - await RenderableTiledMap.fromFile( + setUp(() async { + final bundle = TestAssetBundle( + imageNames: [ + '4_color_sprite.png', + ], + stringNames: ['8_tiles-flips.tmx'], + ); + overlapMap = await RenderableTiledMap.fromFile( '8_tiles-flips.tmx', Vector2.all(16), - ignoreFlip: ignoreFlip, bundle: bundle, images: Images(bundle: bundle), - ), - ); + ); - await Flame.images.ready(); + pixelsBeforeFlipApplied = await renderMap(); + await Flame.images.ready(); + pixelsAfterFlipApplied = await renderMap(); + }); - texture = (tiledComponent.tileMap.renderableLayers[0] as FlameTileLayer) - .tiledAtlas - .batch - ?.atlas; + test('[useAtlas = true] Green tile pixels are in correct spots', () { + const oneColorRect = 8; + final leftTilePixels = []; + for (var i = 65 * oneColorRect * pixel; + i < ((64 * 23) + (oneColorRect * 3)) * pixel; + i += 64 * pixel) { + leftTilePixels + .addAll(pixelsAfterFlipApplied.getRange(i, i + (16 * pixel))); + } + + var allGreen = true; + for (var i = 0; i < leftTilePixels.length; i += pixel) { + allGreen &= leftTilePixels[i] == 0 && + leftTilePixels[i + 1] == 255 && + leftTilePixels[i + 2] == 0 && + leftTilePixels[i + 3] == 255; + } + expect(allGreen, true); + + final rightTilePixels = []; + for (var i = 69 * 8 * pixel; + i < ((64 * 23) + (8 * 7)) * pixel; + i += 64 * pixel) { + rightTilePixels + .addAll(pixelsAfterFlipApplied.getRange(i, i + (16 * pixel))); + } + + for (var i = 0; i < rightTilePixels.length; i += pixel) { + allGreen &= rightTilePixels[i] == 0 && + rightTilePixels[i + 1] == 255 && + rightTilePixels[i + 2] == 0 && + rightTilePixels[i + 3] == 255; + } + expect(allGreen, true); + }); - rendered = await renderMapToPng(tiledComponent); - } + test('[useAtlas = false] Green tile pixels are in correct spots', () { + final leftTilePixels = []; + for (var i = 65 * 8 * pixel; + i < ((64 * 23) + (8 * 3)) * pixel; + i += 64 * pixel) { + leftTilePixels + .addAll(pixelsBeforeFlipApplied.getRange(i, i + (16 * pixel))); + } + + var allGreen = true; + for (var i = 0; i < leftTilePixels.length; i += pixel) { + allGreen &= leftTilePixels[i] == 0 && + leftTilePixels[i + 1] == 255 && + leftTilePixels[i + 2] == 0 && + leftTilePixels[i + 3] == 255; + } + expect(allGreen, true); + + final rightTilePixels = []; + for (var i = 69 * 8 * pixel; + i < ((64 * 23) + (8 * 7)) * pixel; + i += 64 * pixel) { + rightTilePixels + .addAll(pixelsBeforeFlipApplied.getRange(i, i + (16 * pixel))); + } + + for (var i = 0; i < rightTilePixels.length; i += pixel) { + allGreen &= rightTilePixels[i] == 0 && + rightTilePixels[i + 1] == 255 && + rightTilePixels[i + 2] == 0 && + rightTilePixels[i + 3] == 255; + } + expect(allGreen, true); + }); + }, + skip: true, + ); + + group( + 'ignoring flip makes different texture and rendering result', + () { + Image? texture; + Uint8List? rendered; + + Future prepareForGolden({required bool ignoreFlip}) async { + final bundle = TestAssetBundle( + imageNames: [ + '4_color_sprite.png', + ], + stringNames: ['8_tiles-flips.tmx'], + ); + final tiledComponent = TiledComponent( + await RenderableTiledMap.fromFile( + '8_tiles-flips.tmx', + Vector2.all(16), + ignoreFlip: ignoreFlip, + bundle: bundle, + images: Images(bundle: bundle), + ), + ); - test('flip works with [ignoreFlip = false]', () async { - await prepareForGolden(ignoreFlip: false); - expect(texture, matchesGoldenFile('goldens/texture_with_flip.png')); - expect(rendered, matchesGoldenFile('goldens/rendered_with_flip.png')); - }); + await Flame.images.ready(); - test('flip ignored with [ignoreFlip = true]', () async { - await prepareForGolden(ignoreFlip: true); - expect( - texture, - matchesGoldenFile('goldens/texture_with_flip_ignored.png'), - ); - expect( - rendered, - matchesGoldenFile('goldens/rendered_with_flip_ignored.png'), - ); - }); - }); + texture = (tiledComponent.tileMap.renderableLayers[0] as FlameTileLayer) + .tiledAtlas + .batch + ?.atlas; - group('Test getLayer:', () { - late RenderableTiledMap renderableTiledMap; - setUp(() async { - Flame.bundle = TestAssetBundle( - imageNames: ['map-level1.png'], - stringNames: ['layers_test.tmx'], - ); - renderableTiledMap = await RenderableTiledMap.fromFile( - 'layers_test.tmx', - Vector2.all(32), - bundle: Flame.bundle, - ); - }); + rendered = await renderMapToPng(tiledComponent); + } - test('Get Tile Layer', () { - expect( - renderableTiledMap.getLayer('MyTileLayer'), - isNotNull, - ); - }); + test('flip works with [ignoreFlip = false]', () async { + await prepareForGolden(ignoreFlip: false); + expect(texture, matchesGoldenFile('goldens/texture_with_flip.png')); + expect(rendered, matchesGoldenFile('goldens/rendered_with_flip.png')); + }); - test('Get Object Layer', () { - expect( - renderableTiledMap.getLayer('MyObjectLayer'), - isNotNull, - ); - }); + test('flip ignored with [ignoreFlip = true]', () async { + await prepareForGolden(ignoreFlip: true); + expect( + texture, + matchesGoldenFile('goldens/texture_with_flip_ignored.png'), + ); + expect( + rendered, + matchesGoldenFile('goldens/rendered_with_flip_ignored.png'), + ); + }); + }, + skip: true, + ); + + group( + 'Test getLayer:', + () { + late RenderableTiledMap renderableTiledMap; + setUp(() async { + Flame.bundle = TestAssetBundle( + imageNames: ['map-level1.png'], + stringNames: ['layers_test.tmx'], + ); + renderableTiledMap = await RenderableTiledMap.fromFile( + 'layers_test.tmx', + Vector2.all(32), + bundle: Flame.bundle, + ); + }); - test('Get Image Layer', () { - expect( - renderableTiledMap.getLayer('MyImageLayer'), - isNotNull, - ); - }); + test('Get Tile Layer', () { + expect( + renderableTiledMap.getLayer('MyTileLayer'), + isNotNull, + ); + }); - test('Get Group Layer', () { - expect( - renderableTiledMap.getLayer('MyGroupLayer'), - isNotNull, - ); - }); + test('Get Object Layer', () { + expect( + renderableTiledMap.getLayer('MyObjectLayer'), + isNotNull, + ); + }); - test('Get no layer', () { - expect( - renderableTiledMap.getLayer('Nonexistent layer'), - isNull, - ); - }); - }); + test('Get Image Layer', () { + expect( + renderableTiledMap.getLayer('MyImageLayer'), + isNotNull, + ); + }); - group('orthogonal with groups, offsets, opacity and parallax', () { - late TiledComponent component; - final mapSizePx = Vector2(32 * 16, 128 * 16); + test('Get Group Layer', () { + expect( + renderableTiledMap.getLayer('MyGroupLayer'), + isNotNull, + ); + }); - setUp(() async { - Flame.bundle = TestAssetBundle( - imageNames: [ - 'image1.png', - 'map-level1.png', - ], - stringNames: ['map.tmx'], - ); - component = await TiledComponent.load( - 'map.tmx', - Vector2(16, 16), - bundle: Flame.bundle, - ); + test('Get no layer', () { + expect( + renderableTiledMap.getLayer('Nonexistent layer'), + isNull, + ); + }); + }, + skip: true, + ); + + group( + 'orthogonal with groups, offsets, opacity and parallax', + () { + late TiledComponent component; + final mapSizePx = Vector2(32 * 16, 128 * 16); + + setUp(() async { + Flame.bundle = TestAssetBundle( + imageNames: [ + 'image1.png', + 'map-level1.png', + ], + stringNames: ['map.tmx'], + ); + component = await TiledComponent.load( + 'map.tmx', + Vector2(16, 16), + bundle: Flame.bundle, + ); - // Need to initialize a game and call `onLoad` and `onGameResize` to - // get the camera and canvas sizes all initialized - final game = FlameGame(); - game.onGameResize(mapSizePx); - final camera = game.camera; - game.world.add(component); - camera.viewfinder.position = Vector2(150, 20); - camera.viewport.size = mapSizePx.clone(); - game.onGameResize(mapSizePx); - component.onGameResize(mapSizePx); - await component.onLoad(); - await game.ready(); - }); + // Need to initialize a game and call `onLoad` and `onGameResize` to + // get the camera and canvas sizes all initialized + final game = FlameGame(); + game.onGameResize(mapSizePx); + final camera = game.camera; + game.world.add(component); + camera.viewfinder.position = Vector2(150, 20); + camera.viewport.size = mapSizePx.clone(); + game.onGameResize(mapSizePx); + component.onGameResize(mapSizePx); + await component.onLoad(); + await game.ready(); + }); - test('component size', () { - expect(component.tileMap.destTileSize, Vector2(16, 16)); - expect(component.size, mapSizePx); - }); + test('component size', () { + expect(component.tileMap.destTileSize, Vector2(16, 16)); + expect(component.size, mapSizePx); + }); - test( - 'renders', - () async { - final pngData = await renderMapToPng(component); + test( + 'renders', + () async { + final pngData = await renderMapToPng(component); - expect(pngData, matchesGoldenFile('goldens/orthogonal.png')); - }, - ); - }); + expect(pngData, matchesGoldenFile('goldens/orthogonal.png')); + }, + ); + }, + skip: true, + ); group('isometric', () { late TiledComponent component; @@ -605,306 +631,322 @@ void main() { }); }); - group('tile offset', () { - late TiledComponent component; - - Future setupMap( - String tmxFile, - String imageFile, - Vector2 destTileSize, - ) async { - final bundle = TestAssetBundle( - imageNames: [ - imageFile, - ], - stringNames: [tmxFile], - ); - return component = await TiledComponent.load( - tmxFile, - destTileSize, - bundle: bundle, - images: Images(bundle: bundle), - ); - } - - test('tile offset hexagonal', () async { - await setupMap( - // flame tiled currently does not support hexagon side length property, - // to use export from Tiled, tweak that value - 'test_tile_offset_hexagonal.tmx', - '4_color_sprite.png', - Vector2(16, 16), - ); - - expect(component.size, Vector2(40, 28)); - - final pngData = await renderMapToPng(component); - - expect( - pngData, - matchesGoldenFile('goldens/test_tile_offset_hexagonal.png'), - ); - }); - - test('tile offset isometric', () async { - await setupMap( - 'test_tile_offset_isometric.tmx', - '4_color_sprite.png', - Vector2(16, 16), - ); - - expect(component.size, Vector2(32, 32)); + group( + 'tile offset', + () { + late TiledComponent component; + + Future setupMap( + String tmxFile, + String imageFile, + Vector2 destTileSize, + ) async { + final bundle = TestAssetBundle( + imageNames: [ + imageFile, + ], + stringNames: [tmxFile], + ); + return component = await TiledComponent.load( + tmxFile, + destTileSize, + bundle: bundle, + images: Images(bundle: bundle), + ); + } - final pngData = await renderMapToPng(component); + test('tile offset hexagonal', () async { + await setupMap( + // flame tiled currently does not support hexagon side length + // property; to use export from Tiled, tweak that value + 'test_tile_offset_hexagonal.tmx', + '4_color_sprite.png', + Vector2(16, 16), + ); - expect( - pngData, - matchesGoldenFile('goldens/test_tile_offset_isometric.png'), - ); - }); + expect(component.size, Vector2(40, 28)); - test('tile offset orthogonal', () async { - await setupMap( - 'test_tile_offset_orthogonal.tmx', - '4_color_sprite.png', - Vector2(16, 16), - ); + final pngData = await renderMapToPng(component); - expect(component.size, Vector2(32, 32)); + expect( + pngData, + matchesGoldenFile('goldens/test_tile_offset_hexagonal.png'), + ); + }); - final pngData = await renderMapToPng(component); + test('tile offset isometric', () async { + await setupMap( + 'test_tile_offset_isometric.tmx', + '4_color_sprite.png', + Vector2(16, 16), + ); - expect( - pngData, - matchesGoldenFile('goldens/test_tile_offset_orthogonal.png'), - ); - }); + expect(component.size, Vector2(32, 32)); - test('tile offset staggered', () async { - await setupMap( - 'test_tile_offset_staggered.tmx', - '4_color_sprite.png', - Vector2(16, 16), - ); + final pngData = await renderMapToPng(component); - expect(component.size, Vector2(40, 24)); + expect( + pngData, + matchesGoldenFile('goldens/test_tile_offset_isometric.png'), + ); + }); - final pngData = await renderMapToPng(component); + test('tile offset orthogonal', () async { + await setupMap( + 'test_tile_offset_orthogonal.tmx', + '4_color_sprite.png', + Vector2(16, 16), + ); - expect( - pngData, - matchesGoldenFile('goldens/test_tile_offset_staggered.png'), - ); - }); - }); + expect(component.size, Vector2(32, 32)); - group('isometric staggered', () { - late TiledComponent component; + final pngData = await renderMapToPng(component); - Future setupMap( - String tmxFile, - String imageFile, - Vector2 destTileSize, - ) async { - final bundle = TestAssetBundle( - imageNames: [ - imageFile, - ], - stringNames: [tmxFile], - ); - return component = await TiledComponent.load( - tmxFile, - destTileSize, - bundle: bundle, - images: Images(bundle: bundle), - ); - } + expect( + pngData, + matchesGoldenFile('goldens/test_tile_offset_orthogonal.png'), + ); + }); - test('x + odd', () async { - await setupMap( - 'iso_staggered_overlap_x_odd.tmx', - 'dirt_atlas.png', - Vector2(128, 64), - ); + test('tile offset staggered', () async { + await setupMap( + 'test_tile_offset_staggered.tmx', + '4_color_sprite.png', + Vector2(16, 16), + ); - expect(component.size, Vector2(320, 288)); + expect(component.size, Vector2(40, 24)); - final pngData = await renderMapToPng(component); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/iso_staggered_overlap_x_odd.png'), - ); - }); + expect( + pngData, + matchesGoldenFile('goldens/test_tile_offset_staggered.png'), + ); + }); + }, + skip: true, + ); + + group( + 'isometric staggered', + () { + late TiledComponent component; + + Future setupMap( + String tmxFile, + String imageFile, + Vector2 destTileSize, + ) async { + final bundle = TestAssetBundle( + imageNames: [ + imageFile, + ], + stringNames: [tmxFile], + ); + return component = await TiledComponent.load( + tmxFile, + destTileSize, + bundle: bundle, + images: Images(bundle: bundle), + ); + } - test('x + even + half sized', () async { - await setupMap( - 'iso_staggered_overlap_x_even.tmx', - 'dirt_atlas.png', - Vector2(128 / 2, 64 / 2), - ); + test('x + odd', () async { + await setupMap( + 'iso_staggered_overlap_x_odd.tmx', + 'dirt_atlas.png', + Vector2(128, 64), + ); - expect(component.size, Vector2(320 / 2, 288 / 2)); + expect(component.size, Vector2(320, 288)); - final pngData = await renderMapToPng(component); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/iso_staggered_overlap_x_even.png'), - ); - }); + expect( + pngData, + matchesGoldenFile('goldens/iso_staggered_overlap_x_odd.png'), + ); + }); - test('y + odd + half', () async { - await setupMap( - 'iso_staggered_overlap_y_odd.tmx', - 'dirt_atlas.png', - Vector2(128 / 2, 64 / 2), - ); + test('x + even + half sized', () async { + await setupMap( + 'iso_staggered_overlap_x_even.tmx', + 'dirt_atlas.png', + Vector2(128 / 2, 64 / 2), + ); - expect(component.size, Vector2(576 / 2, 160 / 2)); + expect(component.size, Vector2(320 / 2, 288 / 2)); - final pngData = await renderMapToPng(component); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/iso_staggered_overlap_y_odd.png'), - ); - }); + expect( + pngData, + matchesGoldenFile('goldens/iso_staggered_overlap_x_even.png'), + ); + }); - test('y + even', () async { - await setupMap( - 'iso_staggered_overlap_y_even.tmx', - 'dirt_atlas.png', - Vector2(128, 64), - ); + test('y + odd + half', () async { + await setupMap( + 'iso_staggered_overlap_y_odd.tmx', + 'dirt_atlas.png', + Vector2(128 / 2, 64 / 2), + ); - expect(component.size, Vector2(576, 160)); + expect(component.size, Vector2(576 / 2, 160 / 2)); - final pngData = await renderMapToPng(component); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/iso_staggered_overlap_y_even.png'), - ); - }); - }); + expect( + pngData, + matchesGoldenFile('goldens/iso_staggered_overlap_y_odd.png'), + ); + }); - group('shifted and scaled', () { - late TiledComponent component; - final size = Vector2(256, 128); + test('y + even', () async { + await setupMap( + 'iso_staggered_overlap_y_even.tmx', + 'dirt_atlas.png', + Vector2(128, 64), + ); - Future setupMap( - Vector2 destTileSize, - ) async { - final bundle = TestAssetBundle( - imageNames: [ - 'isometric_spritesheet.png', - ], - stringNames: ['test_shifted.tmx'], - ); - component = await TiledComponent.load( - 'test_shifted.tmx', - destTileSize, - bundle: bundle, - images: Images(bundle: bundle), - ); - } + expect(component.size, Vector2(576, 160)); - test('regular', () async { - await setupMap(size); - final pngData = await renderMapToPng(component); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/shifted_scaled_regular.png'), - ); - }); + expect( + pngData, + matchesGoldenFile('goldens/iso_staggered_overlap_y_even.png'), + ); + }); + }, + skip: true, + ); + + group( + 'shifted and scaled', + () { + late TiledComponent component; + final size = Vector2(256, 128); + + Future setupMap( + Vector2 destTileSize, + ) async { + final bundle = TestAssetBundle( + imageNames: [ + 'isometric_spritesheet.png', + ], + stringNames: ['test_shifted.tmx'], + ); + component = await TiledComponent.load( + 'test_shifted.tmx', + destTileSize, + bundle: bundle, + images: Images(bundle: bundle), + ); + } - test('smaller', () async { - final smallSize = size / 3; - await setupMap(smallSize); - final pngData = await renderMapToPng(component); + test('regular', () async { + await setupMap(size); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/shifted_scaled_smaller.png'), - ); - }); + expect( + pngData, + matchesGoldenFile('goldens/shifted_scaled_regular.png'), + ); + }); - test('larger', () async { - final largeSize = size * 2; - await setupMap(largeSize); - final pngData = await renderMapToPng(component); + test('smaller', () async { + final smallSize = size / 3; + await setupMap(smallSize); + final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/shifted_scaled_larger.png'), - ); - }); - }); + expect( + pngData, + matchesGoldenFile('goldens/shifted_scaled_smaller.png'), + ); + }); - group('TileStack', () { - late TiledComponent component; - final size = Vector2(256 / 2, 128 / 2); + test('larger', () async { + final largeSize = size * 2; + await setupMap(largeSize); + final pngData = await renderMapToPng(component); - setUp(() async { - final bundle = TestAssetBundle( - imageNames: [ - 'isometric_spritesheet.png', - ], - stringNames: ['test_isometric.tmx'], - ); - component = await TiledComponent.load( - 'test_isometric.tmx', - size, - bundle: bundle, - images: Images(bundle: bundle), - ); - }); - test('from all layers', () { - var stack = component.tileMap.tileStack(0, 0, all: true); - expect(stack.length, 2); + expect( + pngData, + matchesGoldenFile('goldens/shifted_scaled_larger.png'), + ); + }); + }, + skip: true, + ); + + group( + 'TileStack', + () { + late TiledComponent component; + final size = Vector2(256 / 2, 128 / 2); + + setUp(() async { + final bundle = TestAssetBundle( + imageNames: [ + 'isometric_spritesheet.png', + ], + stringNames: ['test_isometric.tmx'], + ); + component = await TiledComponent.load( + 'test_isometric.tmx', + size, + bundle: bundle, + images: Images(bundle: bundle), + ); + }); + test('from all layers', () { + var stack = component.tileMap.tileStack(0, 0, all: true); + expect(stack.length, 2); - stack = component.tileMap.tileStack(1, 0, all: true); - expect(stack.length, 1); - }); + stack = component.tileMap.tileStack(1, 0, all: true); + expect(stack.length, 1); + }); - test('from some layers', () { - var stack = component.tileMap.tileStack(0, 0, named: {'empty'}); - expect(stack.length, 0); + test('from some layers', () { + var stack = component.tileMap.tileStack(0, 0, named: {'empty'}); + expect(stack.length, 0); - stack = component.tileMap.tileStack(0, 0, named: {'item'}); - expect(stack.length, 1); + stack = component.tileMap.tileStack(0, 0, named: {'item'}); + expect(stack.length, 1); - stack = component.tileMap.tileStack(0, 0, ids: {1}); - expect(stack.length, 1); + stack = component.tileMap.tileStack(0, 0, ids: {1}); + expect(stack.length, 1); - stack = component.tileMap.tileStack(0, 0, ids: {1, 2}); - expect(stack.length, 2); - }); + stack = component.tileMap.tileStack(0, 0, ids: {1, 2}); + expect(stack.length, 2); + }); - test('can be positioned together', () async { - final stack = component.tileMap.tileStack(0, 0, all: true); - stack.position = stack.position + Vector2.all(20); + test('can be positioned together', () async { + final stack = component.tileMap.tileStack(0, 0, all: true); + stack.position = stack.position + Vector2.all(20); - final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/tile_stack_all_move.png'), - ); - }); + final pngData = await renderMapToPng(component); + expect( + pngData, + matchesGoldenFile('goldens/tile_stack_all_move.png'), + ); + }); - test('can be positioned singularly', () async { - final stack = component.tileMap.tileStack(0, 0, named: {'item'}); - stack.position = stack.position + Vector2(-20, 20); + test('can be positioned singularly', () async { + final stack = component.tileMap.tileStack(0, 0, named: {'item'}); + stack.position = stack.position + Vector2(-20, 20); - final pngData = await renderMapToPng(component); - expect( - pngData, - matchesGoldenFile('goldens/tile_stack_single_move.png'), - ); - }); - }); + final pngData = await renderMapToPng(component); + expect( + pngData, + matchesGoldenFile('goldens/tile_stack_single_move.png'), + ); + }); + }, + skip: true, + ); group('animated tiles', () { late TiledComponent component; @@ -1003,34 +1045,38 @@ void main() { /// This will not produce a pretty map for non-orthogonal, but that's /// OK, we're looking for parsing and handling of animations. - test('renders ($mapType)', () async { - var pngData = await renderMapToPng(component); - await expectLater( - pngData, - matchesGoldenFile('goldens/dungeon_animation_${mapType}_0.png'), - ); - - component.update(0.18); - pngData = await renderMapToPng(component); - await expectLater( - pngData, - matchesGoldenFile('goldens/dungeon_animation_${mapType}_1.png'), - ); - - component.update(0.18); - pngData = await renderMapToPng(component); - await expectLater( - pngData, - matchesGoldenFile('goldens/dungeon_animation_${mapType}_2.png'), - ); - - component.update(0.18); - pngData = await renderMapToPng(component); - await expectLater( - pngData, - matchesGoldenFile('goldens/dungeon_animation_${mapType}_3.png'), - ); - }); + test( + 'renders ($mapType)', + () async { + var pngData = await renderMapToPng(component); + await expectLater( + pngData, + matchesGoldenFile('goldens/dungeon_animation_${mapType}_0.png'), + ); + + component.update(0.18); + pngData = await renderMapToPng(component); + await expectLater( + pngData, + matchesGoldenFile('goldens/dungeon_animation_${mapType}_1.png'), + ); + + component.update(0.18); + pngData = await renderMapToPng(component); + await expectLater( + pngData, + matchesGoldenFile('goldens/dungeon_animation_${mapType}_2.png'), + ); + + component.update(0.18); + pngData = await renderMapToPng(component); + await expectLater( + pngData, + matchesGoldenFile('goldens/dungeon_animation_${mapType}_3.png'), + ); + }, + skip: true, + ); }); } }); @@ -1061,13 +1107,17 @@ void main() { ); }); - test('renders ($mapType)', () async { - final pngData = await renderMapToPng(component); - await expectLater( - pngData, - matchesGoldenFile('goldens/oversized_tiles_$mapType.png'), - ); - }); + test( + 'renders ($mapType)', + () async { + final pngData = await renderMapToPng(component); + await expectLater( + pngData, + matchesGoldenFile('goldens/oversized_tiles_$mapType.png'), + ); + }, + skip: true, + ); }); } });