mirror of
https://github.com/square/okhttp.git
synced 2025-11-24 18:41:06 +03:00
Test Android with Play provider (#5679)
This commit is contained in:
@@ -23,6 +23,7 @@ import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
import java.net.InetAddress
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.logging.Logger
|
||||
|
||||
/**
|
||||
* Apply this rule to all tests. It adds additional checks for leaked resources and uncaught
|
||||
@@ -35,11 +36,16 @@ class OkHttpClientTestRule : TestRule {
|
||||
private val clientEventsList = mutableListOf<String>()
|
||||
private var testClient: OkHttpClient? = null
|
||||
private var uncaughtException: Throwable? = null
|
||||
var logger: Logger? = null
|
||||
|
||||
fun wrap(eventListener: EventListener) = object : EventListener.Factory {
|
||||
override fun create(call: Call) = ClientRuleEventListener(eventListener) { addEvent(it) }
|
||||
}
|
||||
|
||||
fun wrap(eventListenerFactory: EventListener.Factory) = object : EventListener.Factory {
|
||||
override fun create(call: Call) = ClientRuleEventListener(eventListenerFactory.create(call)) { addEvent(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an OkHttpClient for tests to use as a starting point.
|
||||
*
|
||||
@@ -68,6 +74,7 @@ class OkHttpClientTestRule : TestRule {
|
||||
}
|
||||
|
||||
@Synchronized private fun addEvent(event: String) {
|
||||
logger?.info(event)
|
||||
clientEventsList.add(event)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user