-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
306ac5a
to
d988a7d
Compare
With this PR we are moving the tests to the SDK module, this change needs to be reflected in the Makefile for the different unit test tasks we expose there. |
bf18178
to
6f30973
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are looking great overal, feel free to tackle method implementations themselves as well. one thing we were thinking about is removing the List by separating them into different collections, long term we want to simplify a lot of this code using the peer model in #6912.
|
||
static { | ||
@Override | ||
public void loadNativeLibrary() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this is a valid change, loading the native library is a static operation. cc @ivovandongen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use Interfaces in any case for testability. Instead of depending on classes directly.
For the library loading, I would like to centralise it, regardless of testability. For example, create a class LibraryLoader
, with a single static method load()
which can be called from the classes containing methods from a static initialisation block still. This would centralise the knowledge about the library name at least. And also, you could mock this method with PowerMock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivovandongen I like the idea to create a class LibraryLoader
to centralise all related stuff in the same class (as you mentioned) but I don't understand the necessity of a static block and a static method. Do they have to be static for any particular reason that I don't know yet? cc/ @tobrun
3634de4
to
2549f23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The devision of responsibilities is a good idea. However, the decomposition is not entirely clear. This might mostly be naming, but the devision between concepts as AnnotationManager
, Annotations
and then an implementation called AnnotationsFunctions
seems a little arbitrary. It seems like Annotations
is meant to manage the collection of annotations, but thats also the responsibility of AnnotationManager
.
private final List<Marker> selectedMarkers = new ArrayList<>(); | ||
|
||
private MapboxMap mapboxMap; | ||
private MapboxMap.OnMarkerClickListener onMarkerClickListener; | ||
|
||
AnnotationManager(NativeMapView view, MapView mapView, MarkerViewManager markerViewManager) { | ||
private Annotations annotationsManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird naming, an Annotations
called annotationsManager
inside AnnotationManager
|
||
import java.util.List; | ||
|
||
interface Annotations { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, naming here. Can we give this a somewhat more descriptive name? Also, how is this different from the responsibilities of AnnotationManager
itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc on interfaces is greatly appreciated
private final NativeMapView nativeMapView; | ||
private final LongSparseArray<Annotation> annotations; | ||
|
||
AnnotationsFunctions(NativeMapView nativeMapView, LongSparseArray<Annotation> annotations) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming; AnnotationFunctions
?
|
||
|
||
class LibraryLoader { | ||
static void load() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT; empty lines / a hint of JavaDoc
|
||
import java.util.List; | ||
|
||
interface Markers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc on interfaces is greatly appreciated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming here, again sorry, is not ideal. My main question again is how this differs from related classes
static { | ||
System.loadLibrary("mapbox-gl"); | ||
LibraryLoader.load(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you replace all occurrences of System.loadLibrary("mapbox-gl");
:
- platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/NativeConnectivityListener.java
- platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
- platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
|
||
import java.util.List; | ||
|
||
interface Polygons { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc + Naming
private final IconManager iconManager; | ||
private final MarkerViewManager markerViewManager; | ||
|
||
MarkersFunctions(NativeMapView nativeMapView, MapView mapView, LongSparseArray<Annotation> annotations, IconManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc + Naming
In this case the plurality of Markers is also a bit weird here I think.
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
class PolygonsFunctions implements Polygons { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc + Naming (incl plurality)
|
||
import java.util.List; | ||
|
||
interface Polylines { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc + Naming
0b3003d
to
ab0dd00
Compare
8bd2166
to
482b84e
Compare
I would like to get this PR moving forward. The refactored code + having a way to unit test library loading classes are valuable additions to the next release. Though there is consensus on having unit testable native library loading classes, there is some disagreement on the way it's currently setup. Before we merge @Guardiola31337, can we address the naming comments? Most of these were fixed with using the |
e45f800
to
2eaa757
Compare
@tobrun I fixed suggested comments 👍 |
…annotation manager tests (add marker and add markers)
2eaa757
to
75b78ab
Compare
There are a bunch of classes not already tested in the SDK module.