Skip to content

Commit

Permalink
Add more sleeping
Browse files Browse the repository at this point in the history
  • Loading branch information
mscwilson committed Apr 17, 2024
1 parent ddd0959 commit f6e49ea
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ApplicationInstallEventTest {
.installAutotracking(true)
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(2000)
Thread.sleep(2500)

// check if event was tracked
Assert.assertTrue(eventTracked)
Expand All @@ -78,7 +78,7 @@ class ApplicationInstallEventTest {
// create tracker again
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(2000)
Thread.sleep(2500)

// check if event was tracked
Assert.assertFalse(eventTracked)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class StateManagerTest {

// Send events
tracker.track(Timing("category", "variable", 123))
Thread.sleep(1000)
Thread.sleep(1500)
if (eventStore.lastInsertedRow == -1L) Assert.fail()
var payload = eventStore.db[eventStore.lastInsertedRow]
eventStore.removeAllEvents()
Expand All @@ -238,7 +238,7 @@ class StateManagerTest {
.toTypedArray().size - 1).toLong())

tracker.track(Background())
Thread.sleep(1000)
Thread.sleep(1500)
if (eventStore.lastInsertedRow == -1L) Assert.fail()
payload = eventStore.db[eventStore.lastInsertedRow]
eventStore.removeAllEvents()
Expand All @@ -249,7 +249,7 @@ class StateManagerTest {
.toTypedArray().size - 1).toLong())

tracker.track(ScreenView("screen1"))
Thread.sleep(1000)
Thread.sleep(1500)
if (eventStore.lastInsertedRow == -1L) Assert.fail()
payload = eventStore.db[eventStore.lastInsertedRow]
eventStore.removeAllEvents()
Expand All @@ -260,7 +260,7 @@ class StateManagerTest {
.toTypedArray().size - 1).toLong())

tracker.track(Foreground().foregroundIndex(9))
Thread.sleep(1000)
Thread.sleep(1500)
if (eventStore.lastInsertedRow == -1L) Assert.fail()
payload = eventStore.db[eventStore.lastInsertedRow]
eventStore.removeAllEvents()
Expand All @@ -273,7 +273,7 @@ class StateManagerTest {
.toTypedArray().size - 1).toLong())

