如何编写使用内置相机拍照的 Solo/Robotium 测试用例?
从我的活动中,我执行 startActivityForResult(MediaStore.ACTION_IMAGE_CAPTURE),
然后我进入内置相机活动(在本例中是在模拟器中)。
当我现在这样做时:
“solo.clickOnButton(0);”
在我的测试用例中,它没有找到任何按钮(索引 = 0 时找到 null)。
如何编写使用内置相机拍照的 Solo/Robotium 测试用例?
From my activity I do startActivityForResult(MediaStore.ACTION_IMAGE_CAPTURE),
and then I land in the builtin camera activity (in this case in the emulator).
When I now do:
"solo.clickOnButton(0);"
in my testcase, it does not find ANY button (null is found for index=0).
How do I write a Solo/Robotium testcase that uses the builtin camera to take a picture ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 Robotium 文档,您不能执行此操作,因为这跨越两个应用程序(您的应用程序和默认的相机活动)。请参阅http://code.google.com/p/robotium/wiki/QuestionsAndAnswers
您需要在包中编写自己的相机实现,或者编写两个测试应用程序
希望这会有所帮助:)
according to the Robotium doc you cannot do this as this spans two applications ( your one and the default camera activity ). See http://code.google.com/p/robotium/wiki/QuestionsAndAnswers
You will either need to write your own camera implementation within your package or write two test applications
Hope this helps :)
你想要实现的目标绝对是可行的。您正在尝试通过系统内置功能来做到这一点。这里的问题是用户需要拍照并确认其有效。然后,结果(图像 URL)将返回到您的活动中。所以,它不是机器人。
另一种方法是使用 Android 为您提供对相机的完全控制的事实,
这绝对是要求更高的方法。但如果您使用 Android 安装中的现有示例作为指导,
它应该是可以实现的。不要忘记在清单中声明权限,如
Camera
SDK 文档中所述。What are you trying to achieve is definitely feasible. You are trying to do that via System built-in functionality. Issue here is that user is expected to take picture and confirm that it is valid. Than, result (image URL) is brought back to your activity. So, it is not robotium.
Another approach is to use fact that Android offers you complete control over Camera via
It is definitely more demanding approach. But if you use existing example from your Android installation as guideline
it should be achievable. Do not forget to declare permissions in your manifest, as descibed in the
Camera
SDK documentation.抱歉打扰了...
我刚刚将我制作/使用的相机存根放在游戏商店上...认为可能对您/其他人在自动化测试中测试相机有用:)
https://play.google.com/store/apps/details?id =com.hitherejoe.CameraStub&hl=en
Sorry to bump this...
I've just put the camera stub i made / use on the play store... thought might be of use to you / others for testing the camera in automated tests :)
https://play.google.com/store/apps/details?id=com.hitherejoe.CameraStub&hl=en