简体   繁体   English

Android:针对锁定屏幕/主屏幕的Espresso测试

[英]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,尤其是类似以下内容的东西:

   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)? 模拟器上的锁定屏幕是否具有R.id,或者主屏幕(不是针对应用程序,而是针对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". 诸如“在模拟器启动时,双击x / y。如果x / y将您带到R.id.myappshomescreen,则断言X不是Null”。

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. 该代码对于单击通知将非常有用,但是我只想知道espresso是否有可能在锁定的屏幕上单击。

You'll be able to click on notifications using UIAutomator testing framework 您将可以使用UIAutomator测试框架单击通知

Once you click on a notification and open your app, you would be able to proceed with Espresso test in one test case. 单击通知并打开您的应用后,您将可以在一个测试案例中进行Espresso测试。

In my post - Espresso & UIAutomator - the perfect tandem , I'm describing how to combine Espresso with uiautomator . 在我的后Espresso&UIAutomator(完美结合)中,我描述了如何将Espressouiautomator结合使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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