Skip to content

Commit

Permalink
retry volatile properties test
Browse files Browse the repository at this point in the history
  • Loading branch information
maios committed Jun 28, 2024
1 parent c3aedb1 commit 4119cb4
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 153 deletions.
54 changes: 22 additions & 32 deletions example/integration_test/style/source/geojson_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mapbox_maps_example/empty_map_widget.dart' as app;
import '../../utils/retry.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -54,31 +55,24 @@ void main() {

var source = await mapboxMap.style.getSource('source') as GeoJsonSource;
expect(source.id, 'source');
var maxzoom = await source.maxzoom;
expect(maxzoom, 1.0);

var attribution = await source.attribution;
final maxzoom = await source.maxzoom;
expect(maxzoom, 1.0);
final attribution = await source.attribution;
expect(attribution, "abc");

var buffer = await source.buffer;
final buffer = await source.buffer;
expect(buffer, 1.0);

var tolerance = await source.tolerance;
final tolerance = await source.tolerance;
expect(tolerance, 1.0);

var cluster = await source.cluster;
final cluster = await source.cluster;
expect(cluster, true);

var clusterRadius = await source.clusterRadius;
final clusterRadius = await source.clusterRadius;
expect(clusterRadius, 1.0);

var clusterMaxZoom = await source.clusterMaxZoom;
final clusterMaxZoom = await source.clusterMaxZoom;
expect(clusterMaxZoom, 1.0);

var clusterMinPoints = await source.clusterMinPoints;
final clusterMinPoints = await source.clusterMinPoints;
expect(clusterMinPoints, 1.0);

var clusterProperties = await source.clusterProperties;
final clusterProperties = await source.clusterProperties;
expect(clusterProperties, {
"sum": [
[
Expand All @@ -95,23 +89,19 @@ void main() {
1.0
]
});

var lineMetrics = await source.lineMetrics;
final lineMetrics = await source.lineMetrics;
expect(lineMetrics, true);

var generateId = await source.generateId;
final generateId = await source.generateId;
expect(generateId, true);

await Future.delayed(const Duration(seconds: 1), (){});
// https://mapbox.atlassian.net/browse/MAPSFLT-141
var prefetchZoomDelta = await source.prefetchZoomDelta;
expect(prefetchZoomDelta, 1.0);

var tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget?.size,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).size);
expect(tileCacheBudget?.type,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).type);
await retry(2, () async {
await expectLater(source.prefetchZoomDelta, completion(1.0));
});
await retry(2, () async {
await expectLater(
source.tileCacheBudget,
completion(TileCacheBudget.inMegabytes(
TileCacheBudgetInMegabytes(size: 3))));
});
});
}
// End of generated file.
7 changes: 4 additions & 3 deletions example/integration_test/style/source/image_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mapbox_maps_example/empty_map_widget.dart' as app;
import '../../utils/retry.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -31,15 +32,15 @@ void main() {

var source = await mapboxMap.style.getSource('source') as ImageSource;
expect(source.id, 'source');
var coordinates = await source.coordinates;

final coordinates = await source.coordinates;
expect(coordinates, [
[0.0, 1.0],
[0.0, 1.0],
[0.0, 1.0],
[0.0, 1.0]
]);

var prefetchZoomDelta = await source.prefetchZoomDelta;
final prefetchZoomDelta = await source.prefetchZoomDelta;
expect(prefetchZoomDelta, 1.0);
});
}
Expand Down
49 changes: 18 additions & 31 deletions example/integration_test/style/source/raster_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mapbox_maps_example/empty_map_widget.dart' as app;
import '../../utils/retry.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -39,50 +40,36 @@ void main() {

var source = await mapboxMap.style.getSource('source') as RasterSource;
expect(source.id, 'source');
var tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);

var bounds = await source.bounds;
final tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);
final bounds = await source.bounds;
expect(bounds, [0.0, 1.0, 2.0, 3.0]);

var minzoom = await source.minzoom;
final minzoom = await source.minzoom;
expect(minzoom, 1.0);

