Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e11b654 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Fix kotlin warnings in FrameworksServicesTests

And also, enforce these warnings as errors going forward.

Bug: 310014874
Test: atest SystemConfigNamedActorTest
Change-Id: I0b180879335df9f67ffa3d5caf8d29e6de804448
parent 0c9359f2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ android_test {

        "test-apps/SuspendTestApp/src/**/*.java",
    ],

    kotlincflags: [
        "-Werror",
    ],
    static_libs: [
        "frameworks-base-testutils",
        "services.accessibility",
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class OverlayActorEnforcerTests {
        @BeforeClass
        @JvmStatic
        fun checkAllCasesUniquelyNamed() {
            val duplicateCaseNames = CASES.mapIndexed { caseIndex, testCase ->
            val duplicateCaseNames = CASES.mapIndexed { _, testCase ->
                testCase.failures.map {
                    makeTestName(testCase, it.first, Params.Type.FAILURE)
                } + testCase.allowed.map {
+9 −15
Original line number Diff line number Diff line
@@ -18,12 +18,13 @@ package com.android.server.systemconfig

import android.content.Context
import android.util.Xml
import androidx.test.InstrumentationRegistry
import androidx.test.platform.app.InstrumentationRegistry
import com.android.server.SystemConfig
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.TemporaryFolder

class SystemConfigNamedActorTest {
@@ -37,14 +38,11 @@ class SystemConfigNamedActorTest {
        private const val PACKAGE_TWO = "com.test.actor.two"
    }

    private val context: Context = InstrumentationRegistry.getContext()
    private val context: Context = InstrumentationRegistry.getInstrumentation().context

    @get:Rule
    val tempFolder = TemporaryFolder(context.filesDir)

    @get:Rule
    val expected = ExpectedException.none()

    private var uniqueCounter = 0

    @Test
@@ -193,11 +191,9 @@ class SystemConfigNamedActorTest {
            </config>
        """.write()

        expected.expect(IllegalStateException::class.java)
        expected.expectMessage("Defining $ACTOR_ONE as $PACKAGE_ONE " +
        val exc = assertThrows(IllegalStateException::class.java) { assertPermissions() }
        assertEquals(exc.message, "Defining $ACTOR_ONE as $PACKAGE_ONE " +
                "for the android namespace is not allowed")

        assertPermissions()
    }

    @Test
@@ -217,11 +213,9 @@ class SystemConfigNamedActorTest {
            </config>
        """.write()

        expected.expect(IllegalStateException::class.java)
        expected.expectMessage("Duplicate actor definition for $NAMESPACE_TEST/$ACTOR_ONE;" +
        val exc = assertThrows(IllegalStateException::class.java) { assertPermissions() }
        assertEquals(exc.message, "Duplicate actor definition for $NAMESPACE_TEST/$ACTOR_ONE;" +
                " defined as both $PACKAGE_ONE and $PACKAGE_TWO")

        assertPermissions()
    }

    private fun String.write() = tempFolder.root.resolve("${uniqueCounter++}.xml")