Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch more generic exceptions for InstallReferrer (close #647) #681

Merged
merged 6 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ApplicationInstallEventTest {
.installAutotracking(true)
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(1000)
Thread.sleep(1500)

// check if event was tracked
Assert.assertTrue(eventTracked)
Expand All @@ -65,7 +65,7 @@ class ApplicationInstallEventTest {
.installAutotracking(true)
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(1000)
Thread.sleep(1500)

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

Thread.sleep(1000)
Thread.sleep(1500)

// check if event was tracked
Assert.assertFalse(eventTracked)
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(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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

media?.track(MediaPlayEvent())

Thread.sleep(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

assertEquals(2, trackedEvents.size)
val rateEvent = trackedEvents.find { it.schema == eventSchema("playback_rate_change") }
Expand Down Expand Up @@ -238,7 +238,7 @@ class TestMediaController {

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

Thread.sleep(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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

media?.track(MediaAdFirstQuartileEvent())

Thread.sleep(100)
Thread.sleep(200)

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

media?.track(MediaAdMidpointEvent())

Thread.sleep(100)
Thread.sleep(200)

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

media?.track(MediaAdThirdQuartileEvent())

Thread.sleep(100)
Thread.sleep(200)

assertEquals(75, firstEvent.payload.get("percentProgress"))
}
Expand All @@ -301,7 +301,7 @@ class TestMediaController {
media?.track(MediaAdResumeEvent(percentProgress = 40))
media?.track(MediaAdPauseEvent(percentProgress = 50))

Thread.sleep(100)
Thread.sleep(200)

val adClickEvent = trackedEvents.find { it.schema == eventSchema("ad_click") }
assertEquals(15, adClickEvent?.payload?.get("percentProgress"))
Expand All @@ -326,7 +326,7 @@ class TestMediaController {
framesPerSecond = 60
))

Thread.sleep(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

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

Thread.sleep(100)
Thread.sleep(200)

assertEquals(4, trackedEvents.size)
assertEquals(3, trackedEvents.filter { it.schema == eventSchema("percent_progress") }.size)
Expand All @@ -539,7 +539,7 @@ class TestMediaController {
media?.update(player = MediaPlayerEntity(currentTime = i.toDouble()))
}

Thread.sleep(100)
Thread.sleep(200)

assertEquals(2, trackedEvents.size)

Expand All @@ -562,7 +562,7 @@ class TestMediaController {
media?.update(player = MediaPlayerEntity(currentTime = i.toDouble()))
}

Thread.sleep(100)
Thread.sleep(200)

assertEquals(1, trackedEvents.size)
}
Expand All @@ -586,7 +586,7 @@ class TestMediaController {
media?.update(player = MediaPlayerEntity(currentTime = i.toDouble()))
}

Thread.sleep(100)
Thread.sleep(200)

assertEquals(5, trackedEvents.size)
assertEquals(3, trackedEvents.filter { it.schema == eventSchema("percent_progress") }.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PluginsTest {
val tracker = createTracker(listOf(plugin, testPlugin))
tracker.track(Structured("cat", "act"))

Thread.sleep(100)
Thread.sleep(200)
Assert.assertTrue(expectation)
}

Expand All @@ -84,7 +84,7 @@ class PluginsTest {
val tracker = createTracker(listOf(plugin1, plugin2, testPlugin))
tracker.track(ScreenView("sv"))

Thread.sleep(100)
Thread.sleep(200)
Assert.assertTrue(expectation)
}

Expand Down Expand Up @@ -112,7 +112,7 @@ class PluginsTest {
tracker.track(SelfDescribing("schema1", emptyMap()))
tracker.track(SelfDescribing("schema2", emptyMap()))

Thread.sleep(100)
Thread.sleep(200)
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(100)
Thread.sleep(200)
Assert.assertTrue(event1Called)
Assert.assertFalse(event2Called)
Assert.assertFalse(event3Called)
Expand All @@ -156,7 +156,7 @@ class PluginsTest {
tracker.track(SelfDescribing("schema1", emptyMap()))
tracker.track(Structured("cat", "act"))

Thread.sleep(100)
Thread.sleep(200)
Assert.assertTrue(structuredCalled)
Assert.assertFalse(selfDescribingCalled)
}
Expand All @@ -172,7 +172,7 @@ class PluginsTest {

tracker.track(ScreenView("sv"))

Thread.sleep(100)
Thread.sleep(200)
Assert.assertTrue(expectation)
}

Expand All @@ -187,7 +187,7 @@ class PluginsTest {

tracker.track(ScreenView("sv"))

Thread.sleep(100)
Thread.sleep(200)
Assert.assertFalse(pluginCalled)
}

Expand All @@ -203,12 +203,12 @@ class PluginsTest {
val tracker = createTracker(listOf(filterPlugin, afterTrackPlugin))

tracker.track(SelfDescribing("s1", emptyMap()))
Thread.sleep(100)
Thread.sleep(200)

Assert.assertFalse(afterTrackCalled)

tracker.track(SelfDescribing("s2", emptyMap()))
Thread.sleep(100)
Thread.sleep(200)

Assert.assertTrue(afterTrackCalled)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class InstallReferrerDetails(
} catch (_: RemoteException) {
Logger.d(TAG, "Install referrer API remote exception.")
callback(null)
} catch (_: NoSuchMethodError) {
Logger.d(TAG, "Upgrade InstallReferrer package to v1.1 or higher to add the install referrer details entity.")
callback(null)
}
}
InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
Expand All @@ -99,7 +102,7 @@ class InstallReferrerDetails(
})
}

fun isInstallReferrerPackageAvailable(): Boolean {
private fun isInstallReferrerPackageAvailable(): Boolean {
try {
Class.forName("com.android.installreferrer.api.InstallReferrerStateListener")
return true
Expand Down
Loading