Skip to content

Commit 5891cbc

Browse files
committed
Type on the software keyboard's keys in the demo, pace it for under 100 s, tap web rows after scrolling them into view, and record with the host renderer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xYtaUjbkB1hwLtK4TEzhq
1 parent 35d3176 commit 5891cbc

3 files changed

Lines changed: 101 additions & 34 deletions

File tree

‎.github/workflows/android-shell-video.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ jobs:
123123
timeout-minutes: 4
124124
env:
125125
ANIMATOR_SCALE: "1"
126+
# The host-side software renderer for the recordings: smooth enough to type and scroll
127+
# on camera. The test workflow keeps the guest renderer, which never froze.
128+
GPU_MODE: swiftshader_indirect
126129
run: android-shell/ci/emulator.sh all
127130

128131
- name: Install the apps

‎android-shell/app/src/androidTest/java/ai/openbot/shell/test/DemoTourTest.kt‎

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,64 +28,67 @@ class DemoTourTest : ShellTestBase() {
2828
// The first page load answers 1.5 s late (debug hook), so the loading skeleton reads on video.
2929
launch(MOCK_A, "tour", extras = mapOf("openbot.delay_first_load_ms" to "1500"))
3030
check(waitFor("sign_in_button", 20_000) != null, "demo: no Sign in button")
31-
pause(1_000)
32-
// Native sign-in, then the Custom Tab with the mock's page, followed by hand, each step held.
33-
if (!check(signInThroughCustomTab("tour", shots = false, paceMs = 2_000), "demo: signing in did not reach the tabs")) return
31+
pause(800)
32+
// Native sign-in, the Custom Tab with the mock's page followed by hand, each step held.
33+
if (!check(signInThroughCustomTab("tour", shots = false, paceMs = 1_500), "demo: signing in did not reach the tabs")) return
3434
check(waitPageText("Start a conversation", 30_000), "demo: Home did not render")
35-
pause(2_000)
35+
pause(1_500)
3636

3737
// The software keyboard: the bottom bar hides, the message box sits on the keyboard.
38-
val box = waitComposerRect(10_000)
39-
if (box != null) {
38+
waitComposerRect(10_000)?.let { box ->
4039
tapComposer(box)
41-
if (waitKeyboard(true, 8_000)) {
42-
pause(800)
43-
shell("input text What%schanged%sin%scompetitor%spricing?")
44-
pause(2_000)
40+
if (waitKeyboard(true, 6_000)) {
41+
pause(500)
42+
typeOnKeyboard("what changed in pricing")
43+
val typed = pageString("document.activeElement ? (document.activeElement.innerText || document.activeElement.value || '') : ''")
44+
note("demo: the message box holds ${typed.length} characters after typing")
45+
pause(1_200)
46+
screenshot("home-keyboard-typed")
4547
device.pressBack()
4648
waitKeyboard(false, 4_000)
4749
} else {
4850
note("demo: the software keyboard did not show")
4951
}
5052
}
51-
pause(1_500)
53+
pause(800)
5254

53-
// Conversations: scroll, open one, system Back.
55+
// Conversations: open one, system Back.
5456
tab(Tab.CONVERSATIONS)?.click()
55-
check(waitPageText("Competitor pricing notes", 20_000), "demo: no conversations")
57+
check(waitPageText("Competitor pricing notes", 15_000), "demo: no conversations")
5658
pause(1_200)
57-
find("openbot_webview")?.swipe(Direction.UP, 0.6f)
58-
pause(800)
59-
find("openbot_webview")?.swipe(Direction.DOWN, 0.6f)
60-
pause(1_000)
6159
tapWeb("Competitor pricing notes")
62-
check(waitPageText("What do our three closest competitors charge?", 20_000) || waitPageText("per-seat", 2_000), "demo: the conversation did not open")
63-
pause(2_000)
60+
check(waitPageText("What do our three closest competitors charge?", 15_000) || waitPageText("per-seat", 1_000), "demo: the conversation did not open")
61+
pause(1_800)
62+
if (keyboardShown()) screenshot("conversation-keyboard-still")
6463
dismissKeyboardIfUp()
65-
pause(1_200)
64+
pause(600)
6665
device.pressBack()
6766
check(waitPageText("Quarterly forecast", 8_000), "demo: system Back did not return to the list")
68-
pause(1_500)
67+
pause(1_200)
6968

7069
// Bots: open one.
7170
tab(Tab.BOTS)?.click()
72-
tapWeb("Research Bot", 20_000)
73-
pause(2_500)
71+
check(waitPageText("Research Bot", 15_000), "demo: no Bots")
72+
pause(800)
73+
sleep(1_500)
74+
screenshot("bots-still")
75+
tapWeb("Research Bot")
76+
pause(2_000)
7477
dismissKeyboardIfUp()
7578

7679
// Home, the Account menu, Sign out: the native sign-in screen.
7780
tab(Tab.HOME)?.click()
81+
pause(1_200)
82+
check(tapWeb("Account"), "demo: no Account button")
83+
pause(1_200)
84+
check(tapWeb("Sign out"), "demo: no Sign out in the Account menu")
85+
check(waitFor("sign_in_button", 15_000) != null, "demo: Sign out did not return to the native sign-in")
7886
pause(1_500)
79-
(device.findObject(By.desc("Account")) ?: waitWebObject("Account", 10_000))?.click()
80-
pause(1_500)
81-
tapWeb("Sign out")
82-
check(waitFor("sign_in_button", 20_000) != null, "demo: Sign out did not return to the native sign-in")
83-
pause(2_000)
8487

8588
// The lock screen, then the connection comes back.
86-
launch(MOCK_A, "tour-offline", reset = false, extras = mapOf("openbot.force_offline_seconds" to "5"))
89+
launch(MOCK_A, "tour-offline", reset = false, extras = mapOf("openbot.force_offline_seconds" to "4"))
8790
check(waitFor("offline_lock", 5_000) != null, "demo: no lock screen")
88-
check(waitGone("offline_lock", 15_000), "demo: the lock did not lift")
89-
pause(2_000)
91+
check(waitGone("offline_lock", 12_000), "demo: the lock did not lift")
92+
pause(1_500)
9093
}
9194
}

‎android-shell/app/src/androidTest/java/ai/openbot/shell/test/ShellTestBase.kt‎

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,12 @@ abstract class ShellTestBase {
333333
"(function(t){var best=null;var all=document.querySelectorAll('a,button,[role=button],[role=link],[role=menuitem],li,div,span,p,h1,h2,h3');" +
334334
"for(var i=0;i<all.length;i++){var e=all[i];var s=(e.innerText||e.getAttribute('aria-label')||'').trim();" +
335335
"if(s===t||s.indexOf(t)===0){var r=e.getBoundingClientRect();" +
336-
"if(r.width>0&&r.height>0&&r.bottom>0&&r.top<window.innerHeight&&(!best||r.width*r.height<best.a))" +
337-
"best={a:r.width*r.height,l:r.left,t:r.top,r:r.right,b:r.bottom};}}" +
338-
"if(!best)return 'null';best.d=window.devicePixelRatio;return JSON.stringify(best);})(" +
336+
"if(r.width>0&&r.height>0&&(!best||r.width*r.height<best.a))best={a:r.width*r.height,e:e};}}" +
337+
"if(!best)return 'null';best.e.scrollIntoView({block:'center'});var q=best.e.getBoundingClientRect();" +
338+
"return JSON.stringify({l:q.left,t:q.top,r:q.right,b:q.bottom,d:window.devicePixelRatio});})(" +
339339
org.json.JSONObject.quote(text) + ")",
340340
)
341+
sleep(300)
341342
val web = bounds(find("openbot_webview"))
342343
if (raw != "null" && raw.isNotEmpty() && web != null) {
343344
try {
@@ -381,6 +382,66 @@ abstract class ShellTestBase {
381382
)
382383
}
383384

385+
/**
386+
* Types `text` on the real software keyboard by tapping its keys at points computed once from
387+
* the keyboard window's bounds (Gboard's QWERTY grid: a toolbar strip, four key rows, the
388+
* navigation strip), 150 ms a key. Letters and spaces only through the grid; anything else, and
389+
* whatever the grid did not land, goes through `input text`. Answers which path was used.
390+
*/
391+
fun typeOnKeyboard(text: String, deadlineMs: Long = 15_000): String {
392+
val started = SystemClock.uptimeMillis()
393+
val ime = device.findObjects(By.pkg("com.google.android.inputmethod.latin"))
394+
.mapNotNull { bounds(it) }.maxByOrNull { it.width() * it.height() }
395+
val unplaced = StringBuilder()
396+
var path = "keys"
397+
if (ime == null || ime.height() < 200) {
398+
path = "input-text (no keyboard window found)"
399+
shell("input text " + text.replace(" ", "%s"))
400+
return path
401+
}
402+
val h = ime.height().toFloat()
403+
val top = ime.top + h * 0.15f
404+
val rowH = h * 0.75f / 4f
405+
val keyW = ime.width() / 10f
406+
val rows = listOf("qwertyuiop", "asdfghjkl", "zxcvbnm")
407+
fun point(c: Char): Pair<Int, Int>? {
408+
if (c == ' ') return Pair((ime.left + ime.width() * 0.5f).toInt(), (top + rowH * 3.5f).toInt())
409+
for ((r, keys) in rows.withIndex()) {
410+
val i = keys.indexOf(c.lowercaseChar())
411+
if (i >= 0) {
412+
val offset = when (r) { 0 -> 0f; 1 -> 0.5f; else -> 1.5f }
413+
return Pair((ime.left + keyW * (i + offset + 0.5f)).toInt(), (top + rowH * (r + 0.5f)).toInt())
414+
}
415+
}
416+
return null
417+
}
418+
for (c in text) {
419+
if (SystemClock.uptimeMillis() - started > deadlineMs) {
420+
screenshot("typing-deadline")
421+
check(false, "typing took longer than ${deadlineMs / 1000} s")
422+
return "$path (stopped at the deadline)"
423+
}
424+
val p = point(c)
425+
if (p == null) {
426+
unplaced.append(c)
427+
continue
428+
}
429+
if (unplaced.isNotEmpty()) {
430+
shell("input text " + unplaced.toString().replace(" ", "%s"))
431+
unplaced.clear()
432+
path = "keys + input-text"
433+
}
434+
device.click(p.first, p.second)
435+
sleep(150)
436+
}
437+
if (unplaced.isNotEmpty()) {
438+
shell("input text " + unplaced.toString().replace(" ", "%s"))
439+
path = "keys + input-text"
440+
}
441+
note("typed ${text.length} characters on the software keyboard in ${(SystemClock.uptimeMillis() - started) / 1000.0} s ($path)")
442+
return path
443+
}
444+
384445
/** Taps the message box near its top (where the text line is). */
385446
fun tapComposer(rect: Rect) {
386447
device.click(rect.centerX(), minOf(rect.top + 40, rect.centerY()))

0 commit comments

Comments
 (0)