55 lines · 2.4 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.setValueimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.test.assertIsFocusedimport androidx.compose.ui.test.assertIsNotFocusedimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performClickimport com.cottondb.messages.calls.CallViewimport com.cottondb.shell.core.CottonCoreimport kotlinx.serialization.json.jsonObjectimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * A CALL PLACED WITH THE KEYBOARD UP (two emulators, 21 Nov 2026): Emma wrote, tapped Call, and the * keyboard stayed open over the call's Mute, Speaker and Camera. The call screen now takes the focus from the field * under it, so the keyboard goes. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w400dp-h860dp-xhdpi", application = Application::class)class CallKeyboardTest { @get:Rule val compose = createComposeRule() @Test fun the_call_screen_takes_the_focus_from_the_writing_box() { val view = CallView.of(CottonCore.json.parseToJsonElement("""{"shown":true,"phase":"ringing_out","name":"Pat","picture":{"initials":"P","tint":1},"status":"Ringing…","controls":[{"id":"end","label":"End","on":false}]}""").jsonObject) var calling by mutableStateOf(false) compose.setContent { WarmTheme(night = false) { Box { var text by remember { mutableStateOf("Hello Pat") } BasicTextField(text, { text = it }, Modifier.testTag("field")) if (calling) CallScreen(view, remote = null, local = null, egl = null, onAnswer = {}, onDecline = {}, onControl = {}) } } } compose.onNodeWithTag("field").performClick() compose.onNodeWithTag("field").assertIsFocused() calling = true compose.waitForIdle() compose.onNodeWithTag("field").assertIsNotFocused() }}