Native component AlertDialog.Builder for showing overlays over apps can't be found or interacted with patrol
Steps to reproduce
- Create a flutter application that triggers a native overlay using the AlertDialog.Builder. The dialog should have some text and some buttons (the draw over other apps Android permission is required) Eg of dialog creation:
val builder: AlertDialog.Builder = AlertDialog.Builder(contextThemeWrapper)
builder.setView(contentView)
builder.setOnDismissListener {
onDismissListener.onDismiss(it)
}
fun createOverlayDialog(
builder: AlertDialog.Builder,
): AlertDialog {
val alertDialog: AlertDialog = builder.create()
alertDialog.window?.setClipToOutline(true)
alertDialog.window?.setBackgroundDrawableResource(android.R.color.transparent)
alertDialog.window?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY)
return alertDialog
}
alertDialog.show
- Make a patrol test that verify the overlay show and interact with overlay buttons
Actual results
I tried with "patrol.native.getNativeViews" but does not find the alert dialog view by id, nor by text . This works only on flutter components.
Note: Seems the patrol library can interact with system dialog views for permissions under the hud. We are expecting to have a method exposed that can interact with the overlay dialogs created by the app, by knowing the actual custom view components ids that are used for creating the overlay dialog content.
Logs
"patrol.native.getNativeViews" returns null. "await $('Click me!').tap();" does nothing for the button that has "Click me!" text in the overlay dialog.
Patrol version
patrol_cli: v3.5.1
Patrol Doctor output
Patrol doctor:
Patrol CLI version: 3.5.1
Flutter command: flutter
Flutter 3.29.3 • channel stable
Android:
• Program adb found in /Users/
Flutter Doctor output
╰─$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.100.0)
[✓] Connected device (5 available)
! Error: Browsing on the local area network for Iphone -
• No issues found!
Hi @aburtea. Have you also tried using patrol devtools to inspect the view in patrol develop mode? Is the overlay also not reflected in that view tree?
Hello! I try to run my test and use this Flutter DevTools Extension while I run it, but nothing is visible in the tree, same for run my app in debug mode until the overlay screen is visible but nothing in the tree and also same for "adb shell uiautomator dump" command to obtain views from that overlay, but nothing in the window_dump.xml generd by the command
"await $('Click me!').tap();" does nothing for the button that has "Click me!" text in the overlay dialog. Hi @aburtea did you try
await $.native.tap(Selector(text: 'Click me'));? Example that you mention will not work on the native side.