-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
166 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'package:flutter_map_mbtiles/flutter_map_mbtiles.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
|
||
@GenerateNiceMocks([MockSpec<MBTiles>()]) | ||
import 'integration_test.mocks.dart'; | ||
import 'utils/test_app.dart'; | ||
|
||
Future<void> main() async { | ||
testWidgets('FlutterMap with MbTilesTileProvider', (tester) async { | ||
final mbtiles = MockMBTiles(); | ||
when(mbtiles.getMetadata()) | ||
.thenAnswer((_) => MBTilesMetadata(name: 'MockMBTiles', format: 'png')); | ||
when(mbtiles.getTile(captureAny, captureAny, captureAny)) | ||
.thenAnswer((_) => TileProvider.transparentImage); | ||
await tester.pumpWidget(TestApp(mbtiles: mbtiles)); | ||
await tester.pumpAndSettle(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Mocks generated by Mockito 5.4.4 from annotations | ||
// in flutter_map_mbtiles/test/integration_test.dart. | ||
// Do not manually edit this file. | ||
|
||
// ignore_for_file: no_leading_underscores_for_library_prefixes | ||
import 'dart:typed_data' as _i3; | ||
|
||
import 'package:mbtiles/mbtiles.dart' as _i2; | ||
import 'package:mockito/mockito.dart' as _i1; | ||
|
||
// ignore_for_file: type=lint | ||
// ignore_for_file: avoid_redundant_argument_values | ||
// ignore_for_file: avoid_setters_without_getters | ||
// ignore_for_file: comment_references | ||
// ignore_for_file: deprecated_member_use | ||
// ignore_for_file: deprecated_member_use_from_same_package | ||
// ignore_for_file: implementation_imports | ||
// ignore_for_file: invalid_use_of_visible_for_testing_member | ||
// ignore_for_file: prefer_const_constructors | ||
// ignore_for_file: unnecessary_parenthesis | ||
// ignore_for_file: camel_case_types | ||
// ignore_for_file: subtype_of_sealed_class | ||
|
||
class _FakeMBTilesMetadata_0 extends _i1.SmartFake | ||
implements _i2.MBTilesMetadata { | ||
_FakeMBTilesMetadata_0( | ||
Object parent, | ||
Invocation parentInvocation, | ||
) : super( | ||
parent, | ||
parentInvocation, | ||
); | ||
} | ||
|
||
/// A class which mocks [MBTiles]. | ||
/// | ||
/// See the documentation for Mockito's code generation for more information. | ||
class MockMBTiles extends _i1.Mock implements _i2.MBTiles { | ||
@override | ||
_i2.MBTilesMetadata getMetadata({bool? allowCache = true}) => | ||
(super.noSuchMethod( | ||
Invocation.method( | ||
#getMetadata, | ||
[], | ||
{#allowCache: allowCache}, | ||
), | ||
returnValue: _FakeMBTilesMetadata_0( | ||
this, | ||
Invocation.method( | ||
#getMetadata, | ||
[], | ||
{#allowCache: allowCache}, | ||
), | ||
), | ||
returnValueForMissingStub: _FakeMBTilesMetadata_0( | ||
this, | ||
Invocation.method( | ||
#getMetadata, | ||
[], | ||
{#allowCache: allowCache}, | ||
), | ||
), | ||
) as _i2.MBTilesMetadata); | ||
|
||
@override | ||
_i3.Uint8List? getTile( | ||
int? z, | ||
int? x, | ||
int? y, | ||
) => | ||
(super.noSuchMethod( | ||
Invocation.method( | ||
#getTile, | ||
[ | ||
z, | ||
x, | ||
y, | ||
], | ||
), | ||
returnValueForMissingStub: null, | ||
) as _i3.Uint8List?); | ||
|
||
@override | ||
void dispose() => super.noSuchMethod( | ||
Invocation.method( | ||
#dispose, | ||
[], | ||
), | ||
returnValueForMissingStub: null, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'package:flutter_map_mbtiles/flutter_map_mbtiles.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
|
||
// ignore_for_file: diagnostic_describe_all_properties | ||
|
||
class TestApp extends StatelessWidget { | ||
final MBTiles mbtiles; | ||
|
||
const TestApp({super.key, required this.mbtiles}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
body: FlutterMap( | ||
options: const MapOptions( | ||
initialZoom: 0, | ||
initialCenter: LatLng(0, 0), | ||
), | ||
children: [ | ||
TileLayer( | ||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
tileProvider: MbTilesTilesProvider(mbtiles: mbtiles), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,7 @@ dependencies: | |
pmtiles: ^1.2.0 | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
test: ^1.24.9 | ||
flutter_lints: ^3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters