Android: Espresso test for lock screen/main screen

你。 提交于 2019-12-02 11:22:28

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/33351750/android-espresso-test-for-lock-screen-main-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!