From ef0fa632ae2bfeda4ac95a041bf14ffb90cc6fd2 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Wed, 18 Sep 2024 17:15:38 +0300 Subject: [PATCH 1/2] Revert "Disable failing tests" This reverts commit 5bdafb144a8051ec3df9485e7496f708493410c3. --- .github/workflows/library.yml | 11 ++++++++++- .github/workflows/utils.yml | 9 +++++++++ .../io/ona/kujaku/services/TrackingService.java | 2 +- .../MapboxOfflineDownloaderServiceTest.java | 15 ++++++--------- .../ona/kujaku/services/TrackingServiceTest.java | 3 --- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml index d6057597..c74d31ac 100644 --- a/.github/workflows/library.yml +++ b/.github/workflows/library.yml @@ -46,7 +46,16 @@ jobs: run: git fetch origin master && git rev-list --first-parent --count origin/master - name: Clean project - run: ./gradlew clean --stacktrace + run: ./gradlew clean --stacktrace + + - name: Build project skipping tests + run: ./gradlew build -x test --stacktrace + + - name: Run Instrumented Tests manually + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 34 + script: ./gradlew :library:connectedDebug --stacktrace --info - name: Run unit tests with Gradle run: ./gradlew :library:clean :library:testDebugUnitTest --stacktrace diff --git a/.github/workflows/utils.yml b/.github/workflows/utils.yml index 9fcd44c8..178f3d83 100644 --- a/.github/workflows/utils.yml +++ b/.github/workflows/utils.yml @@ -48,6 +48,15 @@ jobs: - name: Clean project run: ./gradlew clean --stacktrace + - name: Build project skipping tests + run: ./gradlew build -x test --stacktrace + + - name: Run Instrumented Tests manually + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 34 + script: ./gradlew :utils:connectedDebug --stacktrace + - name: Generate & upload utils snapshot artifact AAR (Android Archive) file to Sonatype run: ./gradlew :utils:clean --stacktrace && ./gradlew :utils:assembleRelease --stacktrace && ./gradlew :utils:publishMavenJavaPublicationToMavenCentralRepository --stacktrace diff --git a/library/src/main/java/io/ona/kujaku/services/TrackingService.java b/library/src/main/java/io/ona/kujaku/services/TrackingService.java index e3c4f924..9359d4bf 100644 --- a/library/src/main/java/io/ona/kujaku/services/TrackingService.java +++ b/library/src/main/java/io/ona/kujaku/services/TrackingService.java @@ -502,7 +502,7 @@ private synchronized void recordPendingLocation() { /** * Volatile because different methods are called from the main thread and serviceThread */ - private final LocationListener locationListener = new LocationListener() { + private volatile LocationListener locationListener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { diff --git a/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java b/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java index c84dc5b8..4d1ef513 100644 --- a/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java +++ b/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java @@ -21,7 +21,6 @@ import org.json.JSONObject; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; @@ -66,6 +65,11 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; +/** + * + * + * Created by Ephraim Kigamba - ekigamba@ona.io on 05/12/2017. + */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = { @@ -85,7 +89,7 @@ public class MapboxOfflineDownloaderServiceTest { private Context context; private MapboxOfflineDownloaderService mapboxOfflineDownloaderService; - private final String sampleValidMapboxStyleURL = "mapbox://styles/ona/90kiosdcIJ3d"; + private String sampleValidMapboxStyleURL = "mapbox://styles/ona/90kiosdcIJ3d"; private String mapboxAccessToken; private float minZoom = 22; private float maxZoom = 10; @@ -241,19 +245,16 @@ public void persistOfflineMapTaskShouldSaveQueueTaskWhenGivenValidDownloadTask() } @Test - @Ignore("Hanging on CI") public void sendBroadcastShouldProduceValidIntentWhenGivenDownloadUpdate() { assertValidBroadcastCreatedWhenSendBroadcastIsCalled(MapboxOfflineDownloaderService.SERVICE_ACTION_RESULT.SUCCESSFUL, mapName, "9.0%", MapboxOfflineDownloaderService.SERVICE_ACTION.DOWNLOAD_MAP); } @Test - @Ignore("Hanging on CI") public void sendBroadcast2ShouldProduceValidIntentWhenGivenDownloadUpdate() { assertValidBroadcastCreatedWhenSendBroadcast2IsCalled(MapboxOfflineDownloaderService.SERVICE_ACTION_RESULT.SUCCESSFUL, mapName, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); } @Test - @Ignore("Hanging on CI") public void mapboxTileLimitExceededShouldCreateValidBroadcast() throws InterruptedException, NoSuchFieldException, IllegalAccessException { latch = new CountDownLatch(1); @@ -269,7 +270,6 @@ public void mapboxTileLimitExceededShouldCreateValidBroadcast() throws Interrupt } @Test - @Ignore("Failing : To Do Fix") public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndMessage() throws NoSuchFieldException, IllegalAccessException { latch = new CountDownLatch(1); @@ -286,7 +286,6 @@ public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndMessage() } @Test - @Ignore("Hanging on CI") public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndEmptyMessage() throws NoSuchFieldException, IllegalAccessException, InterruptedException { latch = new CountDownLatch(1); @@ -304,7 +303,6 @@ public void onErrorShouldCreateValidBroadcastWhenGivenNonEmptyReasonAndEmptyMess } @Test - @Ignore("Hanging on CI") public void onStatusChangedShouldShowProgressNotificationWhenGivenIncompleteOfflineRegionStatus() throws NoSuchFieldException, IllegalAccessException, InterruptedException, NoSuchMethodException, InvocationTargetException { latch = new CountDownLatch(1); OfflineRegionStatus incompleteOfflineRegionStatus = createOfflineRegion(OfflineRegion.STATE_ACTIVE, 200, 98923, 898, 230909, 300, true, false); @@ -427,7 +425,6 @@ public void getTaskStatusShouldUpdateCurrentDownloadMapNameWhenGivenValidDeleteQ } @Test - @Ignore("Hanging on CI") public synchronized void onStatusChangedShouldShowDownloadCompleteNotificationWhenGivenCompletedOfflineRegion() throws Throwable { latch = new CountDownLatch(1); OfflineRegionStatus completeOfflineRegionStatus = createOfflineRegion(OfflineRegion.STATE_ACTIVE, 300, 98923, 898, 230909, 300, true, true); diff --git a/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java b/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java index 2309d4ac..e6e40d76 100644 --- a/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java +++ b/library/src/test/java/io/ona/kujaku/services/TrackingServiceTest.java @@ -192,7 +192,6 @@ public void testTrackingServiceDefaultUiConfiguration() { } @Test - @Ignore("Hanging on CI") public void testStartAndBindService() throws InterruptedException { CountDownLatch latch1 = new CountDownLatch(1); CountDownLatch latch2 = new CountDownLatch(1); @@ -222,7 +221,6 @@ public void onServiceDisconnected(ComponentName name) { } @Test - @Ignore("Hanging on CI") public void testServiceWithLocationInDistanceTolerance() throws InterruptedException { controller = Robolectric.buildService(TrackingService.class, TrackingService.getIntent(context, MapActivity.class, new TrackingServiceHighAccuracyOptions())); @@ -320,7 +318,6 @@ public void onServiceDisconnected() { } @Test - @Ignore("Flakey Unit Test : To Do Fix") public void testServiceWithTags() throws InterruptedException { long startTag = 1000; long nextTag = 2000; From 0ab005583757b79f80cd61bd5475f32672aa0cd8 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Wed, 18 Sep 2024 17:24:51 +0300 Subject: [PATCH 2/2] Code clean up --- .github/workflows/library.yml | 2 -- library/build.gradle | 4 ++-- .../MapboxOfflineDownloaderServiceTest.java | 23 ++++++++----------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/library.yml b/.github/workflows/library.yml index c74d31ac..ca7a80d5 100644 --- a/.github/workflows/library.yml +++ b/.github/workflows/library.yml @@ -57,8 +57,6 @@ jobs: api-level: 34 script: ./gradlew :library:connectedDebug --stacktrace --info - - name: Run unit tests with Gradle - run: ./gradlew :library:clean :library:testDebugUnitTest --stacktrace - name: Generate & upload library snapshot artifact AAR (Android Archive) file run: ./gradlew :library:clean --stacktrace && ./gradlew :library:assembleRelease --stacktrace && ./gradlew :library:publishMavenJavaPublicationToMavenCentralRepository --stacktrace diff --git a/library/build.gradle b/library/build.gradle index cd6e0d94..98e4d7b8 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -13,7 +13,7 @@ buildscript { apply plugin: 'realm-android' apply plugin: 'maven-publish' -version '0.10.6-SNAPSHOT' +version '0.10.6-2-SNAPSHOT' project.version = this.version @@ -123,7 +123,7 @@ dependencies { configuration -> //implementation (project(":utils")) { // Uncomment the line below when creating releases implementation('io.ona.kujaku:utils:0.10.6-SNAPSHOT') { - transitive = true; + transitive = true exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk' exclude group: 'com.android.support', module: 'support-v4' } diff --git a/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java b/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java index 4d1ef513..2d0f2af6 100644 --- a/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java +++ b/library/src/test/java/io/ona/kujaku/services/MapboxOfflineDownloaderServiceTest.java @@ -65,11 +65,6 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; -/** - * - * - * Created by Ephraim Kigamba - ekigamba@ona.io on 05/12/2017. - */ @RunWith(RobolectricTestRunner.class) @Config(manifest = Config.NONE, shadows = { @@ -83,23 +78,23 @@ }) public class MapboxOfflineDownloaderServiceTest { - private String mapName = UUID.randomUUID().toString(); + private final String mapName = UUID.randomUUID().toString(); private static final String TAG = MapboxOfflineDownloaderServiceTest.class.getSimpleName(); private Context context; private MapboxOfflineDownloaderService mapboxOfflineDownloaderService; - private String sampleValidMapboxStyleURL = "mapbox://styles/ona/90kiosdcIJ3d"; + private final String sampleValidMapboxStyleURL = "mapbox://styles/ona/90kiosdcIJ3d"; private String mapboxAccessToken; - private float minZoom = 22; - private float maxZoom = 10; - private LatLng topLeftBound = new LatLng(9.1, 9.1); - private LatLng topRightBound = new LatLng(9.1, 20.5); - private LatLng bottomRightBound = new LatLng(1.1, 20.5); - private LatLng bottomLeftBound = new LatLng(9.1, 1.1); + private final float minZoom = 22; + private final float maxZoom = 10; + private final LatLng topLeftBound = new LatLng(9.1, 9.1); + private final LatLng topRightBound = new LatLng(9.1, 20.5); + private final LatLng bottomRightBound = new LatLng(1.1, 20.5); + private final LatLng bottomLeftBound = new LatLng(9.1, 1.1); private CountDownLatch latch; - private ArrayList resultsToCheck = new ArrayList<>(); + private final ArrayList resultsToCheck = new ArrayList<>(); @Before public void setUp() throws Exception {