@@ -138,6 +138,37 @@ void main() {
138138 }
139139 });
140140
141+ group ('renderTiles' , () {
142+ test ('%.retainChildren uses correct coordinates for z+2 fallback' , () {
143+ // This test verifies that _retainChildren correctly calculates
144+ // descendant coordinates when recursing to z+2 level.
145+ // Using large coordinates (100, 200) to catch the bug where
146+ // i,j (0-1) was passed instead of 2*x+i, 2*y+j.
147+ const baseZoom = 10 ;
148+ final tileImages = tileImagesMappingFrom ([
149+ // z=10 tile not ready
150+ MockTileImage (100 , 200 , baseZoom,
151+ loadFinished: false , readyToDisplay: false ),
152+ // z=11 tiles don't exist
153+ // z=12 tile exists and is ready (this is what we want to fall back to)
154+ MockTileImage (400 , 800 , baseZoom + 2 ),
155+ ]);
156+
157+ final tileImageView = TileImageView (
158+ tileImages: tileImages,
159+ positionCoordinates: Set <TileCoordinates >.from (tileImages.keys),
160+ visibleRange: discreteTileRange (100 , 200 , 100 , 200 , zoom: baseZoom),
161+ keepRange: discreteTileRange (100 , 200 , 100 , 200 , zoom: baseZoom),
162+ );
163+
164+ final renderTiles = tileImageView.renderTiles.toList ();
165+ expect (
166+ renderTiles,
167+ contains (const TileCoordinates (400 , 800 , baseZoom + 2 )),
168+ );
169+ });
170+ });
171+
141172 test ('errorTilesNotVisible' , () {
142173 const zoom = 10 ;
143174 final tileImages = tileImagesMappingFrom ([
0 commit comments