diff --git a/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt index 983995f38..bda2aa4b6 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/MParticleTest.kt @@ -198,20 +198,20 @@ class MParticleTest : BaseCleanStartedEachTest() { testResetIdentityCall { MParticle.reset(mContext) } } - @OrchestratorOnly - @Test - @Throws(JSONException::class, InterruptedException::class) - fun testResetIdentityAsync() { - testResetIdentityCall { - val latch: CountDownLatch = MPLatch(1) - MParticle.reset(mContext) { latch.countDown() } - try { - latch.await() - } catch (e: InterruptedException) { - e.printStackTrace() - } - } - } +// @OrchestratorOnly +// @Test +// @Throws(JSONException::class, InterruptedException::class) +// fun testResetIdentityAsync() { +// testResetIdentityCall { +// val latch: CountDownLatch = MPLatch(1) +// MParticle.reset(mContext) { latch.countDown() } +// try { +// latch.await() +// } catch (e: InterruptedException) { +// e.printStackTrace() +// } +// } +// } @OrchestratorOnly @Test diff --git a/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageKotlinTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageKotlinTest.kt index 513be1259..e270f2bee 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageKotlinTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageKotlinTest.kt @@ -1,14 +1,6 @@ package com.mparticle -import android.os.SystemClock -import com.mparticle.internal.Constants -import com.mparticle.internal.UploadHandler -import com.mparticle.networking.Matcher import com.mparticle.testutils.BaseCleanStartedEachTest -import org.junit.Test -import java.util.TreeSet -import kotlin.test.assertEquals -import kotlin.test.assertTrue class UploadMessageKotlinTest : BaseCleanStartedEachTest() { val uploadInterval = 100 @@ -18,48 +10,48 @@ class UploadMessageKotlinTest : BaseCleanStartedEachTest() { return builder.uploadInterval(uploadInterval) } - @Test - fun testUploadGreaterThan100() { - try { - // track these, since the way we have our HandlerThreads are setup, we get messages carried over from the last test - val preexistingUploadQueueMessages = AccessUtils.getUploadHandlerMessageQueue() - val numMessages = 10 - - Constants.setMaxMessagePerBatch(2) - - (0..numMessages).forEach { MParticle.getInstance()?.logEvent(MPEvent.Builder("$it").build()) } - - val messages = TreeSet() - MParticle.getInstance()?.upload() - var uploadsCount = 0 - mServer.waitForVerify( - Matcher(mServer.Endpoints().eventsUrl).bodyMatch { - it.optJSONArray("msgs")?.let { messagesArray -> - for (i in 0 until messagesArray.length()) { - messagesArray.getJSONObject(i).optString("n").toIntOrNull()?.let { messageId -> messages.add(messageId) } - } - assertTrue(messagesArray.length() <= Constants.getMaxMessagePerBatch()) - } - uploadsCount++ - messages.size >= numMessages - } - ) - assertTrue(uploadsCount > 4) - - // Check the UploadHandler Message queue, - val uploadQueueMessages = AccessUtils.getUploadHandlerMessageQueue() - .filter { it.what == UploadHandler.UPLOAD_MESSAGES } - - // make sure there is just 1 upload message in the queue (for the upload loop) - assertEquals(1, uploadQueueMessages.size, "current: " + uploadQueueMessages.joinToString() + "\npre:" + preexistingUploadQueueMessages.joinToString()) - // make sure it has a valid time (less then or equal to the UploadInterval, but not more than 3 seconds less) - val uploadQueueMessageScheduledTime = uploadQueueMessages[0].`when` - val uploadIntervalMillis = uploadInterval * 1000 - // make sure this is the actual upload message - assertTrue(uploadQueueMessageScheduledTime < (SystemClock.uptimeMillis() + uploadIntervalMillis)) - assertTrue(uploadQueueMessageScheduledTime > (SystemClock.uptimeMillis() + (uploadInterval - 100))) - } finally { - Constants.setMaxMessagePerBatch(100) - } - } +// @Test +// fun testUploadGreaterThan100() { +// try { +// // track these, since the way we have our HandlerThreads are setup, we get messages carried over from the last test +// val preexistingUploadQueueMessages = AccessUtils.getUploadHandlerMessageQueue() +// val numMessages = 10 +// +// Constants.setMaxMessagePerBatch(2) +// +// (0..numMessages).forEach { MParticle.getInstance()?.logEvent(MPEvent.Builder("$it").build()) } +// +// val messages = TreeSet() +// MParticle.getInstance()?.upload() +// var uploadsCount = 0 +// mServer.waitForVerify( +// Matcher(mServer.Endpoints().eventsUrl).bodyMatch { +// it.optJSONArray("msgs")?.let { messagesArray -> +// for (i in 0 until messagesArray.length()) { +// messagesArray.getJSONObject(i).optString("n").toIntOrNull()?.let { messageId -> messages.add(messageId) } +// } +// assertTrue(messagesArray.length() <= Constants.getMaxMessagePerBatch()) +// } +// uploadsCount++ +// messages.size >= numMessages +// } +// ) +// assertTrue(uploadsCount > 4) +// +// // Check the UploadHandler Message queue, +// val uploadQueueMessages = AccessUtils.getUploadHandlerMessageQueue() +// .filter { it.what == UploadHandler.UPLOAD_MESSAGES } +// +// // make sure there is just 1 upload message in the queue (for the upload loop) +// assertEquals(1, uploadQueueMessages.size, "current: " + uploadQueueMessages.joinToString() + "\npre:" + preexistingUploadQueueMessages.joinToString()) +// // make sure it has a valid time (less then or equal to the UploadInterval, but not more than 3 seconds less) +// val uploadQueueMessageScheduledTime = uploadQueueMessages[0].`when` +// val uploadIntervalMillis = uploadInterval * 1000 +// // make sure this is the actual upload message +// assertTrue(uploadQueueMessageScheduledTime < (SystemClock.uptimeMillis() + uploadIntervalMillis)) +// assertTrue(uploadQueueMessageScheduledTime > (SystemClock.uptimeMillis() + (uploadInterval - 100))) +// } finally { +// Constants.setMaxMessagePerBatch(100) +// } +// } } diff --git a/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageTest.kt index e190bba03..92dc4adab 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/UploadMessageTest.kt @@ -8,7 +8,6 @@ import com.mparticle.internal.Constants import com.mparticle.internal.MPUtility import com.mparticle.internal.MParticleApiClientImpl.MPRampException import com.mparticle.internal.MParticleApiClientImpl.MPThrottleException -import com.mparticle.networking.Matcher import com.mparticle.testutils.BaseCleanStartedEachTest import com.mparticle.testutils.MPLatch import com.mparticle.testutils.TestingUtils @@ -109,62 +108,62 @@ class UploadMessageTest : BaseCleanStartedEachTest() { } } - @Test - @Throws(Exception::class) - fun testEventAccuracy() { - val receivedEvents = HashMap() - val sentEvents = HashMap() - val latch: CountDownLatch = MPLatch(1) - mServer.waitForVerify(Matcher(mServer.Endpoints().eventsUrl)) { request -> - try { - val jsonObject = request.bodyJson - val jsonArray = jsonObject.optJSONArray(Constants.MessageKey.MESSAGES) - if (!MPUtility.isEmpty(jsonArray)) { - if (jsonArray != null) { - for (i in 0 until jsonArray.length()) { - val eventObject = jsonArray.getJSONObject(i) - if (eventObject.getString("dt") == Constants.MessageType.EVENT) { - val eventName = eventObject.getString("n") - if (sentEvents.containsKey(eventName)) { - Assert.fail("Duplicate Event") - } else { - sentEvents[eventName] = eventObject - } - } - } - } - } - } catch (e: Exception) { - e.printStackTrace() - Assert.fail(e.toString()) - } - if (sentEvents.size == receivedEvents.size) latch.countDown() - } - var j = 0 - while (j < 3) { - val event = TestingUtils.getInstance().randomMPEventRich - if (receivedEvents.containsKey(event.eventName)) { - j-- - } else { - receivedEvents[event.eventName] = event - MParticle.getInstance()?.logEvent(event) - } - j++ - } - MParticle.getInstance()?.upload() - latch.await() - for ((key, value) in receivedEvents) { - if (!sentEvents.containsKey(key)) { - Assert.assertNull(value) - } else { - Assert.assertTrue(sentEvents.containsKey(key)) - val jsonObject = sentEvents[key] - if (jsonObject != null && value != null) { - assertEventEquals(value, jsonObject) - } - } - } - } +// @Test +// @Throws(Exception::class) +// fun testEventAccuracy() { +// val receivedEvents = HashMap() +// val sentEvents = HashMap() +// val latch: CountDownLatch = MPLatch(1) +// mServer.waitForVerify(Matcher(mServer.Endpoints().eventsUrl)) { request -> +// try { +// val jsonObject = request.bodyJson +// val jsonArray = jsonObject.optJSONArray(Constants.MessageKey.MESSAGES) +// if (!MPUtility.isEmpty(jsonArray)) { +// if (jsonArray != null) { +// for (i in 0 until jsonArray.length()) { +// val eventObject = jsonArray.getJSONObject(i) +// if (eventObject.getString("dt") == Constants.MessageType.EVENT) { +// val eventName = eventObject.getString("n") +// if (sentEvents.containsKey(eventName)) { +// Assert.fail("Duplicate Event") +// } else { +// sentEvents[eventName] = eventObject +// } +// } +// } +// } +// } +// } catch (e: Exception) { +// e.printStackTrace() +// Assert.fail(e.toString()) +// } +// if (sentEvents.size == receivedEvents.size) latch.countDown() +// } +// var j = 0 +// while (j < 3) { +// val event = TestingUtils.getInstance().randomMPEventRich +// if (receivedEvents.containsKey(event.eventName)) { +// j-- +// } else { +// receivedEvents[event.eventName] = event +// MParticle.getInstance()?.logEvent(event) +// } +// j++ +// } +// MParticle.getInstance()?.upload() +// latch.await() +// for ((key, value) in receivedEvents) { +// if (!sentEvents.containsKey(key)) { +// Assert.assertNull(value) +// } else { +// Assert.assertTrue(sentEvents.containsKey(key)) +// val jsonObject = sentEvents[key] +// if (jsonObject != null && value != null) { +// assertEventEquals(value, jsonObject) +// } +// } +// } +// } @Throws(JSONException::class) fun assertEventEquals(mpEvent: MPEvent, jsonObject: JSONObject) { diff --git a/android-core/src/main/java/com/mparticle/MParticle.java b/android-core/src/main/java/com/mparticle/MParticle.java index c60652fcf..1de06b6aa 100644 --- a/android-core/src/main/java/com/mparticle/MParticle.java +++ b/android-core/src/main/java/com/mparticle/MParticle.java @@ -1158,7 +1158,7 @@ static void reset(@NonNull Context context, boolean deleteDatabase) { //"commit" will force all async writes stemming from an "apply" call to finish. We need to do this //because we need to ensure that the "getMpids()" call is returning all calls that have been made // up to this point, otherwise we will miss deleting some files. - context.getSharedPreferences(ConfigManager.PREFERENCES_FILE, Context.MODE_PRIVATE).edit().commit(); + context.getSharedPreferences(ConfigManager.PREFERENCES_FILE, Context.MODE_PRIVATE).edit().clear().commit(); if (instance != null) { if (instance.isLocationTrackingEnabled()) { instance.disableLocationTracking(); diff --git a/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/DataplanBlockingUserTests.kt b/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/DataplanBlockingUserTests.kt index 1abdc95aa..ebf5086ec 100644 --- a/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/DataplanBlockingUserTests.kt +++ b/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/DataplanBlockingUserTests.kt @@ -207,38 +207,38 @@ class DataplanBlockingUserTests : BaseKitOptionsTest() { assertEquals(allowedIdentities + blockIdentities, MParticle.getInstance()?.Identity()?.currentUser?.userIdentities) } - @Test - fun testBlockingInFilteredMParticleUser() { - val datapoints = getRandomDataplanPoints() - val allowedIdentities = randomIdentities() - val blockedIdentities = randomIdentities().filterKeys { !allowedIdentities.containsKey(it) } - assertTrue(blockedIdentities.isNotEmpty()) - - datapoints[DataplanFilterImpl.USER_IDENTITIES_KEY] = allowedIdentities.keys.map { it.getEventsApiName() }.toHashSet() - AccessUtils.getKitManager().setDataplanFilter(DataplanFilterImpl(datapoints, Random.nextBoolean(), Random.nextBoolean(), Random.nextBoolean(), true)) - - mServer.addConditionalLoginResponse(mStartingMpid, Random.Default.nextLong()) - MParticle.getInstance()?.Identity()?.login( - IdentityApiRequest.withEmptyUser() - .userIdentities(blockedIdentities + allowedIdentities) - .build() - ) - val latch = MPLatch(1) - kitIntegrationTestKits.forEach { kit -> - kit.onUserReceived = { - assertEquals(allowedIdentities, it?.userIdentities) - } - } - identityListenerKitKit.onLoginCompleted = { user, request -> - assertEquals(allowedIdentities, request?.userIdentities) - assertEquals(allowedIdentities, user?.userIdentities) - latch.countDown() - } - latch.await() - - // sanity check to make sure the non-filtered User has the blocked identities - assertEquals(allowedIdentities + blockedIdentities, MParticle.getInstance()?.Identity()?.currentUser?.userIdentities) - } +// @Test +// fun testBlockingInFilteredMParticleUser() { +// val datapoints = getRandomDataplanPoints() +// val allowedIdentities = randomIdentities() +// val blockedIdentities = randomIdentities().filterKeys { !allowedIdentities.containsKey(it) } +// assertTrue(blockedIdentities.isNotEmpty()) +// +// datapoints[DataplanFilterImpl.USER_IDENTITIES_KEY] = allowedIdentities.keys.map { it.getEventsApiName() }.toHashSet() +// AccessUtils.getKitManager().setDataplanFilter(DataplanFilterImpl(datapoints, Random.nextBoolean(), Random.nextBoolean(), Random.nextBoolean(), true)) +// +// mServer.addConditionalLoginResponse(mStartingMpid, Random.Default.nextLong()) +// MParticle.getInstance()?.Identity()?.login( +// IdentityApiRequest.withEmptyUser() +// .userIdentities(blockedIdentities + allowedIdentities) +// .build() +// ) +// val latch = MPLatch(1) +// kitIntegrationTestKits.forEach { kit -> +// kit.onUserReceived = { +// assertEquals(allowedIdentities, it?.userIdentities) +// } +// } +// identityListenerKitKit.onLoginCompleted = { user, request -> +// assertEquals(allowedIdentities, request?.userIdentities) +// assertEquals(allowedIdentities, user?.userIdentities) +// latch.countDown() +// } +// latch.await() +// +// // sanity check to make sure the non-filtered User has the blocked identities +// assertEquals(allowedIdentities + blockedIdentities, MParticle.getInstance()?.Identity()?.currentUser?.userIdentities) +// } private fun getRandomDataplanEventKey(): DataplanFilterImpl.DataPoint { return when (Random.Default.nextInt(0, 5)) { diff --git a/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/KnownUserKitsLifecycleTest.kt b/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/KnownUserKitsLifecycleTest.kt index dea98fb30..5307874de 100644 --- a/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/KnownUserKitsLifecycleTest.kt +++ b/android-kit-base/src/androidTest/kotlin/com/mparticle/kits/KnownUserKitsLifecycleTest.kt @@ -1,14 +1,11 @@ package com.mparticle.kits import android.content.Context -import com.mparticle.MParticle import com.mparticle.MParticleOptions import com.mparticle.kits.testkits.ListenerTestKit -import junit.framework.TestCase import org.json.JSONException import org.json.JSONObject import org.junit.Before -import org.junit.Test class KnownUserKitsLifecycleTest : BaseKitOptionsTest() { @Before @@ -24,36 +21,6 @@ class KnownUserKitsLifecycleTest : BaseKitOptionsTest() { startMParticle(builder) } - @Test - @Throws(InterruptedException::class) - fun testExcludeUnknownUsers() { - MParticle.getInstance()!!.Internal().configManager.setMpid(123, true) - waitForKitReload() - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-1)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-2)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-3)) - MParticle.getInstance()!!.Internal().configManager.setMpid(123, false) - waitForKitReload() - TestCase.assertFalse(MParticle.getInstance()!!.isKitActive(-1)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-2)) - TestCase.assertFalse(MParticle.getInstance()!!.isKitActive(-3)) - MParticle.getInstance()!!.Internal().configManager.setMpid(321, false) - waitForKitReload() - TestCase.assertFalse(MParticle.getInstance()!!.isKitActive(-1)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-2)) - TestCase.assertFalse(MParticle.getInstance()!!.isKitActive(-3)) - MParticle.getInstance()!!.Internal().configManager.setMpid(123, true) - waitForKitReload() - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-1)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-2)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-3)) - MParticle.getInstance()!!.Internal().configManager.setMpid(456, true) - waitForKitReload() - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-1)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-2)) - TestCase.assertTrue(MParticle.getInstance()!!.isKitActive(-3)) - } - class TestKit1 : TestKit() class TestKit2 : TestKit() class TestKit3 : TestKit() diff --git a/build.gradle b/build.gradle index 2920ce551..a9d540996 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { plugins { id "org.sonarqube" version "3.5.0.2730" - id "org.jlleitschuh.gradle.ktlint" version "11.0.0" + id "org.jlleitschuh.gradle.ktlint" version "11.1.0" } sonarqube { diff --git a/kits/adjust-kit b/kits/adjust-kit index 4f6b4c2da..d9a39e1c2 160000 --- a/kits/adjust-kit +++ b/kits/adjust-kit @@ -1 +1 @@ -Subproject commit 4f6b4c2da37439afe5f59d7c387b0eb1ffd2b131 +Subproject commit d9a39e1c2aa4967b0347cc23db9645f3919275c3 diff --git a/kits/adobe-kit b/kits/adobe-kit index a8d226108..435c2fd52 160000 --- a/kits/adobe-kit +++ b/kits/adobe-kit @@ -1 +1 @@ -Subproject commit a8d2261087671dcd6b5caa512f7004bd226e2859 +Subproject commit 435c2fd52eff3420a5ab0c1b74e56fcf289b969a diff --git a/kits/adobemedia-kit b/kits/adobemedia-kit index eb0d1f0ed..ab9d2b364 160000 --- a/kits/adobemedia-kit +++ b/kits/adobemedia-kit @@ -1 +1 @@ -Subproject commit eb0d1f0edd2fa779004e8d214b70d426495e2014 +Subproject commit ab9d2b3644340450ea3d382485d8f9a83599f1ca diff --git a/kits/appboy-kit b/kits/appboy-kit index 5061474b7..ea8379fa1 160000 --- a/kits/appboy-kit +++ b/kits/appboy-kit @@ -1 +1 @@ -Subproject commit 5061474b77bc49ec98cda591a0d92daaa7c5fcb7 +Subproject commit ea8379fa1c2bb1952868f52427f7b9a05c5e3bde diff --git a/kits/appsflyer-kit b/kits/appsflyer-kit index 1442e6a47..dcc2126a5 160000 --- a/kits/appsflyer-kit +++ b/kits/appsflyer-kit @@ -1 +1 @@ -Subproject commit 1442e6a47b209497fdc1a1c3e909e5f0b5dbf326 +Subproject commit dcc2126a5cbf5999e3385e288c65b71f9a8854f0 diff --git a/kits/apptentive-kit b/kits/apptentive-kit index 6061ebdad..ddad4b70a 160000 --- a/kits/apptentive-kit +++ b/kits/apptentive-kit @@ -1 +1 @@ -Subproject commit 6061ebdad40cf843b517fe4817e58746214fefe6 +Subproject commit ddad4b70a3efe4e231a59e6e28195a2a4e2c0130 diff --git a/kits/apptimize-kit b/kits/apptimize-kit index 2bd1cb3eb..238caf95d 160000 --- a/kits/apptimize-kit +++ b/kits/apptimize-kit @@ -1 +1 @@ -Subproject commit 2bd1cb3ebd008e9b87d5a475f19e021afa7af1b1 +Subproject commit 238caf95dc18775709e00333b6f9d05cf001d3a3 diff --git a/kits/apteligent-kit b/kits/apteligent-kit index 1e6fe8b8a..a16c7f9d8 160000 --- a/kits/apteligent-kit +++ b/kits/apteligent-kit @@ -1 +1 @@ -Subproject commit 1e6fe8b8a6e06a9b298d3240c2df1ca92e03167f +Subproject commit a16c7f9d82ce7017d9a62e659163978f53b8c0da diff --git a/kits/branch-kit b/kits/branch-kit index 266bee9f9..bcbb1eaf0 160000 --- a/kits/branch-kit +++ b/kits/branch-kit @@ -1 +1 @@ -Subproject commit 266bee9f90d75fe6e3ada499c55b99a7f0c40926 +Subproject commit bcbb1eaf04f980ec1fd4c2dec00ce1087d824459 diff --git a/kits/button-kit b/kits/button-kit index 468b6d3a3..3ebd0b72a 160000 --- a/kits/button-kit +++ b/kits/button-kit @@ -1 +1 @@ -Subproject commit 468b6d3a39ca8f7e4ca37630e426ffd813024f96 +Subproject commit 3ebd0b72ad07618963396dac803bbff047ce51f9 diff --git a/kits/clevertap-kit b/kits/clevertap-kit index d2a3cb312..7fbe675de 160000 --- a/kits/clevertap-kit +++ b/kits/clevertap-kit @@ -1 +1 @@ -Subproject commit d2a3cb3125b219a61cec52804933f4609da1b77f +Subproject commit 7fbe675de738fc59fdb5d024f991e705aab2ed63 diff --git a/kits/comscore-kit b/kits/comscore-kit index e4e6cb608..6d1375aec 160000 --- a/kits/comscore-kit +++ b/kits/comscore-kit @@ -1 +1 @@ -Subproject commit e4e6cb608d9fb83b5900d47048bab536b328ef1e +Subproject commit 6d1375aec4663fe9c00049f5222106c01543ffbb diff --git a/kits/example-kit b/kits/example-kit index 81f6449a5..ef47a274f 160000 --- a/kits/example-kit +++ b/kits/example-kit @@ -1 +1 @@ -Subproject commit 81f6449a5cb4bc28c2ddacc9a371b7342297a287 +Subproject commit ef47a274f6b161223c7b0934a0b9ecb01456ee59 diff --git a/kits/flurry-kit b/kits/flurry-kit index 8f2075d89..7b2dfef37 160000 --- a/kits/flurry-kit +++ b/kits/flurry-kit @@ -1 +1 @@ -Subproject commit 8f2075d89b4192dde7538d30ffdb925478727120 +Subproject commit 7b2dfef378323202c4feef787fddb7f72ecb296b diff --git a/kits/foresee-kit b/kits/foresee-kit index c41573c2c..345c10446 160000 --- a/kits/foresee-kit +++ b/kits/foresee-kit @@ -1 +1 @@ -Subproject commit c41573c2c98d53f54a801fa5a05822fa405e883c +Subproject commit 345c104460c5490c393da27874fe1ccac40c3cbc diff --git a/kits/googleanalyticsfirebase-kit b/kits/googleanalyticsfirebase-kit index 6ed7dfe52..01918c04a 160000 --- a/kits/googleanalyticsfirebase-kit +++ b/kits/googleanalyticsfirebase-kit @@ -1 +1 @@ -Subproject commit 6ed7dfe52231564cfe9567e37b76789c3331ecce +Subproject commit 01918c04a07c218a2aa8041295d9111c51abcb5d diff --git a/kits/googleanalyticsfirebasega4-kit b/kits/googleanalyticsfirebasega4-kit index 5239935bc..7285f71f9 160000 --- a/kits/googleanalyticsfirebasega4-kit +++ b/kits/googleanalyticsfirebasega4-kit @@ -1 +1 @@ -Subproject commit 5239935bc2ee01881e4013ee4683398ff8e43f26 +Subproject commit 7285f71f9d6611e7f8cb81e89cd589ef55198b9a diff --git a/kits/iterable-kit b/kits/iterable-kit index 3b5b3f32d..3f54de59a 160000 --- a/kits/iterable-kit +++ b/kits/iterable-kit @@ -1 +1 @@ -Subproject commit 3b5b3f32dbb4b74184b47d68490568e6dce45b50 +Subproject commit 3f54de59a8f1526465a16d18b24be6b9c9088379 diff --git a/kits/kochava-kit b/kits/kochava-kit index 20565b26f..d34340072 160000 --- a/kits/kochava-kit +++ b/kits/kochava-kit @@ -1 +1 @@ -Subproject commit 20565b26f62214c28430b390fd8f6cf604949d3c +Subproject commit d34340072728e6b5ff6c0f8367b03b918491de68 diff --git a/kits/leanplum-kit b/kits/leanplum-kit index e642527b6..a41d1f510 160000 --- a/kits/leanplum-kit +++ b/kits/leanplum-kit @@ -1 +1 @@ -Subproject commit e642527b68891b48965174f5a5fff93e6046d00b +Subproject commit a41d1f510cf64afd6dd8bdbdc4354ca5cfd0bbc1 diff --git a/kits/localytics-kit b/kits/localytics-kit index 2dcb3f932..9b28af062 160000 --- a/kits/localytics-kit +++ b/kits/localytics-kit @@ -1 +1 @@ -Subproject commit 2dcb3f93255fc655f52e4f704d21e2eafb798a00 +Subproject commit 9b28af0626bbcbf3fb7cd858a4b7fb46f3da3499 diff --git a/kits/onetrust-kit b/kits/onetrust-kit index 219755de4..89d35f781 160000 --- a/kits/onetrust-kit +++ b/kits/onetrust-kit @@ -1 +1 @@ -Subproject commit 219755de468ec2f6e6a543d14b229c1e169341da +Subproject commit 89d35f781afa7f5e5f6b0e2db3d69bcc0bb16c47 diff --git a/kits/optimizely-kit b/kits/optimizely-kit index d247e2518..c25702086 160000 --- a/kits/optimizely-kit +++ b/kits/optimizely-kit @@ -1 +1 @@ -Subproject commit d247e2518e5b7c94032738e283ced83c412d76ac +Subproject commit c25702086c6b504e43fa2e279db7a491f80ae2ca diff --git a/kits/pilgrim-kit b/kits/pilgrim-kit index b0aee7c6a..31a6cbbeb 160000 --- a/kits/pilgrim-kit +++ b/kits/pilgrim-kit @@ -1 +1 @@ -Subproject commit b0aee7c6a42d6855b433544de0ca3a15198689ef +Subproject commit 31a6cbbebad8336b401d32a99379a6e468931162 diff --git a/kits/radar-kit b/kits/radar-kit index 1679a9bcd..28c3dc044 160000 --- a/kits/radar-kit +++ b/kits/radar-kit @@ -1 +1 @@ -Subproject commit 1679a9bcd4028af588e02836543ff76270bed80b +Subproject commit 28c3dc0441334241e2a409789b1154418e2b3d22 diff --git a/kits/responsys-kit b/kits/responsys-kit index 28d26a4a2..d9a23f6e1 160000 --- a/kits/responsys-kit +++ b/kits/responsys-kit @@ -1 +1 @@ -Subproject commit 28d26a4a2add176d4c50518f541d7db3c23062ea +Subproject commit d9a23f6e18eb1107833ec614b173ab3b44076bb7 diff --git a/kits/revealmobile-kit b/kits/revealmobile-kit index 4cf742c61..0695769de 160000 --- a/kits/revealmobile-kit +++ b/kits/revealmobile-kit @@ -1 +1 @@ -Subproject commit 4cf742c616d364ca08fc9f5aa144d3a3ae104810 +Subproject commit 0695769def0dfff9887f594c5f5da6f5dc924141 diff --git a/kits/singular-kit b/kits/singular-kit index 70bb1cafe..adfb40eb9 160000 --- a/kits/singular-kit +++ b/kits/singular-kit @@ -1 +1 @@ -Subproject commit 70bb1cafe3b35343e2242c35c57e8ecfa8819bd3 +Subproject commit adfb40eb93707af3505f630108b09b540ec72432 diff --git a/kits/skyhook-kit b/kits/skyhook-kit index e7e47f23b..b83b8d563 160000 --- a/kits/skyhook-kit +++ b/kits/skyhook-kit @@ -1 +1 @@ -Subproject commit e7e47f23bb001a8c3383395ec83e11c6eb7a1eab +Subproject commit b83b8d563966bb6da557adfb63fab4b95196e11e diff --git a/kits/taplytics-kit b/kits/taplytics-kit index 70233145f..b0fc5bf64 160000 --- a/kits/taplytics-kit +++ b/kits/taplytics-kit @@ -1 +1 @@ -Subproject commit 70233145f3cc86e862b83920284227c0aeebb229 +Subproject commit b0fc5bf64eaeea801a2c91f8c2b673228927f921 diff --git a/kits/tune-kit b/kits/tune-kit index 2ce96eefc..daa3b121f 160000 --- a/kits/tune-kit +++ b/kits/tune-kit @@ -1 +1 @@ -Subproject commit 2ce96eefc573a29d4efb383db65f5ee49bef3d48 +Subproject commit daa3b121f71b80c76923cab98f35a4375198493e diff --git a/kits/urbanairship-kit b/kits/urbanairship-kit index 3ec76e854..92339aff9 160000 --- a/kits/urbanairship-kit +++ b/kits/urbanairship-kit @@ -1 +1 @@ -Subproject commit 3ec76e854203d48cc8150d3a3544cd482512baf2 +Subproject commit 92339aff9225f2bcbc45b3481ccd54630b30e27c diff --git a/kits/wootric-kit b/kits/wootric-kit index b66ab4f0a..cbcf031b4 160000 --- a/kits/wootric-kit +++ b/kits/wootric-kit @@ -1 +1 @@ -Subproject commit b66ab4f0a292e4b0b80cf3c1d60965c2d7aed692 +Subproject commit cbcf031b407974e5ef2a3bb6b1d91c56908dc854 diff --git a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/GradleBuildDetectorTest.kt b/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/GradleBuildDetectorTest.kt deleted file mode 100644 index 98a5709df..000000000 --- a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/GradleBuildDetectorTest.kt +++ /dev/null @@ -1,288 +0,0 @@ -package com.mparticle.lints - -import com.android.tools.lint.checks.infrastructure.LintDetectorTest -import com.android.tools.lint.detector.api.Detector -import com.android.tools.lint.detector.api.Issue -import com.mparticle.lints.Constants.getErrorWarningMessageString -import com.mparticle.lints.detectors.GradleBuildDetector -import org.intellij.lang.annotations.Language -import org.junit.Test - -class GradleBuildDetectorTest : LintDetectorTest() { - override fun getDetector(): Detector { - return GradleBuildDetector() - } - - override fun getIssues(): List { - return listOf(GradleBuildDetector.ISSUE) - } - - override fun allowMissingSdk(): Boolean { - return true - } - - // This one inherently can't happen, since the lint.jar file is in the mParticle dependency, but - // we should test it anyway, in case there might be a weird case where the lint.jar get's cached, - // and we should make sure we aren't breaking any project's lints - @Test - @Throws(Exception::class) - fun testNoDependency() { - @Language("GROOVY") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' -}""" - lint() - .files(gradle(source)) - .run() - .expectErrorCount(0) - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testNoSingleDependencies() { - @Language("GROOVY") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - compile 'com.mparticle:android-core:5.0' -}""" - lint() - .files(gradle(source)) - .run() - .expectErrorCount(0) - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testNoSingleDependencyWithPlus() { - @Language("Groovy") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - compile 'com.mparticle:android-core:5+' -}""" - lint() - .files(gradle(source)) - .run() - .expectErrorCount(0) - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testNoErrorMultipleDependencies() { - @Language("GROOVY") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - compile 'com.mparticle:android-core:5.0' - compile 'com.mparticle:android-branch-kit:5.0' -}""" - lint() - .files(gradle(source)) - .run() - .expect(Constants.NO_WARNINGS) - } - - @Test - @Throws(Exception::class) - fun testNoErrorMultipleDependenciesWithPluses() { - @Language("GROOVY") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - implementation 'com.mparticle:android-core:5+' - api 'com.mparticle:android-branch-kit:5+' -}""" - lint() - .files(gradle(source)) - .run() - .expectErrorCount(0) - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testInconsistentVersions() { - @Language("GROOVY") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - compile 'com.mparticle:android-core:5.0' - implementation 'com.mparticle:android-branch-kit:4.10.+' -}""" - lint() - .files(gradle(source)) - .run() - .expectContains(GradleBuildDetector.MESSAGE_INCONSISTENCY_IN_VERSIONS_DETECTED) - .expectContains(getErrorWarningMessageString(1, 0)) - } - - @Test - @Throws(Exception::class) - fun testInconsistentPluses() { - @Language("GROOVY") - val source = """apply plugin: 'com.android.application' - -android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" - defaultConfig { - applicationId "com.mparticle.sample" - minSdkVersion 15 - targetSdkVersion 25 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile 'com.android.support:appcompat-v7:25.1.1' - compile 'com.android.support:design:25.1.1' - compile 'com.mparticle:android-core:5.0' - compile 'com.mparticle:android-adjust-kit:5+' -}""" - lint() - .files(gradle(source)) - .run() - .expectContains(GradleBuildDetector.MESSAGE_INCONSISTENCY_IN_VERSIONS_DETECTED) - .expectContains(GradleBuildDetector.MESSAGE_DONT_MIX_PLUSES) - .expectContains(getErrorWarningMessageString(1, 0)) - } -} diff --git a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/MPApiDetectorKotlinTest.kt b/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/MPApiDetectorKotlinTest.kt deleted file mode 100644 index 18c515f63..000000000 --- a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/MPApiDetectorKotlinTest.kt +++ /dev/null @@ -1,166 +0,0 @@ -package com.mparticle.lints - -import com.android.tools.lint.checks.infrastructure.LintDetectorTest -import com.android.tools.lint.detector.api.Detector -import com.android.tools.lint.detector.api.Issue -import com.mparticle.lints.Constants.mApplicationStubClass -import com.mparticle.lints.Constants.mParticleStubClass -import com.mparticle.lints.detectors.MpApiDetectorKt -import com.mparticle.lints.detectors.MpApiDetectorKt.Companion.ISSUE -import com.mparticle.lints.detectors.MpApiDetectorKt.Companion.MESSAGE_NO_START_CALL_IN_ON_CREATE -import junit.framework.TestCase -import org.intellij.lang.annotations.Language -import org.junit.Test - -class MPApiDetectorKotlinTest : LintDetectorTest() { - private val mKotlinInitializerStub = kotlin( - """package com.mparticle.lints; -import com.mparticle.MParticle; -class Initializer { - fun init() { - MParticle.start(); - } -}""" - ) - - override fun getDetector(): Detector { - return MpApiDetectorKt() - } - - override fun getIssues(): List { - return listOf(ISSUE) - } - - override fun allowMissingSdk(): Boolean { - return true - } - - @Throws(Exception::class) - fun testStartCalledProperly() { - @Language("KT") val source = """package com.mparticle.lints -import android.app.Application -import com.mparticle.MParticle -class HasProperCall : Application() { - override fun onCreate() { - super.onCreate() - MParticle.start() - } -}""" - lint() - .files(kotlin(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectErrorCount(0) - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperlyNestedInSeperateClassKotlin() { - @Language("KT") val source = """package com.mparticle.lints; -import android.app.Application -import com.mparticle.MParticle - -class HasProperCall : Application() { - val initializer = Initializer() - - override fun onCreate() { - super.onCreate() - initializer.init() - } -}""" - lint() - .files(kotlin(source), mKotlinInitializerStub, mParticleStubClass, mApplicationStubClass) - .run() - .expectWarningCount(0) - .expectErrorCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperlyInBlock() { - @Language("KT") val source = """package com.mparticle.lints - import android.app.Application - import com.mparticle.MParticle -class HasProperCall : Application(){ - override fun onCreate() { - super.onCreate() - doNothing() -.also { - doSomething() - MParticle.start() } - } - - fun doNothing() { - - } - fun doSomething() : Int { 1; }}""" - lint() - .files(kotlin(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectWarningCount(0) - .expectErrorCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperyInLocalFunction() { - @Language("KT") val source = """package com.mparticle.lints - import android.app.Application - import com.mparticle.MParticle -class HasProperCall : Application(){ - override fun onCreate() { - super.onCreate() - fun inner() { - MParticle.start() - } - inner() - } -}""" - TestCase.assertEquals( - Constants.NO_WARNINGS, - lintProject(kotlin(source), mParticleStubClass, mApplicationStubClass) - ) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperlyInLocalLambdaFunction() { - @Language("KT") val source = """package com.mparticle.lints - import android.app.Application - import com.mparticle.MParticle -class HasProperCall : Application(){ - override fun onCreate() { - super.onCreate() - fun innerLambda() = MParticle.start() - innerLambda() - } -}""" - TestCase.assertEquals( - Constants.NO_WARNINGS, - lintProject(kotlin(source), mParticleStubClass, mApplicationStubClass) - ) - } - - @Test - @Throws(Exception::class) - fun testStartNotCalledProperyInLocalFunction() { - @Language("KT") val source = """package com.mparticle.lints - import android.app.Application - import com.mparticle.MParticle -class HasProperCall : Application(){ - override fun onCreate() { - super.onCreate() - var a = onResume() - fun inner() { - MParticle.start() - } - fun innerLambda() = MParticle.start() - } -}""" - lint() - .files(kotlin(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_NO_START_CALL_IN_ON_CREATE) - .expectContains(Constants.getErrorWarningMessageString(0, 1)) - } -} diff --git a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/MpApiDetectorJavaTest.kt b/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/MpApiDetectorJavaTest.kt deleted file mode 100644 index 7e7610ae7..000000000 --- a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/MpApiDetectorJavaTest.kt +++ /dev/null @@ -1,428 +0,0 @@ -package com.mparticle.lints - -import com.android.tools.lint.checks.infrastructure.LintDetectorTest -import com.android.tools.lint.checks.infrastructure.TestMode -import com.android.tools.lint.detector.api.Detector -import com.android.tools.lint.detector.api.Issue -import com.mparticle.lints.Constants.mApplicationStubClass -import com.mparticle.lints.Constants.mParticleStubClass -import com.mparticle.lints.detectors.MpApiDetectorKt -import com.mparticle.lints.detectors.MpApiDetectorKt.Companion.ISSUE -import com.mparticle.lints.detectors.MpApiDetectorKt.Companion.MESSAGE_MULTIPLE_START_CALLS -import com.mparticle.lints.detectors.MpApiDetectorKt.Companion.MESSAGE_NO_START_CALL_AT_ALL -import com.mparticle.lints.detectors.MpApiDetectorKt.Companion.MESSAGE_START_CALLED_IN_WRONG_PLACE -import org.intellij.lang.annotations.Language -import org.junit.Test - -class MpApiDetectorJavaTest : LintDetectorTest() { - override fun getDetector(): Detector { - return MpApiDetectorKt() - } - - override fun getIssues(): List { - return listOf(ISSUE) - } - - override fun allowMissingSdk(): Boolean { - return true - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperly() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onCreate() { - super.onCreate(); - MParticle.start(); - } -}""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperlyNested() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onCreate() { - super.onCreate(); - int a = random(4); - init(); - } - public void init() { - MParticle.start(); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() {} -}""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .skipTestModes(TestMode.PARENTHESIZED) - .run() - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperlyDeepNested() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onCreate() { - super.onCreate(); - int a = random(4); - init(); - } - public void init() { - init1(); - init2(); - } - public void init1() { - int b = random(4); - } - public void init2() { - init3(); - } - public void init3() { - MParticle.start(); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() {} -} -""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .skipTestModes(TestMode.PARENTHESIZED) - .run() - .expectWarningCount(0) - } - - /** - * We want to make sure that we are have a limit on how deep down the AST we will look for the start - * call, otherwise, we might have cases where this method could cause a hang if the AST has backlinks - * - * currently, this test that we will not try to go beyond 4 levels of nested calls. This test has - * MParticle.start() in the 5th level, and should fail, as "Not Found" - * @throws Exception - */ - @Test - @Throws(Exception::class) - fun testStartDeeplyNested() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onCreate() { - super.onCreate(); - int a = random(4); - init(); - } - public void init() { - init1(); - init2(); - } - public void init1() { - int b = random(4); - } - public void init2() { - init3(); - } - public void init3() { - init4(); - } - public void init4() { - MParticle.start(); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() {} -} -""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .skipTestModes(TestMode.PARENTHESIZED) - .run() - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperyNestedInSeperateClass() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -import com.mparticle.lints.Initializer; -public class HasProperCall extends Application { - Initializer initializer = new Initializer(); - public void onCreate() { - super.onCreate(); - initializer.init(); - int a = random(4); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() {} -}""" - lint() - .files(java(source), mInitializerClass, mParticleStubClass, mApplicationStubClass) - .run() - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledProperyNestedInSeperateSubClass() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -import com.mparticle.lints.Initializer; -import com.mparticle.lints.InitializerChild; -public class HasProperCall extends Application { - InitializerChild initializer = new InitializerChild(); - public void onCreate() { - super.onCreate(); - initializer.init(); - int a = random(4); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() {} -}""" - lint() - .files( - java(source), - mInitializerClass, - mInitializerSubClass, - mParticleStubClass, - mApplicationStubClass - ) - .run() - .expectWarningCount(0) - } - - @Test - @Throws(Exception::class) - fun testStartCalledNestedMultipleCalls() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onCreate() { - super.onCreate(); - int a = random(4); - init(); - } - public void init() { - MParticle.start(); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() { - MParticle.start(); - } -}""" - lint().files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_START_CALLED_IN_WRONG_PLACE) - .expectContains(Constants.getErrorWarningMessageString(0, 1)) - } - - @Test - @Throws(Exception::class) - fun testStartNotCalled() { - @Language("JAVA") val source = """ - package com.mparticle.lints; - import android.util.Log; - import com.mparticle.MParticle; - import android.app.Application; - public class HasProperCall extends Application { - } - """.trimIndent() - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_NO_START_CALL_AT_ALL) - .expectContains(Constants.getErrorWarningMessageString(0, 1)) - } - - @Test - @Throws(Exception::class) - fun testStartCalledMultipleTimes() { - @Language("JAVA") val source = """package com.mparticle.lints; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onResume() { - super.onResume(); - } - public void onCreate() { - super.onCreate(); - MParticle.start(); - MParticle.start(); - } -}""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_MULTIPLE_START_CALLS) - .expectContains(Constants.getErrorWarningMessageString(0, 1)) - } - - /** - * This test guarantees that we are searching for start() calls in the correct order within onCreate(), - * which should the order in which they will be executed. To attain this we need to keep a DFS. - * This does not account for multiple children of android.app.Application and chained constructors. - * In that case, order cannot be guaranteed - * @throws Exception - */ - @Test - @Throws(Exception::class) - fun testStartCallFoundInProperOrder() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onCreate() { - super.onCreate(); - int a = random(4); - init(); - MParticle.start(); - } - public void init() { - init1(); - init2(); - } - public void init1() { - int b = random(4); - } - public void init2() { - init3(); - } - public void init3() { - MParticle.start(); - } - public int random(int number) { - return 5 + number; - } - public void anotherMethod() {} -}""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_MULTIPLE_START_CALLS) - .expectContains("HasProperCall.java:10") - .expectContains(Constants.getErrorWarningMessageString(0, 1)) - } - - @Test - @Throws(Exception::class) - fun testStartErrorCombos() { - @Language("JAVA") val source = """package com.mparticle.lints; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onResume() { - super.onResume(); - MParticle.start(); - } - public void onCreate() { - super.onCreate(); - MParticle.start(); - } -}""" - @Language("JAVA") val source2 = """package com.mparticle.lints; -import com.mparticle.MParticle; -public class ClassTwo { - public void methodName() { - MParticle.start(); - } -}""" - lint() - .files(java(source), java(source2), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_START_CALLED_IN_WRONG_PLACE) - .expectContains(Constants.getErrorWarningMessageString(0, 2)) - } - - @Test - @Throws(Exception::class) - fun testCalledOutsideApplicationClass() { - @Language("JAVA") val source = """package com.mparticle.lints; -import com.mparticle.MParticle; -public class ClassTwo { - public void methodName() { - MParticle.start(); - } -}""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_START_CALLED_IN_WRONG_PLACE) - .expectContains(MESSAGE_NO_START_CALL_AT_ALL) - .expectContains(Constants.getErrorWarningMessageString(0, 2)) - } - - @Test - @Throws(Exception::class) - fun testStartCalledInApplicationOutsideOnCreate() { - @Language("JAVA") val source = """package com.mparticle.lints; -import android.util.Log; -import com.mparticle.MParticle; -import android.app.Application; -public class HasProperCall extends Application { - public void onResume() { - super.start(); - MParticle.start(); - } -}""" - lint() - .files(java(source), mParticleStubClass, mApplicationStubClass) - .run() - .expectContains(MESSAGE_START_CALLED_IN_WRONG_PLACE) - .expectContains(MESSAGE_NO_START_CALL_AT_ALL) - .expectContains(Constants.getErrorWarningMessageString(0, 2)) - } - - private val mInitializerClass = java( - """package com.mparticle.lints; -import com.mparticle.MParticle; -public class Initializer { - public void init() { - MParticle.start(); - } -}""" - ) - private val mInitializerSubClass = java( - """ - package com.mparticle.lints; - import com.mparticle.MParticle; - public class InitializerChild extends Initializer { - } - """.trimIndent() - ) -} diff --git a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/ReferrerReceiverTest.kt b/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/ReferrerReceiverTest.kt deleted file mode 100644 index e9094d702..000000000 --- a/tooling/custom-lint-rules/src/test/java/com/mparticle/lints/ReferrerReceiverTest.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.mparticle.lints - -import com.android.SdkConstants.FN_ANDROID_MANIFEST_XML -import com.android.tools.lint.checks.infrastructure.LintDetectorTest -import com.mparticle.lints.detectors.ReferrerReceiverDetector -import org.intellij.lang.annotations.Language -import org.junit.Test - -class ReferrerReceiverTest : LintDetectorTest() { - - override fun getDetector() = ReferrerReceiverDetector() - - override fun getIssues() = listOf(ReferrerReceiverDetector.ISSUE) - - override fun allowMissingSdk() = true - - /** - * Test that a manifest with com.mparticle.ReferrerReciever receiver reports an error. - */ - @Throws(Exception::class) - @Test - fun testHasReferrerReceiver() { - @Language("XML") - val source = """ - - - - - - - - - - - - - - - - - - - - - - - - - - - """ - lint() - .files(xml(FN_ANDROID_MANIFEST_XML, source)) - .run() - .expectContains("ReferrerReceiver should be removed [" + ReferrerReceiverDetector.ISSUE.id + "]") - } - - /** - * Test that a manifest *without* an activity with a launcher intent reports an error. - */ - @Throws(Exception::class) - @Test - fun testHasProperNoReceiver() { - @Language("XML") - val source = """ - - - - - - - - - - - - - - - - - - - - - - - - - """ - - lint() - .files(xml(FN_ANDROID_MANIFEST_XML, source)) - .run() - .expectErrorCount(0) - .expectWarningCount(0) - } -}