Skip to content

Commit aa36db8

Browse files
committed
test: add failing tests for filtered SSIDs persisting in time graph
1 parent 727346e commit aa36db8

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/timegraph/DataManagerTest.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,47 @@ class DataManagerTest {
155155
verify(timeGraphCache).active()
156156
}
157157

158+
@Test
159+
fun newSeriesShouldNotIncludeActiveCacheEntriesNotInCurrentWiFiDetails() {
160+
// Expected: newSeries includes currentDetails and only those active cache
161+
// entries that satisfy the given predicate. Entries from timeGraphCache.active()
162+
// that do not match the predicate (e.g. filtered-out SSIDs) must be excluded.
163+
// setup
164+
val currentDetails: Set<WiFiDetail> = makeWiFiDetails().toSet()
165+
val staleEntries: Set<WiFiDetail> = makeMoreWiFiDetails().toSet()
166+
whenever(timeGraphCache.active()).thenReturn(staleEntries)
167+
// execute
168+
val actual = fixture.newSeries(currentDetails)
169+
// validate: current entries must be present, stale entries must NOT leak in
170+
assertThat(actual).containsAll(currentDetails)
171+
assertThat(actual).doesNotContainAnyElementsOf(staleEntries)
172+
verify(timeGraphCache).active()
173+
}
174+
175+
@Test
176+
fun adjustDataShouldNotAppendToStaleCacheEntriesNotInCurrentDetails() {
177+
// Expected: adjustData only appends floor data points and increments the
178+
// TimeGraphCache counter for differenceSeries entries that satisfy the
179+
// given predicate. Entries that do not match must be left untouched.
180+
// setup
181+
val currentDetails: Set<WiFiDetail> = makeWiFiDetails().toSet()
182+
val staleEntry: WiFiDetail = makeWiFiDetail("SSID4")
183+
whenever(graphViewWrapper.differenceSeries(currentDetails))
184+
.thenReturn(listOf(staleEntry))
185+
// execute
186+
fixture.adjustData(graphViewWrapper, currentDetails)
187+
// validate: stale entries must NOT receive floor data points
188+
verify(graphViewWrapper, never()).appendToSeries(
189+
eq(staleEntry),
190+
any(),
191+
any(),
192+
any(),
193+
)
194+
// validate: stale entries must NOT be added to the time graph cache
195+
verify(timeGraphCache, never()).add(staleEntry)
196+
verify(timeGraphCache).clear()
197+
}
198+
158199
@Test
159200
fun addDataToExistingSeries() {
160201
// setup

0 commit comments

Comments
 (0)