Merge "Expose the netd mock in CSTest to allow verifying calls on it" into main

This commit is contained in:
Jean Chalard
2023-10-10 04:17:29 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 10 deletions

View File

@@ -127,6 +127,7 @@ open class CSTest {
val packageManager = makeMockPackageManager()
val connResources = makeMockConnResources(sysResources, packageManager)
val netd = mock<INetd>()
val bpfNetMaps = mock<BpfNetMaps>()
val clatCoordinator = mock<ClatCoordinator>()
val proxyTracker = ProxyTracker(context, mock<Handler>(), 16 /* EVENT_PROXY_HAS_CHANGED */)
@@ -138,7 +139,7 @@ open class CSTest {
}
val deps = CSDeps()
val service = makeConnectivityService(context, deps).also { it.systemReadyInternal() }
val service = makeConnectivityService(context, netd, deps).also { it.systemReadyInternal() }
val cm = ConnectivityManager(context, service)
val csHandler = Handler(csHandlerThread.looper)

View File

@@ -145,12 +145,13 @@ internal fun initMockedResources(res: Resources) {
private val TEST_LINGER_DELAY_MS = 400
private val TEST_NASCENT_DELAY_MS = 300
internal fun makeConnectivityService(context: Context, deps: Dependencies) = ConnectivityService(
context,
mock<IDnsResolver>(),
mock<IpConnectivityLog>(),
mock<INetd>(),
deps).also {
it.mLingerDelayMs = TEST_LINGER_DELAY_MS
it.mNascentDelayMs = TEST_NASCENT_DELAY_MS
}
internal fun makeConnectivityService(context: Context, netd: INetd, deps: Dependencies) =
ConnectivityService(
context,
mock<IDnsResolver>(),
mock<IpConnectivityLog>(),
netd,
deps).also {
it.mLingerDelayMs = TEST_LINGER_DELAY_MS
it.mNascentDelayMs = TEST_NASCENT_DELAY_MS
}