tracker.track(ScreenView("screen1"))
Thread.sleep(1000)
Thread.sleep(1500)
if (eventStore.lastInsertedRow == -1L) Assert.fail()
payload = eventStore.db[eventStore.lastInsertedRow]
eventStore.removeAllEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class TestMediaController {
)
media?.track(MediaPlayEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
assertEquals(eventSchema("play"), firstEvent.schema)
Expand All @@ -102,7 +102,7 @@ class TestMediaController {
)
media?.track(MediaEndEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
assertEquals(eventSchema("end"), firstEvent.schema)
Expand All @@ -119,7 +119,7 @@ class TestMediaController {
media?.track(event = MediaSeekEndEvent(), player = MediaPlayerEntity(currentTime = 2.0))
media?.track(event = MediaSeekStartEvent(), player = MediaPlayerEntity(currentTime = 3.0))

Thread.sleep(200)
Thread.sleep(400)

assertEquals(3, trackedEvents.size)
assertEquals(2, trackedEvents.filter { it.schema == eventSchema("seek_start") }.size)
Expand All @@ -136,7 +136,7 @@ class TestMediaController {
media?.track(MediaPlayEvent())
media?.track(MediaPauseEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
assertEquals(eventSchema("play"), firstEvent.schema)
Expand All @@ -154,7 +154,7 @@ class TestMediaController {

media?.track(MediaPlayEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
assertNotNull(
Expand All @@ -178,7 +178,7 @@ class TestMediaController {
)
)

Thread.sleep(300)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
assertNotNull(
Expand All @@ -199,7 +199,7 @@ class TestMediaController {
media?.track(MediaPlaybackRateChangeEvent(newRate = 1.5))
media?.track(MediaPauseEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals(2, trackedEvents.size)
val rateEvent = trackedEvents.find { it.schema == eventSchema("playback_rate_change") }
Expand All @@ -219,7 +219,7 @@ class TestMediaController {
media?.track(MediaVolumeChangeEvent(newVolume = 90))
media?.track(MediaPauseEvent())

Thread.sleep(250)
Thread.sleep(400)

assertEquals(2, trackedEvents.size)
val volumeEvent = trackedEvents.find { it.schema == eventSchema("volume_change") }
Expand All @@ -238,7 +238,7 @@ class TestMediaController {

media?.track(MediaFullscreenChangeEvent(fullscreen = true))

Thread.sleep(300)
Thread.sleep(400)

assertEquals(true, firstEvent.payload.get("fullscreen"))
assertEquals(true, firstPlayer?.get("fullscreen"))
Expand All @@ -253,7 +253,7 @@ class TestMediaController {

media?.track(MediaPictureInPictureChangeEvent(pictureInPicture = true))

Thread.sleep(200)
Thread.sleep(400)

assertEquals(true, firstEvent.payload.get("pictureInPicture"))
assertEquals(true, firstPlayer?.get("pictureInPicture"))
Expand All @@ -265,7 +265,7 @@ class TestMediaController {

media?.track(MediaAdFirstQuartileEvent())

Thread.sleep(300)
Thread.sleep(400)

assertEquals(25, firstEvent.payload.get("percentProgress"))
}
Expand All @@ -276,7 +276,7 @@ class TestMediaController {

media?.track(MediaAdMidpointEvent())

Thread.sleep(300)
Thread.sleep(400)

assertEquals(50, firstEvent.payload.get("percentProgress"))
}
Expand All @@ -287,7 +287,7 @@ class TestMediaController {

media?.track(MediaAdThirdQuartileEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals(75, firstEvent.payload.get("percentProgress"))
}
Expand Down Expand Up @@ -326,7 +326,7 @@ class TestMediaController {
framesPerSecond = 60
))

Thread.sleep(200)
Thread.sleep(400)

assertEquals("720p", firstEvent.payload.get("previousQuality"))
assertEquals("1080p", firstEvent.payload.get("newQuality"))
Expand All @@ -344,7 +344,7 @@ class TestMediaController {
errorDescription = "Failed to load media"
))

Thread.sleep(200)
Thread.sleep(400)

assertEquals("501", firstEvent.payload.get("errorCode"))
assertEquals("forbidden", firstEvent.payload.get("errorName"))
Expand All @@ -363,7 +363,7 @@ class TestMediaController {
mapOf("url" to "https://www.youtube.com/watch?v=12345")
))

Thread.sleep(200)
Thread.sleep(400)

assertEquals("iglu:com.acme/video_played/jsonschema/1-0-0", firstEvent.schema)
assertEquals("Video", firstPlayer?.get("label"))
Expand All @@ -377,7 +377,7 @@ class TestMediaController {

media?.track(MediaPlayEvent())

Thread.sleep(200)
Thread.sleep(400)

assertEquals("media1", firstSession?.get("mediaSessionId"))
}
Expand All @@ -401,7 +401,7 @@ class TestMediaController {
media.update(player = MediaPlayerEntity(currentTime = 10.0))
media.track(MediaEndEvent())

Thread.sleep(300)
Thread.sleep(400)

val endEvent = trackedEvents.find { it.schema == eventSchema("end") }
val lastSession = endEvent?.entities?.find { it.map.get("schema") == sessionSchema }?.map?.get("data") as? Map<*, *>
Expand All @@ -427,7 +427,7 @@ class TestMediaController {

timer.fire()

Thread.sleep(300)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
assertEquals(10000L, timer.delay)
Expand All @@ -452,7 +452,7 @@ class TestMediaController {
media.track(MediaPauseEvent())
timer.fire()

Thread.sleep(200)
Thread.sleep(400)

assertEquals(4, trackedEvents.size)
}
Expand All @@ -475,7 +475,7 @@ class TestMediaController {
timer.fire()
}

Thread.sleep(200)
Thread.sleep(400)

assertEquals(2, trackedEvents.size)
}
Expand All @@ -498,7 +498,7 @@ class TestMediaController {
timer.fire()
}

Thread.sleep(200)
Thread.sleep(400)

assertEquals(5, trackedEvents.size)
}
Expand Down Expand Up @@ -562,7 +562,7 @@ class TestMediaController {
media?.update(player = MediaPlayerEntity(currentTime = i.toDouble()))
}

Thread.sleep(200)
Thread.sleep(400)

assertEquals(1, trackedEvents.size)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ class PluginsTest {
var event2HasEntity: Boolean? = null

val testPlugin = PluginConfiguration("test")
testPlugin.afterTrack {
if (it.schema == "schema1") {
event1HasEntity = it.entities.filter { it.map["schema"] == "xx" }.isNotEmpty()
testPlugin.afterTrack { event ->
if (event.schema == "schema1") {
event1HasEntity = event.entities.filter { it.map["schema"] == "xx" }.isNotEmpty()
}
if (it.schema == "schema2") {
event2HasEntity = it.entities.filter { it.map["schema"] == "xx" }.isNotEmpty()
if (event.schema == "schema2") {
event2HasEntity = event.entities.filter { it.map["schema"] == "xx" }.isNotEmpty()
}
}

val tracker = createTracker(listOf(plugin, testPlugin))
tracker.track(SelfDescribing("schema1", emptyMap()))
tracker.track(SelfDescribing("schema2", emptyMap()))

Thread.sleep(200)
Thread.sleep(400)
Assert.assertTrue(event1HasEntity!!)
Assert.assertFalse(event2HasEntity!!)
}
Expand All @@ -135,7 +135,7 @@ class PluginsTest {
tracker.track(SelfDescribing("schema2", emptyMap()))
tracker.track(Structured("cat", "act"))

Thread.sleep(200)
Thread.sleep(400)
Assert.assertTrue(event1Called)
Assert.assertFalse(event2Called)
Assert.assertFalse(event3Called)
Expand Down

0 comments on commit f6e49ea

Please sign in to comment.