Skip to content

Commit f0450be

Browse files
committed
Make the Google recording one attempt that ends cleanly on any stop, and check the status bar's icons on light screens
The Google test now records from launch, stops at Cloudflare's check at each production page, screenshots every step, and on any stop leaves a picture and the screen's words (addresses masked, private artifact only). A recording run makes the WebView attempt only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xYtaUjbkB1hwLtK4TEzhq
1 parent 09fc12c commit f0450be

3 files changed

Lines changed: 122 additions & 34 deletions

File tree

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,39 @@ class HardeningTest : ShellTestBase() {
113113
note("commits before $commitsBefore, after ${stateValue("commits")}")
114114
screenshot("2-recovered")
115115
}
116+
117+
/**
118+
* The status bar: visible, and drawn with dark icons on the light first screen and on Home
119+
* (light-bars appearance). Notes what the window and SystemUI report, for runs where the
120+
* screenshots show no clock.
121+
*/
122+
@Test
123+
fun testStatusBarIconsOnLightScreens() {
124+
launch(MOCK_A, "status-bar")
125+
check(waitFor("sign_in_button", 20_000) != null, "no first screen")
126+
sleep(1_500)
127+
checkStatusBar("first-screen")
128+
if (!launchSignedIn("status-bar-home")) return
129+
sleep(3_000)
130+
checkStatusBar("home")
131+
}
132+
133+
private fun checkStatusBar(moment: String) {
134+
var light: Boolean? = null
135+
var visible: Boolean? = null
136+
instrumentation.runOnMainSync {
137+
val activity = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED)
138+
.firstOrNull { it.javaClass.name == ACTIVITY } ?: return@runOnMainSync
139+
val decor = activity.window.decorView
140+
light = androidx.core.view.WindowCompat.getInsetsController(activity.window, decor).isAppearanceLightStatusBars
141+
visible = androidx.core.view.ViewCompat.getRootWindowInsets(decor)?.isVisible(androidx.core.view.WindowInsetsCompat.Type.statusBars())
142+
}
143+
val window = shell("dumpsys window windows").lines().map { it.trim() }
144+
.filter { it.contains("StatusBar") && (it.contains("isVisible") || it.contains("mHasSurface") || it.startsWith("Window #")) }
145+
.take(4).joinToString(" / ")
146+
note("$moment: status bar visible $visible, light-bars appearance $light; window: ${window.take(400)}")
147+
screenshot("$moment-status-bar")
148+
check(visible == true, "$moment: the status bar is not visible to the app")
149+
check(light == true, "$moment: the status bar's icons are not dark on a light screen")
150+
}
116151
}

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

