Android:锁定屏幕/主屏幕的Espresso测试 [英] Android: Espresso test for lock screen/main screen

查看:126
本文介绍了Android:锁定屏幕/主屏幕的Espresso测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行我的应用程序时,在某些日期会弹出一条横幅通知,提醒用户应用程序活动.当用户双击此按钮时,它们将被带到应用程序.另外,在应用程序的左上方是一个通知图标,单击该图标将再次显示横幅(如果用户未在锁定屏幕上将其清除).

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).

我需要为这两个编写测试,但是我只熟悉onView,尤其是:

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());

仿真器上的锁定屏幕是否具有R.id,或者主屏幕(不是用于应用程序,而是用于Android)?我该如何测试这两个?

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?

类似于在模拟器启动时,双击x/y.如果x/y将您带到R.id.myappshomescreen,则断言X不是Null."

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

该代码对于单击通知非常有用,但是我只想知道espresso是否有可能在锁定的屏幕上单击.

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测试.

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

在我的帖子中- Espresso& UIAutomator-完美的串联方式,我正在描述如何将Espressouiautomator组合.

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

这篇关于Android:锁定屏幕/主屏幕的Espresso测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