Robotium如何与后台服务,如转换测试?

编程入门 行业动态 更新时间:2024-10-27 16:39:34
本文介绍了Robotium如何与后台服务,如转换测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Robotium录音机来测试我的应用程序。我的问题是在我的应用我正在基于多少时间用户记录在做背景,还需要一段时间的音频转换。

I am using Robotium Recorder to test my app. My problem is in my app i am doing audio conversions in background which take some time based on how much time user is recording.

示例

如果我运行一个测试,记录了10分钟这样每次(转换背景)的10倍,它记录这样的当我最后一次记录是10日录制完成robotium退出并杀死应用程序。

If i am running a test which records for 10mins (Converts in background) each time like this 10 times it records so when my last recording that is 10th recording finishes robotium exits and kill the app.

**问题: - 对于最后的录音我的文件仍然需要转换其背景(服务),但应用程序转换是杀了那么转换失败。我不能使用solo.sleep(INT),因为我不知道这将需要多长时间来转换**

推荐答案

最后我得到了解决。

在 testRun()函数调用 isServiceRunning()功能。

public void testRun() { . . if(isSurviceRunning()) { solo.sleep(time); } }

这为您的应用程序的后台服务的方法检查,并返回boolean值。

This method check for background services of your app and return boolean.

public boolean isServiceRunning() { ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.pakage.name.yourcls.your_service_name".equals(service.service.getClassName())) { Log.d("Running Service is->", "" + service.service.getClassName()); return true; } else { Log.d("false", "" + service.service.getClassName()); } } return false; }

更多推荐

Robotium如何与后台服务,如转换测试?

本文发布于:2023-11-27 05:00:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后台   测试   Robotium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!