Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Increase SDK test coverage #8261

Merged
merged 1 commit into from
May 11, 2017
Merged

Increase SDK test coverage #8261

merged 1 commit into from
May 11, 2017

Conversation

Guardiola31337
Copy link
Contributor

There are a bunch of classes not already tested in the SDK module.

@Guardiola31337 Guardiola31337 added Android Mapbox Maps SDK for Android tests ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Mar 2, 2017
@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch from 306ac5a to d988a7d Compare March 2, 2017 22:54
@tobrun
Copy link
Member

tobrun commented Mar 3, 2017

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.

@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch from bf18178 to 6f30973 Compare March 6, 2017 21:14
Copy link
Member

@tobrun tobrun left a 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() {
Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch 3 times, most recently from 3634de4 to 2549f23 Compare March 31, 2017 11:51
Copy link
Contributor

@ivovandongen ivovandongen left a 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;
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor

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) {
Copy link
Contributor

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() {
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor

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();
Copy link
Contributor

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 {
Copy link
Contributor

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
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaDoc + Naming

@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch from 0b3003d to ab0dd00 Compare April 11, 2017 06:38
@Guardiola31337 Guardiola31337 added ✓ ready for review and removed ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Apr 11, 2017
@Guardiola31337 Guardiola31337 changed the title [WIP] Increase SDK test coverage Increase SDK test coverage Apr 11, 2017
@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch 3 times, most recently from 8bd2166 to 482b84e Compare April 13, 2017 17:11
@tobrun
Copy link
Member

tobrun commented Apr 20, 2017

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.
I feel the best way forward is to merge current approach and ticketing out a follow up ticket with a focus on having more local and isolated setup.

Before we merge @Guardiola31337, can we address the naming comments? Most of these were fixed with using the -able suffix but the plural names remained untouched. AFAIK plural names are reserved for Collection (sub)classes with the exception of utility classes.

@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch 2 times, most recently from e45f800 to 2eaa757 Compare May 10, 2017 18:32
@Guardiola31337
Copy link
Contributor Author

@tobrun I fixed suggested comments 👍
Could you give it a second look?

…annotation manager tests (add marker and add markers)
@Guardiola31337 Guardiola31337 force-pushed the move_unit_tests_into_sdk branch from 2eaa757 to 75b78ab Compare May 11, 2017 09:03
@Guardiola31337 Guardiola31337 merged commit 5290d7e into master May 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants