如何在仪器测试的关键事件发送到一个无头模拟器? [英] how to send key events to a headless emulator in an instrumentation test?

查看:138
本文介绍了如何在仪器测试的关键事件发送到一个无头模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们正在上运行我们的构建服务器上的仪器测试套件,但在测试通过使用普通的Andr​​oid模拟器一个开发机器上,这些版本无法生成服务器上,因为在那里,我们只运行一个无头仿真器该-no窗口标志。

We are currently working on an instrumentation test suite which runs on our build server, but while the tests pass on a dev machine using a normal Android emulator, the builds fail on the build server since there we only run a headless emulator with the -no-window flag.

的失败尝试调用InstrumentationTestCase.sendKeys()方法以编程方式打开选项菜单时出现。错误是:

The failure occurs when trying to invoke the InstrumentationTestCase.sendKeys() method to programatically open the options menu. The error is:

权限被拒绝:注射关键事件来自PID 646 UID 10026到窗口窗口{43d55100暂停= FALSE}通过UID 1000拥有

Permission denied: injecting key event from pid 646 uid 10026 to window Window{43d55100 paused=false} owned by uid 1000

然后,我们发现,有一个INJECT_EVENTS许可,但在清单中设置它没有任何效果。其实在日志中,我们看到这样的输出:

We then found out that there's a INJECT_EVENTS permission, but setting it in the manifest had no effect. In fact in the log we saw this output:

未授予权限android.permission.INJECT_EVENTS打包com.qype.radar(的ProtectionLevel = 2标志= 0x6644)

Not granting permission android.permission.INJECT_EVENTS to package com.qype.radar (protectionLevel=2 flags=0x6644)

这是否意味着此权限是没用的?

does that mean this permission is useless?

我们还试图让被测共享相同的Linux用户ID的仪器测试程序和应用程序采用了android:sharedUserId,并在同一个进程中运行(安卓过程 - 我们不知道这已经是案件),但仍没有运气。

We also tried to let the instrumentation test app and the app under test share the same Linux user ID using android:sharedUserId and run in the same process (android:process -- we weren't sure if that was already the case), but still no luck.

这是否意味着它目前无法运行包含在一具无头仿真关键事件,还是我们失去了一些东西?仪器仪表

Does this mean it's currently impossible to run instrumentations which contain key events on a headless emulator, or are we missing something?

推荐答案

我有类似的问题,我哈得逊服务器上测试。在我来说,这个问题我解决了从Android SDK中建议: 的http://developer.android.com/guide/topics/testing/testing_android.html#UITestTroubleshooting

I had similar problem with my test on the Hudson server. In my case the problem I solved by suggestion from Android SDK: http://developer.android.com/guide/topics/testing/testing_android.html#UITestTroubleshooting

重要的是,我不得不启用主应用程序的权限了。

Important was that I had to enable permissions for main application too.

这篇关于如何在仪器测试的关键事件发送到一个无头模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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