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

Commit b47d6de9 authored by William Escande's avatar William Escande
Browse files

Properly use test rules in kotlin

Bug: 311772251
Flag: Exempt TEST_ONLY
Test: atest ServiceBluetoothRoboTests
Change-Id: Ibb6e8645f6e8f60bc66a8e864746f93acbd1bbc6
parent 9ee77103
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -42,8 +42,7 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
@kotlinx.coroutines.ExperimentalCoroutinesApi
class ActiveLogTest {

    @JvmField @Rule val testName = TestName()
    @get:Rule val testName = TestName()

    @Before
    fun setUp() {
+1 −1
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
@kotlinx.coroutines.ExperimentalCoroutinesApi
class BluetoothAdapterStateTest {
    @get:Rule val testName = TestName()

    lateinit var mState: BluetoothAdapterState
    @JvmField @Rule val testName = TestName()

    @Before
    fun setUp() {
+3 −3
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ import org.robolectric.Shadows.shadowOf
@RunWith(RobolectricTestRunner::class)
@kotlinx.coroutines.ExperimentalCoroutinesApi
class AutoOnFeatureTest {
    @get:Rule val testName = TestName()
    @get:Rule val expect = Expect.create()

    private val looper = Looper.getMainLooper()
    private val state = BluetoothAdapterState()
    private val context = ApplicationProvider.getApplicationContext<Context>()
@@ -65,9 +68,6 @@ class AutoOnFeatureTest {

    private var callback_count = 0

    @JvmField @Rule val testName = TestName()
    @JvmField @Rule val expect = Expect.create()

    @Before
    fun setUp() {
        Log.i("AutoOnFeatureTest", "\t--> setUp(${testName.getMethodName()})")
+1 −1
Original line number Diff line number Diff line
@@ -57,9 +57,9 @@ internal fun enableMode(resolver: ContentResolver, looper: Looper, modeKey: Stri

@RunWith(RobolectricTestRunner::class)
class RadioModeListenerTest {
    @get:Rule val testName = TestName()
    private val resolver: ContentResolver =
        ApplicationProvider.getApplicationContext<Context>().getContentResolver()
    @JvmField @Rule val testName = TestName()

    private val looper: Looper = Looper.getMainLooper()

+3 −3
Original line number Diff line number Diff line
@@ -94,14 +94,14 @@ class ModeListenerTest {
        }
    }

    @get:Rule val testName = TestName()
    @get:Rule val setFlagsRule = SetFlagsRule()

    private val looper: Looper = Looper.getMainLooper()
    private val state = BluetoothAdapterState()
    private val mContext = ApplicationProvider.getApplicationContext<Context>()
    private val resolver: ContentResolver = mContext.contentResolver

    @JvmField @Rule val testName = TestName()
    @JvmField @Rule val setFlagsRule = SetFlagsRule(SetFlagsRule.DefaultInitValueType.NULL_DEFAULT)

    private val userContext =
        mContext.createContextAsUser(UserHandle.of(ActivityManager.getCurrentUser()), 0)

Loading