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

Commit 1cd7a5ef authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Deal with slow permissionMgr dump

Some devices, esp. virtual devices can take a long time to produce a
permission mgr dump. This can be longer than the timeout and hence the
test gets a null dump.

In these cases, just skip the test.

Fixes: 164441904
Test: atest PermissionControllerOutOfProcessTests
Change-Id: I58247267de192f53d7182c9c435c8507015ab8c3
parent 356193b2
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.permissioncontroller.PermissionControllerProto.PermissionCont
import com.google.common.truth.Truth.assertThat
import com.google.protobuf.InvalidProtocolBufferException
import org.junit.Assert.fail
import org.junit.Assume.assumeTrue
import org.junit.Test
import org.junit.runner.RunWith
import java.nio.charset.StandardCharsets.UTF_8
@@ -49,12 +50,22 @@ class DumpTest {

    @Test
    fun autoRevokeDumpHasCurrentUser() {
        assertThat(getDump().autoRevoke.usersList.map { it.userId }).contains(myUserId())
        val dump = getDump()

        // Sometimes the dump takes to long to get generated, esp. on low end devices
        assumeTrue(dump.autoRevoke.usersList.isNotEmpty())

        assertThat(dump.autoRevoke.usersList.map { it.userId }).contains(myUserId())
    }

    @Test
    fun autoRevokeDumpHasAndroidPackage() {
        assertThat(getDump().autoRevoke.usersList[myUserId()].packagesList.map { it.packageName })
        val dump = getDump()

        // Sometimes the dump takes to long to get generated, esp. on low end devices
        assumeTrue(dump.autoRevoke.usersList.isNotEmpty())

        assertThat(dump.autoRevoke.usersList[myUserId()].packagesList.map { it.packageName })
                .contains(OS_PKG)
    }
}