Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
LasOri committed Apr 6, 2022
2 parents ce11dd0 + 5d3d86b commit d1384b3
Show file tree
Hide file tree
Showing 194 changed files with 4,925 additions and 4,701 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$Versions.kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$Versions.kotlin_version"
classpath "com.github.ben-manes:gradle-versions-plugin:0.39.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.1"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}
Expand Down
26 changes: 12 additions & 14 deletions buildSrc/src/main/java/Dependency.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
object Versions {
const val kotlin_version = "1.6.10"
const val kotlin_version = "1.6.20"
const val kotlin_test_version = "3.4.2"
const val mockito_version = "4.1.0"
const val firebase_messaging_version = "23.0.0"
const val mockito_version = "4.4.0"
const val firebase_messaging_version = "23.0.2"
const val support_test_version = "1.4.0"
const val support_library = "1.4.0"
const val support_library = "1.4.1"
const val support_test_extensions= "1.1.3"
const val support_test_fragment= "1.4.0"
const val support_test_fragment= "1.4.1"
const val support_annotations = "1.3.0"
const val buildToolsVersion = "31.0.0"
const val multiDexVersion = "2.0.0"
const val kotlinMockito = "4.0.0"
const val location_services_version = "19.0.0"
const val location_services_version = "19.0.1"
const val espresso_idling_resources = "3.4.0"
const val archLifecycleVersion ="2.4.0"
const val java8LifecycleVersion ="2.4.0"
const val archLifecycleVersion ="2.4.1"
const val java8LifecycleVersion ="2.4.1"
const val securityCryptoVersion = "1.1.0-alpha03"
const val byte_buddy_version = "1.12.3"
const val byte_buddy_version = "1.12.8"
const val google_tink_version = "1.6.1"
const val huawei_agconnect_core_version = "1.6.2.300"
const val huawei_hms_push_version = "6.1.0.300"
const val mockkVersion = "1.12.1"
const val kotlin_coroutine_version = "1.5.2"
const val huawei_agconnect_core_version = "1.6.4.300"
const val huawei_hms_push_version = "6.3.0.304"
const val mockkVersion = "1.12.3"
}

object Libs {
Expand All @@ -39,7 +38,6 @@ object Libs {
const val google_tink = "com.google.crypto.tink:tink-android:${Versions.google_tink_version}"
const val huawei_agconnect_core = "com.huawei.agconnect:agconnect-core:${Versions.huawei_agconnect_core_version}"
const val huawei_hms_push = "com.huawei.hms:push:${Versions.huawei_hms_push_version}"
const val kotlin_coroutine = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.kotlin_coroutine_version}"
}

object TestLibs {
Expand Down
13 changes: 4 additions & 9 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# What's changed
### [Emarsys SDK](https://github.com/emartech/android-emarsys-sdk/wiki)
* Kotlin version has been updated to 1.6.10

### [Predict](https://github.com/emartech/android-emarsys-sdk/wiki#4-predict)
* Added new validation to the `trackPurchase` method so that empty cartItems lists are no longer accepted as it would be an invalid request.

# What's fixed
### [Emarsys SDK](https://github.com/emartech/android-emarsys-sdk/wiki)
* Fixed an issue where in some edge-cases the SDK could crash below API level 28 when tried to decide if the device has internet connection
### [Config](https://github.com/emartech/android-emarsys-sdk/wiki/Config#changeapplicationcode)
* Fixed an issue when changing appcode would not clear the push token.
### [Geofence](https://github.com/emartech/android-emarsys-sdk/wiki#8-geofence)
* Fixed an issue when enabling the feature without last known location could cause a crash.
1 change: 0 additions & 1 deletion core-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ dependencies {
api Libs.lifecycle_extension_java_8
api Libs.lifecycle_process
api Libs.security_crypto
api Libs.kotlin_coroutine
androidTestImplementation project(':testUtils')
}
2 changes: 2 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dependencies {
implementation project(':core-api')
implementation Libs.google_tink
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'


androidTestImplementation project(':testUtils')
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.emarsys.core.activity
import android.app.Activity
import com.emarsys.core.activity.ActivityLifecycleAction.ActivityLifecycle.CREATE
import com.emarsys.core.activity.ActivityLifecycleAction.ActivityLifecycle.RESUME
import com.emarsys.core.concurrency.CoreSdkHandlerProvider
import com.emarsys.core.handler.CoreSdkHandler
import com.emarsys.core.concurrency.ConcurrentHandlerHolderFactory
import com.emarsys.core.handler.ConcurrentHandlerHolder
import com.emarsys.core.provider.activity.CurrentActivityProvider
import io.kotlintest.shouldBe
import org.junit.Before
Expand All @@ -15,7 +15,7 @@ import java.util.concurrent.CountDownLatch
class ActivityLifecycleActionRegistryTest {

private lateinit var activityLifecycleActionRegistry: ActivityLifecycleActionRegistry
private lateinit var coreSdkHandler: CoreSdkHandler
private lateinit var concurrentHandlerHolder: ConcurrentHandlerHolder
private lateinit var mockCurrentActivityProvider: CurrentActivityProvider
private lateinit var mockAction1: ActivityLifecycleAction
private lateinit var mockAction2: ActivityLifecycleAction
Expand All @@ -39,10 +39,10 @@ class ActivityLifecycleActionRegistryTest {
on { get() } doReturn mockActivity
}
mockActions = mutableListOf(mockAction1, mockAction2, mockAction3)
coreSdkHandler = CoreSdkHandlerProvider().provideHandler()
concurrentHandlerHolder = ConcurrentHandlerHolderFactory.create()

activityLifecycleActionRegistry = ActivityLifecycleActionRegistry(
coreSdkHandler, mockCurrentActivityProvider, mockActions
concurrentHandlerHolder, mockCurrentActivityProvider, mockActions
)
}

Expand All @@ -54,7 +54,8 @@ class ActivityLifecycleActionRegistryTest {

@Test
fun testConstructor_createEmptyArraysByDefault() {
val emptyActivityLifecycleActionRegistry = ActivityLifecycleActionRegistry(coreSdkHandler, mockCurrentActivityProvider)
val emptyActivityLifecycleActionRegistry =
ActivityLifecycleActionRegistry(concurrentHandlerHolder, mockCurrentActivityProvider)
emptyActivityLifecycleActionRegistry.triggerOnActivityActions.size shouldBe 0
emptyActivityLifecycleActionRegistry.lifecycleActions.size shouldBe 0
}
Expand Down Expand Up @@ -247,7 +248,7 @@ class ActivityLifecycleActionRegistryTest {

private fun waitForCoreSDKThread() {
val latch = CountDownLatch(1)
coreSdkHandler.post {
concurrentHandlerHolder.coreHandler.post {
latch.countDown()
}
latch.await()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.emarsys.core.activity

import android.app.Activity
import com.emarsys.core.concurrency.CoreSdkHandlerProvider
import com.emarsys.core.handler.CoreSdkHandler
import com.emarsys.testUtil.TimeoutUtils
import org.junit.Before
import org.junit.Rule
Expand Down
97 changes: 17 additions & 80 deletions core/src/androidTest/java/com/emarsys/core/api/AsyncProxyTest.kt
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
package com.emarsys.core.api

import android.os.HandlerThread
import com.emarsys.core.concurrency.CoreHandler
import com.emarsys.core.handler.CoreSdkHandler
import com.emarsys.core.concurrency.ConcurrentHandlerHolderFactory
import com.emarsys.core.handler.ConcurrentHandlerHolder
import com.emarsys.testUtil.TimeoutUtils
import com.emarsys.testUtil.mockito.ThreadSpy
import io.kotlintest.shouldBe
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestRule
import java.util.*
import java.util.concurrent.Callable
import java.util.concurrent.CountDownLatch

class AsyncProxyTest {

private lateinit var handler: CoreSdkHandler
private lateinit var concurrentHandlerHolder: ConcurrentHandlerHolder

@Rule
@JvmField
val timeout: TestRule = TimeoutUtils.timeoutRule

@Before
fun setUp() {
val handlerThread = HandlerThread("CoreSDKHandlerThread-" + UUID.randomUUID().toString())
handlerThread.start()
handler = CoreSdkHandler(CoreHandler(handlerThread))
concurrentHandlerHolder = ConcurrentHandlerHolderFactory.create()
}

@Test
fun testInvoke_shouldInvokeMethod() {
val expected: CharSequence = "test"

val result = expected.proxyWithHandler(handler)
val result = expected.proxyWithHandler(concurrentHandlerHolder)

result.toString() shouldBe "test"
}
Expand All @@ -48,7 +44,7 @@ class AsyncProxyTest {
latch.countDown()
}

callback.proxyWithHandler(handler).run()
callback.proxyWithHandler(concurrentHandlerHolder).run()

latch.await()
threadSpy.verifyCalledOnCoreSdkThread()
Expand All @@ -63,86 +59,27 @@ class AsyncProxyTest {
"test"
}

val result = callback.proxyWithHandler(handler).call()
val result = callback.proxyWithHandler(concurrentHandlerHolder).call()

result shouldBe "test"
threadSpy.verifyCalledOnCoreSdkThread()
}

@Test
fun testInvoke_shouldHandlePrimitives_boolean() {
val latch = CountDownLatch(1)
val proxiedTestClass = (TestClassWithPrimitives() as Proxyable).proxyWithHandler(handler, timeout = 1)
var error: Exception? = null
handler.post {
try {
val result = proxiedTestClass.testBoolean()
result shouldBe false
} catch (e: Exception) {
error = e
} finally {
latch.countDown()
}
}
latch.await()
error shouldBe null
}
fun testInvoke_shouldUseCoreThread_whenAlreadyOnCoreThread() {
val threadSpy: ThreadSpy<Any> = ThreadSpy()

@Test
fun testInvoke_shouldHandlePrimitives_double() {
val latch = CountDownLatch(1)
val proxiedTestClass = (TestClassWithPrimitives() as Proxyable).proxyWithHandler(handler, timeout = 1)
var error: Exception? = null
handler.post {
try {
val result = proxiedTestClass.testDouble()
result shouldBe 0.0
} catch (e: Exception) {
error = e
} finally {
latch.countDown()
}
val callback: Callable<String> = Callable<String> {
threadSpy.call()
"test"
}
latch.await()
error shouldBe null
}

@Test
fun testInvoke_shouldHandlePrimitives_char() {
val latch = CountDownLatch(1)
val proxiedTestClass = (TestClassWithPrimitives() as Proxyable).proxyWithHandler(handler, timeout = 1)
var error: Exception? = null
handler.post {
try {
val result = proxiedTestClass.testChar()
result shouldBe Char(0)
} catch (e: Exception) {
error = e
} finally {
latch.countDown()
}
concurrentHandlerHolder.coreHandler.post {
val result = callback.proxyWithHandler(concurrentHandlerHolder).call()
result shouldBe "test"
latch.countDown()
}
latch.await()
error shouldBe null
}
}

interface Proxyable {
fun testBoolean(): Boolean
fun testDouble(): Double
fun testChar(): Char
}

class TestClassWithPrimitives : Proxyable {
override fun testBoolean(): Boolean {
return true
}

override fun testDouble(): Double {
return 1.0
}

override fun testChar(): Char {
return Char(123)
threadSpy.verifyCalledOnCoreSdkThread()
}
}
Loading

0 comments on commit d1384b3

Please sign in to comment.