From 87df2c1d425ff5a2dbae2b9979148d30dc9b3e47 Mon Sep 17 00:00:00 2001 From: Pravin Prakash Kumar Date: Tue, 5 Sep 2023 16:44:31 -0700 Subject: [PATCH 1/5] expose getSmallIconResourceID API for AJO Notification Builder --- .../adobe/marketing/mobile/MobileCore.java | 9 ++++++++ .../internal/AppResourceStoreTests.java | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java b/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java index 889f92730..2f46344a9 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java @@ -318,6 +318,15 @@ public static void setSmallIconResourceID(final int resourceID) { AppResourceStore.INSTANCE.setSmallIconResourceID(resourceID); } + /** + * Returns the resource Id for small icon if it was set by `setSmallIconResourceID`. + * + * @return a `int` value if it has been set, otherwise -1 + */ + public static int getSmallIconResourceID() { + return AppResourceStore.INSTANCE.getSmallIconResourceID(); + } + /** * Sets the resource Id for small icon. * diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java index e8aec2620..0d034db46 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java +++ b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java @@ -95,6 +95,27 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); } + @Test + public void testGetSmallIconResourceId_ValidIdSet() { + // Setup + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + .thenReturn(123456); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + assertEquals(123456, actualResourceId); + } + + @Test + public void testGetSmallIconResourceId_NoIdSet() { + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + .thenReturn(-1); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + assertEquals(actualResourceId,-1); + } + @Test public void testSetLargeIconResourceId_ValidIdSetTwice() { // Setup From 955d5eb38bdb209ecfd6d380e3c696485938ae64 Mon Sep 17 00:00:00 2001 From: Pravin Prakash Kumar Date: Fri, 15 Sep 2023 10:33:41 -0700 Subject: [PATCH 2/5] Include setLargeIconResourceID as well --- .../java/com/adobe/marketing/mobile/MobileCore.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java b/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java index 2f46344a9..43e7af221 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/MobileCore.java @@ -328,7 +328,7 @@ public static int getSmallIconResourceID() { } /** - * Sets the resource Id for small icon. + * Sets the resource Id for large icon. * * @param resourceID the resource Id of the icon */ @@ -336,6 +336,15 @@ public static void setLargeIconResourceID(final int resourceID) { AppResourceStore.INSTANCE.setLargeIconResourceID(resourceID); } + /** + * Returns the resource Id for large icon if it was set by `setLargeIconResourceID`. + * + * @return a `int` value if it has been set, otherwise -1 + */ + public static int getLargeIconResourceID() { + return AppResourceStore.INSTANCE.getLargeIconResourceID(); + } + // ======================================================== // Identifiers // ======================================================== From 939a46ab46022c159874cbbbca0f44365fd6ade0 Mon Sep 17 00:00:00 2001 From: Pravin Prakash Kumar Date: Wed, 20 Sep 2023 15:27:03 -0700 Subject: [PATCH 3/5] more test for large Icon resources --- .../internal/AppResourceStoreTests.java | 74 ++++++++++++++----- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java index 0d034db46..fb1e97057 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java +++ b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java @@ -15,12 +15,15 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; import android.content.Context; import android.content.SharedPreferences; import com.adobe.marketing.mobile.services.AppContextService; import com.adobe.marketing.mobile.services.ServiceProviderModifier; + +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -55,11 +58,45 @@ public void beforeEach() { ServiceProviderModifier.setAppContextService(mockAppContextService); } + @After + public void afterEach() { + reset(mockSharedPreferences); + AppResourceStore.INSTANCE.setLargeIconResourceID(-1); + AppResourceStore.INSTANCE.setSmallIconResourceID(-1); + } + + // ****************************************************************************************** + // SmallIconResourceId Tests + // ****************************************************************************************** + @Test - public void testSetLargeIconResourceId_ValidIdSet() { + public void testGetSmallIconResourceId_ValidIdSet() { + // Setup + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + .thenReturn(123456); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + assertEquals(123456, actualResourceId); + } + + @Test + public void testGetSmallIconResourceId_NoIdSet() { + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + .thenReturn(-1); + + // Test + int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + assertEquals(actualResourceId,-1); + } + + @Test + public void testSetSmallIconResourceId_ValidIdSetTwice() { // Setup final int expectedValueStored = 123456; - when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) + AppResourceStore.INSTANCE.setSmallIconResourceID(11111); + + when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) .thenAnswer( new Answer() { @Override @@ -72,13 +109,15 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) }); // Test - AppResourceStore.INSTANCE.setLargeIconResourceID(expectedValueStored); + AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); } @Test public void testSetSmallIconResourceId_ValidIdSet() { // Setup final int expectedValueStored = 123456; + AppResourceStore.INSTANCE.setSmallIconResourceID(11111); + when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) .thenAnswer( new Answer() { @@ -95,33 +134,34 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); } + // ****************************************************************************************** + // LargeIconResourceId Tests + // ****************************************************************************************** + @Test - public void testGetSmallIconResourceId_ValidIdSet() { + public void testLargeIconResourceId_ValidIdSet() { // Setup - when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) .thenReturn(123456); // Test - int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID(); assertEquals(123456, actualResourceId); } @Test - public void testGetSmallIconResourceId_NoIdSet() { - when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + public void testGetLargeIconResourceId_NoIdSet() { + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) .thenReturn(-1); // Test - int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); + int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID(); assertEquals(actualResourceId,-1); } - @Test - public void testSetLargeIconResourceId_ValidIdSetTwice() { + public void testSetLargeIconResourceId_ValidIdSet() { // Setup final int expectedValueStored = 123456; - AppResourceStore.INSTANCE.setLargeIconResourceID(111111); - when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) .thenAnswer( new Answer() { @@ -139,12 +179,12 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) } @Test - public void testSetSmallIconResourceId_ValidIdSetTwice() { + public void testSetLargeIconResourceId_ValidIdSetTwice() { // Setup final int expectedValueStored = 123456; - AppResourceStore.INSTANCE.setSmallIconResourceID(11111); + AppResourceStore.INSTANCE.setLargeIconResourceID(111111); - when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) + when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) .thenAnswer( new Answer() { @Override @@ -157,6 +197,6 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation) }); // Test - AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored); + AppResourceStore.INSTANCE.setLargeIconResourceID(expectedValueStored); } } From 1028cde1598cb4d5240ff18a42a77a0a72597baf Mon Sep 17 00:00:00 2001 From: praveek Date: Wed, 20 Sep 2023 20:03:21 -0700 Subject: [PATCH 4/5] Fix build errors --- code/core/api/core.api | 2 ++ .../mobile/internal/AppResourceStoreTests.java | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/core/api/core.api b/code/core/api/core.api index 39d1e2200..5ab422d6d 100644 --- a/code/core/api/core.api +++ b/code/core/api/core.api @@ -227,10 +227,12 @@ public final class com/adobe/marketing/mobile/MobileCore { public static fun dispatchResponseEvent (Lcom/adobe/marketing/mobile/Event;Lcom/adobe/marketing/mobile/Event;Lcom/adobe/marketing/mobile/ExtensionErrorCallback;)Z public static fun extensionVersion ()Ljava/lang/String; public static fun getApplication ()Landroid/app/Application; + public static fun getLargeIconResourceID ()I public static fun getLogLevel ()Lcom/adobe/marketing/mobile/LoggingMode; public static fun getMessagingDelegate ()Lcom/adobe/marketing/mobile/services/MessagingDelegate; public static fun getPrivacyStatus (Lcom/adobe/marketing/mobile/AdobeCallback;)V public static fun getSdkIdentities (Lcom/adobe/marketing/mobile/AdobeCallback;)V + public static fun getSmallIconResourceID ()I public static fun lifecyclePause ()V public static fun lifecycleStart (Ljava/util/Map;)V public static fun log (Lcom/adobe/marketing/mobile/LoggingMode;Ljava/lang/String;Ljava/lang/String;)V diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java index fb1e97057..cf2c5c6c8 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java +++ b/code/core/src/test/java/com/adobe/marketing/mobile/internal/AppResourceStoreTests.java @@ -22,7 +22,6 @@ import android.content.SharedPreferences; import com.adobe.marketing.mobile.services.AppContextService; import com.adobe.marketing.mobile.services.ServiceProviderModifier; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -82,12 +81,11 @@ public void testGetSmallIconResourceId_ValidIdSet() { @Test public void testGetSmallIconResourceId_NoIdSet() { - when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())) - .thenReturn(-1); + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_SMALL_ICON), anyInt())).thenReturn(-1); // Test int actualResourceId = AppResourceStore.INSTANCE.getSmallIconResourceID(); - assertEquals(actualResourceId,-1); + assertEquals(actualResourceId, -1); } @Test @@ -151,13 +149,13 @@ public void testLargeIconResourceId_ValidIdSet() { @Test public void testGetLargeIconResourceId_NoIdSet() { - when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())) - .thenReturn(-1); + when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())).thenReturn(-1); // Test int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID(); - assertEquals(actualResourceId,-1); + assertEquals(actualResourceId, -1); } + @Test public void testSetLargeIconResourceId_ValidIdSet() { // Setup From da63d44367d06a554975e2da6450ed4f1ec7f021 Mon Sep 17 00:00:00 2001 From: praveek Date: Thu, 21 Sep 2023 18:46:03 +0000 Subject: [PATCH 5/5] Update versions [Core-2.5.0] --- .../java/com/adobe/marketing/mobile/internal/CoreConstants.kt | 2 +- .../src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt | 2 +- .../internal/configuration/ConfigurationExtensionTests.kt | 2 +- code/gradle.properties | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt b/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt index c397b505e..d36d4797c 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt +++ b/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt @@ -13,7 +13,7 @@ package com.adobe.marketing.mobile.internal internal object CoreConstants { const val LOG_TAG = "MobileCore" - const val VERSION = "2.4.0" + const val VERSION = "2.5.0" object EventDataKeys { /** diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt b/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt index 2b64cb7ac..4d459cbc7 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt +++ b/code/core/src/test/java/com/adobe/marketing/mobile/MobileCoreTests.kt @@ -35,7 +35,7 @@ import kotlin.test.assertTrue @RunWith(MockitoJUnitRunner.Silent::class) class MobileCoreTests { - private var EXTENSION_VERSION = "2.4.0" + private var EXTENSION_VERSION = "2.5.0" @Mock private lateinit var mockedEventHub: EventHub diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt b/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt index 083db7254..2b8fee992 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt +++ b/code/core/src/test/java/com/adobe/marketing/mobile/internal/configuration/ConfigurationExtensionTests.kt @@ -60,7 +60,7 @@ import kotlin.test.assertTrue @RunWith(MockitoJUnitRunner.Silent::class) class ConfigurationExtensionTests { - private var EXTENSION_VERSION = "2.4.0" + private var EXTENSION_VERSION = "2.5.0" @Mock private lateinit var mockServiceProvider: ServiceProvider diff --git a/code/gradle.properties b/code/gradle.properties index eb7862553..15549a7e9 100644 --- a/code/gradle.properties +++ b/code/gradle.properties @@ -6,7 +6,7 @@ android.useAndroidX=true # #Maven artifacts #Core extension -coreExtensionVersion=2.4.0 +coreExtensionVersion=2.5.0 coreExtensionName=core coreExtensionAARName=core-phone-release.aar coreMavenRepoName=AdobeMobileCoreSdk