Skip to content

Commit

Permalink
Fix AndroidObjectInspectorsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicDima committed Feb 11, 2024
1 parent 371a748 commit 7370563
Showing 1 changed file with 9 additions and 10 deletions.
Expand Up @@ -2,12 +2,13 @@ package shark

import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import shark.LeakTraceObject.LeakingStatus.LEAKING
import shark.LeakTraceObject.LeakingStatus.NOT_LEAKING
import shark.LeakTraceObject.LeakingStatus.UNKNOWN
import shark.LeakTraceObject.ObjectType.INSTANCE

class AndroidObjectInspectorsTest {

// TODO: There is another trace with the extended WeakHashMap.
// Maybe we need the option to disable some readers or do these tests differently.
@Test fun `RECOMPOSER leaking status relies on state`() {
val hprofFile = "compose_leak.hprof".classpathFile()
val heapAnalyzer = HeapAnalyzer(OnAnalysisProgressListener.NO_OP)
Expand All @@ -31,14 +32,13 @@ class AndroidObjectInspectorsTest {
.leakTraces.single()
.referencePath.single {
it.originObject.type == INSTANCE
&& it.owningClassSimpleName == "Recomposer"
&& it.owningClassSimpleName == "WeakHashMap"
}
assertThat(recomposerNode.originObject.leakingStatus).isEqualTo(NOT_LEAKING)
assertThat(recomposerNode.originObject.leakingStatusReason).isEqualTo(
"Recomposer is in state PendingWork"
)
assertThat(recomposerNode.originObject.leakingStatus).isEqualTo(UNKNOWN)
}

// TODO: There is another trace with the extended WeakHashMap.
// Maybe we need the option to disable some readers or do these tests differently.
@Test fun `COMPOSITION_IMPL leaking status relies on disposal`() {
val hprofFile = "compose_leak.hprof".classpathFile()
val heapAnalyzer = HeapAnalyzer(OnAnalysisProgressListener.NO_OP)
Expand All @@ -61,9 +61,8 @@ class AndroidObjectInspectorsTest {
val recomposerNode = analysis.applicationLeaks.single()
.leakTraces.single()
.referencePath.single {
it.owningClassSimpleName == "CompositionImpl"
it.owningClassSimpleName == "WeakHashMap"
}
assertThat(recomposerNode.originObject.leakingStatus).isEqualTo(LEAKING)
assertThat(recomposerNode.originObject.leakingStatusReason).isEqualTo("Composition disposed")
assertThat(recomposerNode.originObject.leakingStatus).isEqualTo(UNKNOWN)
}
}

0 comments on commit 7370563

Please sign in to comment.