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

Commit 8bbe5f2c authored by Ben Reich's avatar Ben Reich
Browse files

Make the ActivityTestJunit4 more idiomatically kotlin

This was a straight port from Java and some of the conversions were
not exactly clean. This is cleaning some of them up to be more
idiomatically kotlin.

Bug: 407646510
Test: atest DocumentsUIGoogleTests
Flag: EXEMPT test change
Change-Id: I7bd14f3182bb9389fcf75f9d8484c57798004640
parent f9eb5e78
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import com.android.documentsui.base.UserId
import com.android.documentsui.bots.Bots
import com.android.documentsui.files.FilesActivity
import java.io.IOException
import java.util.Objects
import org.junit.After
import org.junit.Before

@@ -78,6 +77,7 @@ abstract class ActivityTestJunit4<T : Activity?> {

    @JvmField
    protected var mDocsHelper: DocumentsProviderHelper? = null

    @JvmField
    protected var mActivityScenario: ActivityScenario<T?>? = null
    private var initialScreenOffTimeoutValue: String? = null
@@ -105,14 +105,14 @@ abstract class ActivityTestJunit4<T : Activity?> {
    fun setUp() {
        device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
        // NOTE: Must be the "target" context, else security checks in content provider will fail.
        context = InstrumentationRegistry.getInstrumentation().getTargetContext()
        context = InstrumentationRegistry.getInstrumentation().targetContext
        userId = UserId.DEFAULT_USER
        automation = InstrumentationRegistry.getInstrumentation().getUiAutomation()
        automation = InstrumentationRegistry.getInstrumentation().uiAutomation
        features = RuntimeFeatures(context!!.getResources(), null)

        bots = Bots(device, automation, context, TIMEOUT)

        Configurator.getInstance().setToolType(MotionEvent.TOOL_TYPE_MOUSE)
        Configurator.getInstance().toolType = MotionEvent.TOOL_TYPE_MOUSE

        mResolver = context!!.getContentResolver()
        mDocsHelper = DocumentsProviderHelper(
@@ -181,8 +181,12 @@ abstract class ActivityTestJunit4<T : Activity?> {

    @Throws(IOException::class)
    private fun restoreScreenOffAndSleepTimeouts() {
        Objects.requireNonNull<String?>(initialScreenOffTimeoutValue)
        Objects.requireNonNull<String?>(initialSleepTimeoutValue)
        requireNotNull(
            initialScreenOffTimeoutValue
        ) { "Require the initial screen off timeout value to be non-null" }
        requireNotNull(
            initialSleepTimeoutValue
        ) { "Require the sleep timeout value to be non-null" }
        try {
            device!!.executeShellCommand(
                "settings put system screen_off_timeout $initialScreenOffTimeoutValue"