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

Commit 44636552 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix a11y for controls header

When there's only one element (app or structure), the header should not
be clickable.

Test: manual, using TB
Test: atest ControlsUiControllerImplTest
Fixes: 270104680
Change-Id: Ide01d9a3979d7b57787fb98a58955920984a0861
parent ae6c0cf5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -605,6 +605,7 @@ class ControlsUiControllerImpl @Inject constructor (
        if (items.size == 1) {
            spinner.setBackground(null)
            anchor.setOnClickListener(null)
            anchor.isClickable = false
            return
        } else {
            spinner.background = parent.context.resources
+50 −0
Original line number Diff line number Diff line
@@ -200,6 +200,56 @@ class ControlsUiControllerImplTest : SysuiTestCase() {
        verify(taskViewFactory).create(eq(context), eq(uiExecutor), any())
    }

    @Test
    fun testSingleAppHeaderIsNotClickable() {
        mockLayoutInflater()
        val packageName = "pkg"
        `when`(authorizedPanelsRepository.getAuthorizedPanels()).thenReturn(setOf(packageName))
        val panel = SelectedItem.PanelItem("App name", ComponentName(packageName, "cls"))
        val serviceInfo = setUpPanel(panel)

        underTest.show(parent, {}, context)

        val captor = argumentCaptor<ControlsListingController.ControlsListingCallback>()

        verify(controlsListingController).addCallback(capture(captor))

        captor.value.onServicesUpdated(listOf(serviceInfo))
        FakeExecutor.exhaustExecutors(uiExecutor, bgExecutor)

        val header: View = parent.requireViewById(R.id.controls_header)
        assertThat(header.isClickable).isFalse()
        assertThat(header.hasOnClickListeners()).isFalse()
    }

    @Test
    fun testMultipleAppHeaderIsClickable() {
        mockLayoutInflater()
        val packageName1 = "pkg"
        val panel1 = SelectedItem.PanelItem("App name 1", ComponentName(packageName1, "cls"))
        val serviceInfo1 = setUpPanel(panel1)

        val packageName2 = "pkg"
        val panel2 = SelectedItem.PanelItem("App name 2", ComponentName(packageName2, "cls"))
        val serviceInfo2 = setUpPanel(panel2)

        `when`(authorizedPanelsRepository.getAuthorizedPanels())
                .thenReturn(setOf(packageName1, packageName2))

        underTest.show(parent, {}, context)

        val captor = argumentCaptor<ControlsListingController.ControlsListingCallback>()

        verify(controlsListingController).addCallback(capture(captor))

        captor.value.onServicesUpdated(listOf(serviceInfo1, serviceInfo2))
        FakeExecutor.exhaustExecutors(uiExecutor, bgExecutor)

        val header: View = parent.requireViewById(R.id.controls_header)
        assertThat(header.isClickable).isTrue()
        assertThat(header.hasOnClickListeners()).isTrue()
    }

    @Test
    fun testPanelControllerStartActivityWithCorrectArguments() {
        mockLayoutInflater()