-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
c91ab5e
commit 16a61f8
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/internal/SdkApiImplTest.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,37 @@ | ||
package io.embrace.android.embracesdk.internal | ||
|
||
import io.embrace.android.embracesdk.fakes.FakeClock | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
internal class SdkApiImplTest { | ||
|
||
private lateinit var fakeClock: FakeClock | ||
private lateinit var sdkApi: SdkApiImpl | ||
|
||
@Before | ||
fun setup() { | ||
fakeClock = FakeClock(currentTime = beforeObjectInitTime) | ||
sdkApi = SdkApiImpl(fakeClock) | ||
} | ||
|
||
@Test | ||
fun `check usage of SDK time`() { | ||
assertEquals(beforeObjectInitTime, sdkApi.getSdkCurrentTime()) | ||
assertTrue(sdkApi.getSdkCurrentTime() < System.currentTimeMillis()) | ||
fakeClock.tick(10L) | ||
assertEquals(fakeClock.now(), sdkApi.getSdkCurrentTime()) | ||
} | ||
|
||
@Test | ||
fun `check default implementation`() { | ||
assertTrue(beforeObjectInitTime < default.getSdkCurrentTime()) | ||
assertTrue(default.getSdkCurrentTime() <= System.currentTimeMillis()) | ||
} | ||
|
||
companion object { | ||
val beforeObjectInitTime = System.currentTimeMillis() - 1 | ||
} | ||
} |