简体   繁体   中英

Android: Espresso test for lock screen/main screen

When I run my app I have a banner notification pop up on certain dates alerting the user of app activity. When the user double clicks this they're taken to the app. Also, on the top left of the app is a notification icon that when clicked shows the banner again (if the user did not clear it at the lock screen).

I need to write a test for these two, but I'm only familiar with onView, specifically things like:

   onView(withId(R.id.list_product)).perform(longClick());

Does the lock screen on an emulator have an R.id, or does the home screen (not for the app, but for android)? How can I test these two?

Something like "On emulator start, double click x/y. If x/y takes you to R.id.myappshomescreen assert that X is notNull".

The code would be nice for clicking a notification, but I just want to know if it's even possible for espresso to click on the locked screen.

You'll be able to click on notifications using UIAutomator testing framework

Once you click on a notification and open your app, you would be able to proceed with Espresso test in one test case.

In my post - Espresso & UIAutomator - the perfect tandem , I'm describing how to combine Espresso with uiautomator .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM