Skip to content

Commit

Permalink
Merge pull request #563 from adobe/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
praveek authored Sep 27, 2023
2 parents e29ef31 + c78f629 commit 9dd5589
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 15 deletions.
2 changes: 2 additions & 0 deletions code/core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,32 @@ public static void setSmallIconResourceID(final int resourceID) {
}

/**
* Sets the resource Id for small icon.
* 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 large icon.
*
* @param resourceID the resource Id of the icon
*/
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
// ========================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
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;
Expand Down Expand Up @@ -55,11 +57,44 @@ 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<SharedPreferences.Editor>() {
@Override
Expand All @@ -72,13 +107,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<SharedPreferences.Editor>() {
Expand All @@ -95,12 +132,34 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation)
AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored);
}

// ******************************************************************************************
// LargeIconResourceId Tests
// ******************************************************************************************

@Test
public void testSetLargeIconResourceId_ValidIdSetTwice() {
public void testLargeIconResourceId_ValidIdSet() {
// Setup
final int expectedValueStored = 123456;
AppResourceStore.INSTANCE.setLargeIconResourceID(111111);
when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt()))
.thenReturn(123456);

// Test
int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID();
assertEquals(123456, actualResourceId);
}

@Test
public void testGetLargeIconResourceId_NoIdSet() {
when(mockSharedPreferences.getInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt())).thenReturn(-1);

// Test
int actualResourceId = AppResourceStore.INSTANCE.getLargeIconResourceID();
assertEquals(actualResourceId, -1);
}

@Test
public void testSetLargeIconResourceId_ValidIdSet() {
// Setup
final int expectedValueStored = 123456;
when(mockPreferenceEditor.putInt(eq(DATASTORE_KEY_LARGE_ICON), anyInt()))
.thenAnswer(
new Answer<SharedPreferences.Editor>() {
Expand All @@ -118,12 +177,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<SharedPreferences.Editor>() {
@Override
Expand All @@ -136,6 +195,6 @@ public SharedPreferences.Editor answer(InvocationOnMock invocation)
});

// Test
AppResourceStore.INSTANCE.setSmallIconResourceID(expectedValueStored);
AppResourceStore.INSTANCE.setLargeIconResourceID(expectedValueStored);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9dd5589

Please sign in to comment.