Skip to content

Commit

Permalink
Add opportunity to use map in widget tests (#281)
Browse files Browse the repository at this point in the history
Hey! I needed to use the map in widget tests. But as it uses platform
views those are not working properly during widget tests. So I made some
classes visible and added a method to provide fake
`MethodChannelMaplibreGl` to `MapLibreGlPlatform`.

Usage
```dart
class FakeMethodChannelMaplibreGl implements MethodChannelMaplibreGl {
...
}

 MapLibreGlPlatform.instance = FakeMethodChannelMaplibreGl();
```

Co-authored-by: Kostiantyn Manoilo <k.manoilo@foodtech.team>
Co-authored-by: Julian Bissekkou <36447137+JulianBissekkou@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 25, 2023
1 parent 91b0afa commit 06a2cf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/mapbox_gl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da
RasterDemSourceProperties,
GeojsonSourceProperties,
VideoSourceProperties,
ImageSourceProperties;
ImageSourceProperties,
MapLibreGlPlatform,
MethodChannelMaplibreGl,
OnPlatformViewCreatedCallback;

part 'src/controller.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ part of maplibre_gl_platform_interface;
typedef OnPlatformViewCreatedCallback = void Function(int);

abstract class MapLibreGlPlatform {
static MethodChannelMaplibreGl? _instance;

/// The default instance of [MapboxGlPlatform] to use.
///
/// Defaults to [MethodChannelMaplibreGl].
///
/// Platform-specific plugins should set this with their own platform-specific
/// class that extends [MapLibreGlPlatform] when they register themselves.
static MapLibreGlPlatform Function() createInstance =
() => MethodChannelMaplibreGl();
() => _instance ?? MethodChannelMaplibreGl();

static set instance(MethodChannelMaplibreGl instance) {
_instance = instance;
}

final onInfoWindowTappedPlatform = ArgumentCallbacks<String>();

Expand Down

0 comments on commit 06a2cf5

Please sign in to comment.