-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
873 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.1.0 | ||
5.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
.../src/androidTest/java/com/snowplowanalytics/snowplow/event/ApplicationInstallEventTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (c) 2015-2023 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
* This program is licensed to you under the Apache License Version 2.0, | ||
* and you may not use this file except in compliance with the Apache License Version 2.0. | ||
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the Apache License Version 2.0 is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. | ||
*/ | ||
package com.snowplowanalytics.snowplow.event | ||
|
||
import android.content.Context | ||
import androidx.preference.PreferenceManager | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.snowplowanalytics.snowplow.Snowplow.createTracker | ||
import com.snowplowanalytics.snowplow.configuration.* | ||
import com.snowplowanalytics.snowplow.controller.TrackerController | ||
import com.snowplowanalytics.snowplow.network.HttpMethod | ||
import com.snowplowanalytics.snowplow.tracker.MockNetworkConnection | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ApplicationInstallEventTest { | ||
|
||
@Before | ||
fun setUp() { | ||
cleanSharedPreferences() | ||
} | ||
|
||
// Tests | ||
@Test | ||
fun testTracksInstallEventOnFirstLaunch() { | ||
// plugin to check if event was tracked | ||
var eventTracked = false | ||
val plugin = PluginConfiguration("testPlugin") | ||
plugin.afterTrack { eventTracked = true } | ||
|
||
// create tracker with install autotracking | ||
val trackerConfiguration = TrackerConfiguration("appId") | ||
.installAutotracking(true) | ||
createTracker(listOf(trackerConfiguration, plugin)) | ||
|
||
Thread.sleep(500) | ||
|
||
// check if event was tracked | ||
Assert.assertTrue(eventTracked) | ||
} | ||
|
||
@Test | ||
fun testDoesntTrackInstallEventIfPreviouslyTracked() { | ||
// plugin to check if event was tracked | ||
var eventTracked = false | ||
val plugin = PluginConfiguration("testPlugin") | ||
plugin.afterTrack { eventTracked = true } | ||
|
||
// create tracker with install autotracking | ||
val trackerConfiguration = TrackerConfiguration("appId") | ||
.installAutotracking(true) | ||
createTracker(listOf(trackerConfiguration, plugin)) | ||
|
||
Thread.sleep(500) | ||
|
||
// check if event was tracked | ||
Assert.assertTrue(eventTracked) | ||
|
||
// reset flag | ||
eventTracked = false | ||
|
||
// create tracker again | ||
createTracker(listOf(trackerConfiguration, plugin)) | ||
|
||
Thread.sleep(500) | ||
|
||
// check if event was tracked | ||
Assert.assertFalse(eventTracked) | ||
} | ||
|
||
private fun cleanSharedPreferences() { | ||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) | ||
sharedPreferences.edit().clear().commit() | ||
} | ||
|
||
private fun createTracker(configurations: List<Configuration>): TrackerController { | ||
val networkConfig = NetworkConfiguration(MockNetworkConnection(HttpMethod.POST, 200)) | ||
return createTracker( | ||
context, | ||
namespace = "ns" + Math.random().toString(), | ||
network = networkConfig, | ||
configurations = configurations.toTypedArray() | ||
) | ||
} | ||
|
||
private val context: Context | ||
get() = InstrumentationRegistry.getInstrumentation().targetContext | ||
} |
87 changes: 0 additions & 87 deletions
87
...acker/src/androidTest/java/com/snowplowanalytics/snowplow/event/ApplicationInstallTest.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.