var maxzoom = await source.maxzoom;
final maxzoom = await source.maxzoom;
expect(maxzoom, 1.0);

var tileSize = await source.tileSize;
final tileSize = await source.tileSize;
expect(tileSize, 1.0);

var scheme = await source.scheme;
final scheme = await source.scheme;
expect(scheme, Scheme.XYZ);

var attribution = await source.attribution;
final attribution = await source.attribution;
expect(attribution, "abc");

var volatile = await source.volatile;
final volatile = await source.volatile;
expect(volatile, true);

var prefetchZoomDelta = await source.prefetchZoomDelta;
final prefetchZoomDelta = await source.prefetchZoomDelta;
expect(prefetchZoomDelta, 1.0);

var tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget?.size,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).size);
expect(tileCacheBudget?.type,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).type);

var minimumTileUpdateInterval = await source.minimumTileUpdateInterval;
final tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)));
final minimumTileUpdateInterval = await source.minimumTileUpdateInterval;
expect(minimumTileUpdateInterval, 1.0);

var maxOverscaleFactorForParentTiles =
final maxOverscaleFactorForParentTiles =
await source.maxOverscaleFactorForParentTiles;
expect(maxOverscaleFactorForParentTiles, 1.0);

var tileRequestsDelay = await source.tileRequestsDelay;
final tileRequestsDelay = await source.tileRequestsDelay;
expect(tileRequestsDelay, 1.0);

var tileNetworkRequestsDelay = await source.tileNetworkRequestsDelay;
final tileNetworkRequestsDelay = await source.tileNetworkRequestsDelay;
expect(tileNetworkRequestsDelay, 1.0);
});
}
Expand Down
28 changes: 11 additions & 17 deletions example/integration_test/style/source/rasterarray_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mapbox_maps_example/empty_map_widget.dart' as app;
import '../../utils/retry.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -32,29 +33,22 @@ void main() {

var source = await mapboxMap.style.getSource('source') as RasterArraySource;
expect(source.id, 'source');
var tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);

var bounds = await source.bounds;
final tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);
final bounds = await source.bounds;
expect(bounds, [0.0, 1.0, 2.0, 3.0]);

var minzoom = await source.minzoom;
final minzoom = await source.minzoom;
expect(minzoom, 1.0);

var maxzoom = await source.maxzoom;
final maxzoom = await source.maxzoom;
expect(maxzoom, 1.0);

var tileSize = await source.tileSize;
final tileSize = await source.tileSize;
expect(tileSize, 1.0);

var attribution = await source.attribution;
final attribution = await source.attribution;
expect(attribution, "abc");

var tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget?.size,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).size);
expect(tileCacheBudget?.type,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).type);
final tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)));
});
}
// End of generated file.
49 changes: 18 additions & 31 deletions example/integration_test/style/source/rasterdem_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mapbox_maps_example/empty_map_widget.dart' as app;
import '../../utils/retry.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -39,50 +40,36 @@ void main() {

var source = await mapboxMap.style.getSource('source') as RasterDemSource;
expect(source.id, 'source');
var tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);

var bounds = await source.bounds;
final tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);
final bounds = await source.bounds;
expect(bounds, [0.0, 1.0, 2.0, 3.0]);

var minzoom = await source.minzoom;
final minzoom = await source.minzoom;
expect(minzoom, 1.0);

var maxzoom = await source.maxzoom;
final maxzoom = await source.maxzoom;
expect(maxzoom, 1.0);

var tileSize = await source.tileSize;
final tileSize = await source.tileSize;
expect(tileSize, 1.0);

var attribution = await source.attribution;
final attribution = await source.attribution;
expect(attribution, "abc");

var encoding = await source.encoding;
final encoding = await source.encoding;
expect(encoding, Encoding.TERRARIUM);

var volatile = await source.volatile;
final volatile = await source.volatile;
expect(volatile, true);

var prefetchZoomDelta = await source.prefetchZoomDelta;
final prefetchZoomDelta = await source.prefetchZoomDelta;
expect(prefetchZoomDelta, 1.0);

var tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget?.size,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).size);
expect(tileCacheBudget?.type,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).type);

var minimumTileUpdateInterval = await source.minimumTileUpdateInterval;
final tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)));
final minimumTileUpdateInterval = await source.minimumTileUpdateInterval;
expect(minimumTileUpdateInterval, 1.0);

var maxOverscaleFactorForParentTiles =
final maxOverscaleFactorForParentTiles =
await source.maxOverscaleFactorForParentTiles;
expect(maxOverscaleFactorForParentTiles, 1.0);

var tileRequestsDelay = await source.tileRequestsDelay;
final tileRequestsDelay = await source.tileRequestsDelay;
expect(tileRequestsDelay, 1.0);

var tileNetworkRequestsDelay = await source.tileNetworkRequestsDelay;
final tileNetworkRequestsDelay = await source.tileNetworkRequestsDelay;
expect(tileNetworkRequestsDelay, 1.0);
});
}
Expand Down
46 changes: 17 additions & 29 deletions example/integration_test/style/source/vector_source_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mapbox_maps_flutter/mapbox_maps_flutter.dart';
import 'package:mapbox_maps_example/empty_map_widget.dart' as app;
import '../../utils/retry.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -38,47 +39,34 @@ void main() {

var source = await mapboxMap.style.getSource('source') as VectorSource;
expect(source.id, 'source');
var tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);

var bounds = await source.bounds;
final tiles = await source.tiles;
expect(tiles, ["a", "b", "c"]);
final bounds = await source.bounds;
expect(bounds, [0.0, 1.0, 2.0, 3.0]);

var scheme = await source.scheme;
final scheme = await source.scheme;
expect(scheme, Scheme.XYZ);

var minzoom = await source.minzoom;
final minzoom = await source.minzoom;
expect(minzoom, 1.0);

var maxzoom = await source.maxzoom;
final maxzoom = await source.maxzoom;
expect(maxzoom, 1.0);

var attribution = await source.attribution;
final attribution = await source.attribution;
expect(attribution, "abc");

var volatile = await source.volatile;
final volatile = await source.volatile;
expect(volatile, true);

var prefetchZoomDelta = await source.prefetchZoomDelta;
final prefetchZoomDelta = await source.prefetchZoomDelta;
expect(prefetchZoomDelta, 1.0);

var tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget?.size,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).size);
expect(tileCacheBudget?.type,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)).type);

var minimumTileUpdateInterval = await source.minimumTileUpdateInterval;
final tileCacheBudget = await source.tileCacheBudget;
expect(tileCacheBudget,
TileCacheBudget.inMegabytes(TileCacheBudgetInMegabytes(size: 3)));
final minimumTileUpdateInterval = await source.minimumTileUpdateInterval;
expect(minimumTileUpdateInterval, 1.0);

var maxOverscaleFactorForParentTiles =
final maxOverscaleFactorForParentTiles =
await source.maxOverscaleFactorForParentTiles;
expect(maxOverscaleFactorForParentTiles, 1.0);

var tileRequestsDelay = await source.tileRequestsDelay;
final tileRequestsDelay = await source.tileRequestsDelay;
expect(tileRequestsDelay, 1.0);

var tileNetworkRequestsDelay = await source.tileNetworkRequestsDelay;
final tileNetworkRequestsDelay = await source.tileNetworkRequestsDelay;
expect(tileNetworkRequestsDelay, 1.0);
});
}
Expand Down
15 changes: 15 additions & 0 deletions example/integration_test/utils/retry.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Future<T> retry<T>(int retries, Future<T> Function() function,
{Duration? delay = const Duration(milliseconds: 500)}) async {
try {
return await function();
} catch (e) {
if (retries > 1) {
print("MMM retry");
if (delay != null) {
await Future.delayed(delay);
}
return retry(retries - 1, function);
}
rethrow;
}
}
Loading

0 comments on commit 4119cb4

Please sign in to comment.