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

Commit 5a5cc712 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Fix @Test annotation to make Kotlin 2.2 happy."" into main

parents dbee0b29 3efd4544
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.wm.shell.windowdecor.common.WindowDecorTaskResourceLoader
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainCoroutineDispatcher
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -711,7 +712,7 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

    // Construction of a tiling divider with null config expects a null pointer here
    // which is a sign a new divider is being created due to dpi changes.
    @Test(expected = NullPointerException::class)
    @Test
    fun tilingDividerDestroyed_whenDpiChanges() {
        val task1 = createVisibleTask()
        val additionalTaskHelper: DesktopTilingWindowDecoration.AppResizingHelper = mock()
@@ -736,9 +737,9 @@ class DesktopTilingWindowDecorationTest : ShellTestCase() {

        tilingDecoration.leftTaskResizingHelper = tiledTaskHelper
        tilingDecoration.desktopTilingDividerWindowManager = desktopTilingDividerWindowManager
        assertThrows(NullPointerException::class.java) {
            tilingDecoration.onDensityOrFontScaleChanged()

        verify(desktopTilingDividerWindowManager, times(1)).release()
        }
    }

    @Test
+10 −5
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.currentTime
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith

@@ -98,12 +99,16 @@ class AuthenticationInteractorTest : SysuiTestCase() {
            assertFailed(underTest.authenticate(listOf(9, 8, 7, 6, 5, 4)))
        }

    @Test(expected = IllegalArgumentException::class)
    fun authenticate_withEmptyPin_throwsException() =
    @Test
    fun authenticate_withEmptyPin_throwsException() {
        Assert.assertThrows(IllegalArgumentException::class.java) {
            testScope.runTest {
                kosmos.fakeAuthenticationRepository.setAuthenticationMethod(Pin)
                
                underTest.authenticate(listOf())
            }
        }
    }

    @Test
    fun authenticate_withCorrectMaxLengthPin_succeeds() =
+7 −3
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -158,14 +160,16 @@ class DeviceItemActionInteractorTest : SysuiTestCase() {
        }
    }

    @Test(expected = IllegalArgumentException::class)
    @Test
    fun onActionIconClick_audioSharingDeviceType_throwException() {
        with(kosmos) {
            assertThrows(IllegalArgumentException::class.java) {
                testScope.runTest {
                    actionInteractorImpl.onActionIconClick(audioSharingDeviceItem) {}
                }
            }
        }
    }

    private companion object {
        const val DEVICE_NAME = "device"
+9 −3
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.cancel
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Assert.assertThrows
import org.junit.Test
import org.junit.runner.RunWith

@@ -43,8 +45,12 @@ class CoroutineResultTest : SysuiTestCase() {
        assertThat(actual.exceptionOrNull()).isInstanceOf(Exception::class.java)
    }

    @Test(expected = CancellationException::class)
    fun suspendRunCatching_whenCancelled_shouldResumeWithException() = runTest {
    @Test
    fun suspendRunCatching_whenCancelled_shouldResumeWithException() {
        assertThrows(CancellationException::class.java) {
            runTest {
                suspendRunCatching { cancel() }
            }
        }
    }
}
+21 −10
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -507,19 +508,29 @@ class ResizeableItemFrameViewModelTest : SysuiTestCase() {
            assertThat(resizeInfo).isNull()
        }

    @Test(expected = IllegalArgumentException::class)
    fun testIllegalState_maxHeightLessThanMinHeight() =
    @Test
    fun testIllegalState_maxHeightLessThanMinHeight() {
        Assert.assertThrows(IllegalArgumentException::class.java) {
            testScope.runTest {
                updateGridLayout(singleSpanGrid.copy(maxHeightPx = 50, minHeightPx = 100))
            }
        }
    }

    @Test(expected = IllegalArgumentException::class)
    fun testIllegalState_currentSpanExceedsTotalSpans() =
        testScope.runTest { updateGridLayout(singleSpanGrid.copy(currentSpan = 3, totalSpans = 2)) }
    @Test
    fun testIllegalState_currentSpanExceedsTotalSpans() {
        Assert.assertThrows(IllegalArgumentException::class.java) {
            testScope.runTest {
                updateGridLayout(singleSpanGrid.copy(currentSpan = 3, totalSpans = 2)) }
        }
    }

    @Test(expected = IllegalArgumentException::class)
    fun testIllegalState_resizeMultipleZeroOrNegative() =
    @Test
    fun testIllegalState_resizeMultipleZeroOrNegative() {
        Assert.assertThrows(IllegalArgumentException::class.java) {
            testScope.runTest { updateGridLayout(singleSpanGrid.copy(resizeMultiple = 0)) }
        }
    }

    @Test
    fun testZeroHeights_cannotResize() =
Loading