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

Commit e34fb4b8 authored by Josh's avatar Josh
Browse files

Minor Refactoring for phone status bar tests

Following up on comments ag/26398347

Test: NA
Flag: NA
Fixes: 326097469
Change-Id: I455ffce3297268aff70b441a617f60cde67db72a
parent 8fa136da
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -234,19 +234,14 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
    }

    @Test
    fun shadeIsExpandedOnStatusIconClick() {
    fun shadeIsExpandedOnStatusIconMouseClick() {
        val view = createViewMock()
        InstrumentationRegistry.getInstrumentation().runOnMainSync {
            controller = createAndInitController(view)
        }
        val statusContainer = view.requireViewById<View>(R.id.system_icons)
        statusContainer.dispatchTouchEvent(
            getMotionEventFromSource(
                MotionEvent.ACTION_UP,
                0,
                0,
                InputDevice.SOURCE_MOUSE
            )
            getActionUpEventFromSource(InputDevice.SOURCE_MOUSE)
        )
        verify(shadeViewController).expand(any())
    }
@@ -259,18 +254,13 @@ class PhoneStatusBarViewControllerTest : SysuiTestCase() {
        }
        val statusContainer = view.requireViewById<View>(R.id.system_icons)
        val handled = statusContainer.dispatchTouchEvent(
            getMotionEventFromSource(
                MotionEvent.ACTION_UP,
                0,
                0,
                InputDevice.SOURCE_TOUCHSCREEN
            )
            getActionUpEventFromSource(InputDevice.SOURCE_TOUCHSCREEN)
        )
        assertThat(handled).isFalse()
    }

    private fun getMotionEventFromSource(action: Int, x: Int, y: Int, source: Int): MotionEvent {
        val ev = MotionEvent.obtain(0, 0, action, x.toFloat(), y.toFloat(), 0)
    private fun getActionUpEventFromSource(source: Int): MotionEvent {
        val ev = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0f, 0f, 0)
        ev.source = source
        return ev
    }