2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] No issue: Removes deprecated usage of InstrumentationRegistry

This commit is contained in:
Sawyer Blatz 2019-08-08 08:54:36 -07:00 committed by Emily Kager
parent 952926509c
commit e4488b1909

View File

@ -9,11 +9,12 @@ import java.io.IOException
import android.net.Uri
import android.os.Handler
import android.os.Looper
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.core.app.ApplicationProvider
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.RecordedRequest
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.helpers.ext.toUri
object MockWebServerHelper {
@ -47,7 +48,7 @@ class AndroidAssetDispatcher : Dispatcher() {
private val mainThreadHandler = Handler(Looper.getMainLooper())
override fun dispatch(request: RecordedRequest): MockResponse {
val assetManager = InstrumentationRegistry.getInstrumentation().targetContext.assets
val assetManager = ApplicationProvider.getApplicationContext<HomeActivity>().assets
val assetContents = try {
val pathNoLeadingSlash = request.path.drop(1)
assetManager.open(pathNoLeadingSlash).use { inputStream ->