Skip to content

Commit 788482a

Browse files
committed
Move test data classes to their own files
1 parent 339597c commit 788482a

5 files changed

Lines changed: 67 additions & 65 deletions

File tree

embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testcases/features/ActivityFeatureTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import io.embrace.android.embracesdk.assertions.findSpanOfType
66
import io.embrace.android.embracesdk.internal.arch.schema.EmbType
77
import io.embrace.android.embracesdk.internal.clock.nanosToMillis
88
import io.embrace.android.embracesdk.testframework.SdkIntegrationTestRule
9-
import io.embrace.android.embracesdk.testframework.actions.EmbraceActionInterface
9+
import io.embrace.android.embracesdk.testframework.actions.SessionTimestamps
1010
import io.embrace.android.embracesdk.testframework.assertions.assertMatches
1111
import org.junit.Assert.assertEquals
1212
import org.junit.Rule
@@ -24,7 +24,7 @@ internal class ActivityFeatureTest {
2424

2525
@Test
2626
fun `automatically capture activities`() {
27-
var timestamps: EmbraceActionInterface.SessionTimestamps? = null
27+
var timestamps: SessionTimestamps? = null
2828

2929
testRule.runTest(
3030
testCaseAction = {

embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testcases/features/SpanAutoTerminationTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import io.embrace.android.embracesdk.internal.payload.SessionPayload
1010
import io.embrace.android.embracesdk.spans.AutoTerminationMode
1111
import io.embrace.android.embracesdk.spans.EmbraceSpan
1212
import io.embrace.android.embracesdk.testframework.SdkIntegrationTestRule
13-
import io.embrace.android.embracesdk.testframework.actions.EmbraceActionInterface
13+
import io.embrace.android.embracesdk.testframework.actions.SessionTimestamps
1414
import org.junit.Assert.assertEquals
1515
import org.junit.Assert.assertNotNull
1616
import org.junit.Assert.assertNull
@@ -42,8 +42,8 @@ internal class SpanAutoTerminationTest {
4242

4343
@Test
4444
fun `auto termination feature`() {
45-
var firstSessionTimestamps: EmbraceActionInterface.SessionTimestamps? = null
46-
var secondSessionTimestamps: EmbraceActionInterface.SessionTimestamps? = null
45+
var firstSessionTimestamps: SessionTimestamps? = null
46+
var secondSessionTimestamps: SessionTimestamps? = null
4747
testRule.runTest(
4848
instrumentedConfig = FakeInstrumentedConfig(
4949
enabledFeatures = FakeEnabledFeatureConfig(
@@ -123,7 +123,7 @@ internal class SpanAutoTerminationTest {
123123
)
124124
}
125125

126-
private fun EmbraceActionInterface.SessionTimestamps.assertFirstSpans(
126+
private fun SessionTimestamps.assertFirstSpans(
127127
first: Envelope<SessionPayload>,
128128
) {
129129
// startSpan() with children
@@ -167,7 +167,7 @@ internal class SpanAutoTerminationTest {
167167
assertNull(hangingSpan.endTimeNanos)
168168
}
169169

170-
private fun EmbraceActionInterface.SessionTimestamps.assertSecondSpans(
170+
private fun SessionTimestamps.assertSecondSpans(
171171
second: Envelope<SessionPayload>,
172172
) {
173173
val roota = second.findSpanByName(ROOT_HANGING_SPAN)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.embrace.android.embracesdk.testframework.actions
2+
3+
/**
4+
* Timestamps for various events during the simulated execution of an app when we record a session during the integration tests
5+
*/
6+
internal data class AppExecutionTimestamps(
7+
/**
8+
* The time the simulated app execution started.
9+
*/
10+
var executionStartTimeMs: Long = 0L,
11+
12+
/**
13+
* The first time the app was foregrounded during the simulated execution.
14+
*
15+
* It should correspond to the start of the first session.
16+
*/
17+
var firstForegroundTimeMs: Long = 0L,
18+
19+
/**
20+
* The time just before the action within the session is executed for the first session in the execution
21+
*
22+
* This differs from the session creation time (aka foreground time) because some amount of time is ticked off as the app
23+
* goes through the activity lifecycle stages.
24+
*/
25+
var firstActionTimeMs: Long = 0L,
26+
27+
/**
28+
* The last time the app was backgrounded during the execution simulation.
29+
*
30+
* It should correspond to the end of the last session.
31+
*/
32+
var lastBackgroundTimeMs: Long = 0L,
33+
)

embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testframework/actions/EmbraceActionInterface.kt

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -198,64 +198,6 @@ internal class EmbraceActionInterface(
198198
dataSource.handleThermalStateChange(thermalState)
199199
}
200200

201-
/**
202-
* Timestamps for various events during the simulated execution of an app when we record a session during the integration tests
203-
*/
204-
data class SessionTimestamps(
205-
/**
206-
* The time when the session begins
207-
*/
208-
val startTimeMs: Long,
209-
210-
/**
211-
* Time when the session foregrounds. This could differ from [startTimeMs] if the session corresponds to the first session
212-
* of the app instance when background activity is disabled, as the time in the background will be included in the session time.
213-
*/
214-
val foregroundTimeMs: Long,
215-
216-
/**
217-
* The time when the action in the session is invoked
218-
*/
219-
val actionTimeMs: Long,
220-
221-
/**
222-
* The time when the session ended
223-
*/
224-
val endTimeMs: Long,
225-
)
226-
227-
/**
228-
* Timestamps for various events during the simulated execution of an app when we record a session during the integration tests
229-
*/
230-
data class AppExecutionTimestamps(
231-
/**
232-
* The time the simulated app execution started.
233-
*/
234-
var executionStartTimeMs: Long = 0L,
235-
236-
/**
237-
* The first time the app was foregrounded during the simulated execution.
238-
*
239-
* It should correspond to the start of the first session.
240-
*/
241-
var firstForegroundTimeMs: Long = 0L,
242-
243-
/**
244-
* The time just before the action within the session is executed for the first session in the execution
245-
*
246-
* This differs from the session creation time (aka foreground time) because some amount of time is ticked off as the app
247-
* goes through the activity lifecycle stages.
248-
*/
249-
var firstActionTimeMs: Long = 0L,
250-
251-
/**
252-
* The last time the app was backgrounded during the execution simulation.
253-
*
254-
* It should correspond to the end of the last session.
255-
*/
256-
var lastBackgroundTimeMs: Long = 0L,
257-
)
258-
259201
companion object {
260202
const val LIFECYCLE_EVENT_GAP: Long = 10L
261203
const val ACTIVITY_GAP: Long = 100L
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.embrace.android.embracesdk.testframework.actions
2+
3+
/**
4+
* Timestamps for various events during the simulated execution of an app when we record a session during the integration tests
5+
*/
6+
internal data class SessionTimestamps(
7+
/**
8+
* The time when the session begins
9+
*/
10+
val startTimeMs: Long,
11+
12+
/**
13+
* Time when the session foregrounds. This could differ from [startTimeMs] if the session corresponds to the first session
14+
* of the app instance when background activity is disabled, as the time in the background will be included in the session time.
15+
*/
16+
val foregroundTimeMs: Long,
17+
18+
/**
19+
* The time when the action in the session is invoked
20+
*/
21+
val actionTimeMs: Long,
22+
23+
/**
24+
* The time when the session ended
25+
*/
26+
val endTimeMs: Long,
27+
)

0 commit comments

Comments
 (0)