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

Commit 04f7623a authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Fix kotlin warnings in FrameworksServicesTests" into main

parents de63603e 8e11b654
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")