File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
androidTest/java/com/google/firebase/functions
main/java/com/google/firebase/functions Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import com.google.firebase.FirebaseApp
19
19
import com.google.firebase.FirebaseOptions
20
20
import com.google.firebase.functions.FirebaseFunctions.Companion.getInstance
21
21
import junit.framework.TestCase.assertEquals
22
+ import okhttp3.OkHttpClient
22
23
import org.junit.Assert
23
24
import org.junit.Test
24
25
import org.junit.runner.RunWith
@@ -91,6 +92,17 @@ class FirebaseFunctionsTest {
91
92
assertEquals(functions1.getURL(" foo" ).toString(), functions2.getURL(" foo" ).toString())
92
93
}
93
94
95
+ @Test
96
+ fun testSetOkHttpClient () {
97
+ val client = OkHttpClient .Builder ().build()
98
+ val app = getApp(" testSetOkHttpClient" )
99
+ val functions = getInstance(app)
100
+
101
+ functions.setOkHttpClient(client)
102
+
103
+ assertEquals(client, functions.getOkHttpClient())
104
+ }
105
+
94
106
private fun getApp (name : String ): FirebaseApp {
95
107
return FirebaseApp .initializeApp(
96
108
InstrumentationRegistry .getInstrumentation().targetContext,
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ internal constructor(
58
58
@UiThread uiExecutor: Executor
59
59
) {
60
60
// The network client to use for HTTPS requests.
61
- private val client: OkHttpClient = OkHttpClient ()
61
+ private var client: OkHttpClient = OkHttpClient ()
62
62
63
63
// A serializer to encode/decode parameters and return values.
64
64
private val serializer: Serializer = Serializer ()
@@ -311,6 +311,12 @@ internal constructor(
311
311
return tcs.task
312
312
}
313
313
314
+ public fun setOkHttpClient (client : OkHttpClient ) {
315
+ this .client = client
316
+ }
317
+
318
+ public fun getOkHttpClient (): OkHttpClient = this .client
319
+
314
320
public companion object {
315
321
/* * A task that will be resolved once ProviderInstaller has installed what it needs to. */
316
322
private val providerInstalled = TaskCompletionSource <Void >()
You can’t perform that action at this time.
0 commit comments