[Calling][BugFix] Fix UI test for CustomButton (#1067)

This commit is contained in:
pavelprystinka 2024-08-21 15:36:55 -07:00 коммит произвёл GitHub
Родитель f5e8e80909
Коммит e64ba2e968
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 27 добавлений и 67 удалений

Просмотреть файл

@ -6,7 +6,6 @@ package com.azure.android.communication.ui.calling
import androidx.test.platform.app.InstrumentationRegistry
import com.azure.android.communication.BaseUiTest
import com.azure.android.communication.assertTextDisplayed
import com.azure.android.communication.assertTextNotDisplayed
import com.azure.android.communication.common.CommunicationTokenCredential
import com.azure.android.communication.common.CommunicationTokenRefreshOptions
import com.azure.android.communication.tapWhenDisplayed
@ -43,24 +42,25 @@ internal class CustomButtons : BaseUiTest() {
var button2Clicked = false
val controlBarOptions = CallCompositeCallScreenControlBarOptions()
.addCustomButton(
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 1"
) {
button1Clicked = true
}
)
.addCustomButton(
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 2"
) {
button2Clicked = true
}
.setCustomButtons(
listOf(
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 1"
) {
button1Clicked = true
},
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 2"
) {
button2Clicked = true
}
)
)
val callScreenOptions = CallCompositeCallScreenOptions().setControlBarOptions(controlBarOptions)
val callScreenOptions =
CallCompositeCallScreenOptions().setControlBarOptions(controlBarOptions)
val localOptions = CallCompositeLocalOptions().setCallScreenOptions(callScreenOptions)
callComposite.launchTest(
@ -103,14 +103,16 @@ internal class CustomButtons : BaseUiTest() {
var button1Clicked = false
val controlBarOptions = CallCompositeCallScreenControlBarOptions()
.addCustomButton(
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 1",
) {
button1Clicked = true
}
.setEnabled(false)
.setCustomButtons(
listOf(
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 1",
) {
button1Clicked = true
}
.setEnabled(false)
)
)
val callScreenOptions =
@ -132,46 +134,4 @@ internal class CustomButtons : BaseUiTest() {
assert(button1Clicked == false)
}
@OptIn(ExperimentalCoroutinesApi::class)
@Test
fun testCustomButtonsHiddenIsNotVisible() = runTest {
injectDependencies(testScheduler)
// Launch the UI.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
val communicationTokenRefreshOptions =
CommunicationTokenRefreshOptions({ "token" }, true)
val communicationTokenCredential =
CommunicationTokenCredential(communicationTokenRefreshOptions)
val callComposite = CallCompositeBuilder()
.applicationContext(appContext)
.credential(communicationTokenCredential)
.build()
val controlBarOptions = CallCompositeCallScreenControlBarOptions()
.addCustomButton(
CallCompositeCustomButtonOptions(
R.drawable.azure_communication_ui_calling_ic_fluent_speaker_bluetooth_24_regular_primary,
"Custom button 1",
) {}
.setVisible(false)
)
val callScreenOptions =
CallCompositeCallScreenOptions().setControlBarOptions(controlBarOptions)
val localOptions = CallCompositeLocalOptions().setCallScreenOptions(callScreenOptions)
callComposite.launchTest(
appContext,
CallCompositeTeamsMeetingLinkLocator("https:teams.meeting"),
localOptions
)
tapWhenDisplayed(joinCallId)
waitUntilDisplayed(endCallId)
tapWhenDisplayed(moreOptionsId)
assertTextNotDisplayed("Custom button 1")
}
}