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

Commit 637bb3ea authored by Joshua Mokut's avatar Joshua Mokut Committed by Android (Google) Code Review
Browse files

Merge "Minor Refactoring for phone status bar tests" into main

parents 9799ce72 e34fb4b8
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
    }