I add a floating view to the WindowManager and make it move around the screen, and I can execute the click event, when I click this view, everything works fine.
However, I do not know how to access this view in espresso or UIAutomator .
Add View to WindowManager
final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, type, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSLUCENT ); ImageView floatingView = new ImageView(mContext); floatingView.setContentDescription("bugtags_fab_des_normal"); mWindowManager.addView(floatingView, layoutParams);
Floating view
the blue and white icon in the rectangle is the floating view I'm talking about.

Question
A floating view responds to a click event and performs some task, now I want to do this in an AndroidJunit test.
I am trying to use Espresso using the onView method, but a test case:
onView(withContentDescription("bugtags_fab_des_normal")).perform(click());
Get:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with content description: is "bugtags_fab_des_normal"
I am trying UIAutomator Viewer but I cannot find viewView hierarchy in view.
how
How can I access this view in espresso or uiautomator and press it?
application
Test case
@Test public void testInvoke() { onView(withContentDescription("bugtags_fab_des_normal")).perform(click()); }
Output log
output log
Bugtags.com
In fact, I am using sdk called bugtags.com , it is a simple tool for reporting application errors and analyzing crashes.