Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import java.util.HashMap;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -41,19 +42,32 @@ public class GoogleMapControllerTest {
private ComponentActivity activity;
private GoogleMapController googleMapController;

AutoCloseable mockCloseable;
@Mock BinaryMessenger mockMessenger;
@Mock GoogleMap mockGoogleMap;

@Before
public void before() {
MockitoAnnotations.initMocks(this);
mockCloseable = MockitoAnnotations.openMocks(this);
context = ApplicationProvider.getApplicationContext();
activity = Robolectric.setupActivity(ComponentActivity.class);
setUpActivityLegacy();
googleMapController =
new GoogleMapController(0, context, mockMessenger, activity::getLifecycle, null);
googleMapController.init();
}

// TODO(stuartmorgan): Update this to a non-deprecated test API.
// See https://github.com/flutter/flutter/issues/122102
@SuppressWarnings("deprecation")
private void setUpActivityLegacy() {
activity = Robolectric.setupActivity(ComponentActivity.class);
}

@After
public void tearDown() throws Exception {
mockCloseable.close();
}

@Test
public void DisposeReleaseTheMap() throws InterruptedException {
googleMapController.onMapReady(mockGoogleMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public void controller_OnMarkerDragStart() {
when(googleMap.addMarker(any(MarkerOptions.class))).thenReturn(marker);

final LatLng latLng = new LatLng(1.1, 2.2);
final Map<String, String> markerOptions = new HashMap();
final Map<String, String> markerOptions = new HashMap<>();
markerOptions.put("markerId", googleMarkerId);

final List<Object> markers = Arrays.<Object>asList(markerOptions);
controller.addMarkers(markers);
controller.onMarkerDragStart(googleMarkerId, latLng);

final List<Double> points = new ArrayList();
final List<Double> points = new ArrayList<>();
points.add(latLng.latitude);
points.add(latLng.longitude);

Expand All @@ -75,14 +75,14 @@ public void controller_OnMarkerDragEnd() {
when(googleMap.addMarker(any(MarkerOptions.class))).thenReturn(marker);

final LatLng latLng = new LatLng(1.1, 2.2);
final Map<String, String> markerOptions = new HashMap();
final Map<String, String> markerOptions = new HashMap<>();
markerOptions.put("markerId", googleMarkerId);

final List<Object> markers = Arrays.<Object>asList(markerOptions);
controller.addMarkers(markers);
controller.onMarkerDragEnd(googleMarkerId, latLng);

final List<Double> points = new ArrayList();
final List<Double> points = new ArrayList<>();
points.add(latLng.latitude);
points.add(latLng.longitude);

Expand All @@ -108,14 +108,14 @@ public void controller_OnMarkerDrag() {
when(googleMap.addMarker(any(MarkerOptions.class))).thenReturn(marker);

final LatLng latLng = new LatLng(1.1, 2.2);
final Map<String, String> markerOptions = new HashMap();
final Map<String, String> markerOptions = new HashMap<>();
markerOptions.put("markerId", googleMarkerId);

final List<Object> markers = Arrays.<Object>asList(markerOptions);
controller.addMarkers(markers);
controller.onMarkerDrag(googleMarkerId, latLng);

final List<Double> points = new ArrayList();
final List<Double> points = new ArrayList<>();
points.add(latLng.latitude);
points.add(latLng.longitude);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ task clean(type: Delete) {
gradle.projectsEvaluated {
project(":google_maps_flutter_android") {
tasks.withType(JavaCompile) {
// TODO(stuartmorgan): Enable this. See
// https://github.com/flutter/flutter/issues/91868
//options.compilerArgs << "-Xlint:all" << "-Werror"
// Ignore classfile warnings due to https://bugs.openjdk.org/browse/JDK-8190452
// TODO(stuartmorgan): Remove that ignore once the build uses Java 11+.
options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile"
// Workaround for a warning when building that the above turns into
// an error, coming from jetified-play-services-maps-18.1.0:
// warning: Cannot find annotation method 'value()' in type
// 'GuardedBy': class file for
// javax.annotation.concurrent.GuardedBy not found
dependencies {
implementation "com.google.code.findbugs:jsr305:3.0.2"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
org.gradle.jvmargs=-Xmx4G
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true