Skip to content

Commit c3cae26

Browse files
committed
Issue mozilla-mobile#2346: Fix warnings in concept-engine.
1 parent e573e39 commit c3cae26

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

buildSrc/src/main/java/KotlinCompiler.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ object KotlinCompiler {
2323
"browser-search",
2424
"browser-storage-sync",
2525
"browser-toolbar",
26-
"concept-engine",
2726
"concept-toolbar",
2827
"feature-accounts",
2928
"feature-awesomebar",

components/concept/engine/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
api project(':support-base')
3636
api project(':browser-errorpages')
3737

38+
testImplementation Dependencies.androidx_test_core
3839
testImplementation Dependencies.testing_junit
3940
testImplementation Dependencies.testing_robolectric
4041
testImplementation Dependencies.testing_mockito

components/concept/engine/src/test/java/mozilla/components/concept/engine/EngineViewTest.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ package mozilla.components.concept.engine
77
import android.content.Context
88
import android.graphics.Bitmap
99
import android.widget.FrameLayout
10+
import androidx.test.core.app.ApplicationProvider
1011
import org.junit.Assert.assertTrue
1112
import org.junit.Test
1213
import org.junit.runner.RunWith
1314
import org.mockito.Mockito.spy
1415
import org.mockito.Mockito.verify
1516
import org.robolectric.RobolectricTestRunner
16-
import org.robolectric.RuntimeEnvironment
1717
import java.lang.ClassCastException
1818

1919
@RunWith(RobolectricTestRunner::class)
2020
class EngineViewTest {
21+
private val context: Context
22+
get() = ApplicationProvider.getApplicationContext()
23+
2124
@Test
2225
fun `asView method returns underlying Android view`() {
23-
val engineView = createDummyEngineView(RuntimeEnvironment.application)
26+
val engineView = createDummyEngineView(context)
2427

2528
val view = engineView.asView()
2629

@@ -35,7 +38,7 @@ class EngineViewTest {
3538

3639
@Test
3740
fun lifecycleObserver() {
38-
val engineView = spy(createDummyEngineView(RuntimeEnvironment.application))
41+
val engineView = spy(createDummyEngineView(context))
3942
val observer = LifecycleObserver(engineView)
4043

4144
observer.onCreate()
@@ -59,7 +62,7 @@ class EngineViewTest {
5962

6063
private fun createDummyEngineView(context: Context): EngineView = DummyEngineView(context)
6164

62-
open class DummyEngineView(context: Context?) : FrameLayout(context), EngineView {
65+
open class DummyEngineView(context: Context) : FrameLayout(context), EngineView {
6366
override fun captureThumbnail(onFinish: (Bitmap?) -> Unit) = Unit
6467
override fun render(session: EngineSession) {}
6568
}

components/concept/engine/src/test/java/mozilla/components/concept/engine/request/RequestInterceptorTest.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@ class RequestInterceptorTest {
1919
val urlResponse = InterceptionResponse.Url("https://mozilla.org")
2020
val contentReponse = InterceptionResponse.Content("data")
2121

22-
var url: String = when (urlResponse) {
23-
is InterceptionResponse.Url -> urlResponse.url
24-
else -> ""
25-
}
26-
var content: Triple<String, String, String> = when (contentReponse) {
27-
is InterceptionResponse.Content ->
28-
Triple(contentReponse.data, contentReponse.encoding, contentReponse.mimeType)
29-
else -> Triple("", "", "")
30-
}
22+
val url: String = urlResponse.url
23+
24+
val content: Triple<String, String, String> =
25+
Triple(contentReponse.data, contentReponse.encoding, contentReponse.mimeType)
3126

3227
assertEquals("https://mozilla.org", url)
3328
assertEquals(Triple("data", "UTF-8", "text/html"), content)

0 commit comments

Comments
 (0)