Lines changed: 84 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -113,41 +113,92 @@ class RealBackendReleaseTest : ShellTestBase() {
113113
requireProduction()
114114
mark("start")
115115
try {
116-
launchPlain(null, "google-webview")
117-
val button = waitFor("sign_in_button", 15_000) ?: skip("no Sign in button")
118-
sleep(1_500)
119-
button.click()
120-
if (waitFor("web_sign_in_cancel", 25_000) == null) skip("no web sign-in fallback")
121-
waitWebObject("Sign in to OpenBot Cloud", 30_000)
122-
sleep(1_500)
123-
screenshot("1-web-sign-in")
124-
waitWebObject("Sign in or create an account", 15_000)?.click() ?: skip("no 'Sign in or create an account'")
125-
val google = findInApp(pkg, "Google", 30_000) ?: skip("no Google button on OpenBot by CopilotKit's page")
126-
sleep(1_500)
127-
screenshot("2-identity-provider")
128-
google.click()
129-
sleep(10_000)
130-
screenshot("3-google-in-webview")
131-
val refusal = googleRefusal(pkg)
132-
if (refusal != null) {
133-
note("Google refused the sign-in inside Android's WebView: the page says '$refusal'")
134-
skip("refused: Google shows '$refusal' inside Android's WebView; the Custom Tab path is the design")
135-
}
136-
googleSteps(pkg, email, password, totp)
137-
val home = waitForTab(Tab.HOME, 40_000)
138-
sleep(3_000)
139-
screenshot("4-after-google")
140-
note("Google sign-in in the WebView reached the tabs: ${home != null}")
141-
if (home == null) skip("Google's sign-in in the WebView did not end signed in")
142-
// A short journey.
143-
tab(Tab.BOTS)?.click()
144-
sleep(4_000)
145-
screenshot("5-bots")
146-
tab(Tab.HOME)?.click()
147-
sleep(3_000)
148-
screenshot("6-home")
116+
googleWebViewJourney(email, password, totp)
117+
} catch (stop: org.junit.AssumptionViolatedException) {
118+
// Any stop (Cloudflare, Google's refusal or challenge, an unexpected screen) ends here
119+
// with a picture and the screen's visible words; the recording keeps running to the end mark.
120+
screenshot("stopped")
121+
note("stopped: ${stop.message}; visible text: ${visibleText()}")
122+
throw stop
149123
} finally {
150124
mark("end")
151125
}
152126
}
127+
128+
/** The app's visible words (accessibility tree), addresses masked, at most 600 characters. */
129+
private fun visibleText(): String =
130+
device.findObjects(By.pkg(pkg)).flatMap { listOfNotNull(it.text, it.contentDescription) }
131+
.filter { it.isNotBlank() }.distinct().joinToString(" | ")
132+
.replace(Regex("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+"), "<email>").take(600)
133+
134+
private fun googleWebViewJourney(email: String, password: String, totp: ByteArray) {
135+
launchPlain(null, "google-webview")
136+
val button = waitFor("sign_in_button", 15_000) ?: skip("no Sign in button")
137+
sleep(1_500)
138+
screenshot("0-first-screen")
139+
button.click()
140+
if (waitFor("web_sign_in_cancel", 25_000) == null) skip("no web sign-in fallback")
141+
sleep(4_000)
142+
stopAtBotCheck("web-sign-in")
143+
waitWebObject("Sign in to OpenBot Cloud", 30_000)
144+
stopAtBotCheck("web-sign-in-page")
145+
sleep(1_500)
146+
screenshot("1-web-sign-in")
147+
waitWebObject("Sign in or create an account", 15_000)?.click() ?: skip("no 'Sign in or create an account'")
148+
sleep(3_000)
149+
stopAtBotCheck("identity-provider")
150+
val google = findInApp(pkg, "Google", 30_000) ?: skip("no Google button on the identity provider's page")
151+
sleep(1_500)
152+
screenshot("2-identity-provider")
153+
google.click()
154+
sleep(10_000)
155+
screenshot("3-google-in-webview")
156+
stopAtBotCheck("google")
157+
val refusal = googleRefusal(pkg)
158+
if (refusal != null) {
159+
note("Google refused the sign-in inside Android's WebView: the page says '$refusal'")
160+
skip("refused: Google shows '$refusal' inside Android's WebView")
161+
}
162+
googleSteps(pkg, email, password, totp)
163+
val home = waitForTab(Tab.HOME, 40_000)
164+
sleep(3_000)
165+
screenshot("8-after-google")
166+
stopAtBotCheck("after-google")
167+
note("Google sign-in in the WebView reached the tabs: ${home != null}")
168+
if (home == null) skip("Google's sign-in in the WebView did not end signed in")
169+
170+
// The journey, as the session-cookie test: a message and its streamed reply, the tabs,
171+
// the background and back. No sign-out.
172+
val box = waitComposerRect(30_000)
173+
screenshot("9-home")
174+
if (box != null) {
175+
tapComposer(box)
176+
if (!waitKeyboard(true, 5_000)) composerRect()?.let { tapComposer(it) }
177+
note("software keyboard shown for the message: ${waitKeyboard(true, 5_000)}")
178+
shell("input text Say%shello%sin%sthree%swords.")
179+
sleep(1_000)
180+
screenshot("10-message-typed")
181+
val before = visibleText()
182+
(device.findObject(By.desc("Send message")) ?: device.findObject(By.text("Send message")))?.click() ?: device.pressEnter()
183+
sleep(15_000)
184+
screenshot("11-reply")
185+
note("the screen changed after sending: ${visibleText() != before}")
186+
} else {
187+
note("no message box found on Home")
188+
}
189+
tab(Tab.CONVERSATIONS)?.click()
190+
sleep(4_000)
191+
screenshot("12-chats")
192+
tab(Tab.BOTS)?.click()
193+
sleep(4_000)
194+
screenshot("13-bots")
195+
tab(Tab.HOME)?.click()
196+
sleep(2_000)
197+
device.pressHome()
198+
sleep(20_000)
199+
bringBack()
200+
sleep(4_000)
201+
screenshot("14-back-from-background")
202+
note("after the background: home tab ${tab(Tab.HOME) != null}")
203+
}
153204
}

‎android-shell/ci/run_tests.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"HardeningTest#testAccessibilityLabels",
9797
"HardeningTest#testTabletSizeAndRotation",
9898
"HardeningTest#testRendererKilledRecovers",
99+
"HardeningTest#testStatusBarIconsOnLightScreens",
99100
]
100101
DEMO = ["DemoTourTest#testDemoTour"]
101102
# Recordings (video mode only): (first test, last test, file, private?)
@@ -112,9 +113,10 @@
112113
"RealBackendDebugTest#testRealSignedInJourneyWithSessionCookie",
113114
"RealBackendDebugTest#testRealSignedInJourneyWithSessionCookie_2_relaunch",
114115
]
116+
# Exactly 1 Google attempt per run: the app's own path on production (the web sign-in in the
117+
# WebView, as production has no hand-off). The Custom Tab attempt is not part of a recording run.
115118
VIDEO_REAL_GOOGLE = [
116119
"RealBackendReleaseTest#testRealGoogleSignInInWebViewAndJourney",
117-
"RealBackendDebugTest#testRealGoogleSignInInCustomTab",
118120
]
119121
LOG_TAGS = ("OPENBOT_DIAG", "SHELL_NOTE", "SHELL_PROBE", "TestRunner", "AndroidRuntime", "chromium", "cr_", "WebView")
120122
PER_TEST_S = int(os.environ.get("PER_TEST_SECONDS", "300"))

0 commit comments

Comments
 (0)