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

Commit 2fb41b6d authored by David Saff's avatar David Saff Committed by Android (Google) Code Review
Browse files

Merge "Prevent mockito initialization issue in ScreenshotViewModelTest" into main

parents a242ce45 d35174bd
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.screenshot.ui.viewmodel
import android.view.accessibility.AccessibilityManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -79,4 +80,10 @@ class ScreenshotViewModelTest {
        assertThat(updated.appearance).isEqualTo(otherAppearance)
        assertThat(updated.onClicked).isEqualTo(onclick)
    }

    companion object {
        init {
            SysuiTestCase.waitUntilMockitoCanBeInitialized()
        }
    }
}
+11 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ public abstract class SysuiTestCase {
    private SysuiTestDependency mSysuiDependency;

    static {
        assertTempFilesAreCreatable();
        waitUntilMockitoCanBeInitialized();
    }

    @Before
@@ -219,6 +219,16 @@ public abstract class SysuiTestCase {
        }
    }

    /**
     * Due to b/404544974, it is possible for a test process to start without access to its
     * temp folder, and then gain access later.  Mockito cannot initialize (b/391948934) if the
     * temp folder is not writeable, so calling this method allows a test not to proceed until
     * mockito will be workable.
     */
    public static void waitUntilMockitoCanBeInitialized() {
        assertTempFilesAreCreatable();
    }

    private static Boolean sCanCreateTempFiles = null;
    private static void assertTempFilesAreCreatable() throws RuntimeException {
        // TODO(b/391948934): hopefully remove this hack