android - 如何为单元测试创建 CellInfo 对象?
问题描述
我正在编写单元测试用例,我无法理解的是如何制作 CellinfoGsm 或任何技术的虚拟对象并从中测试我的代码。我确实阅读了 CellInfo 的文档和基类,但我不明白如何使用 Creator,谁能给我一个示例,说明如何使用我自己的值制作我自己的对象以用于测试目的。任何帮助将不胜感激。
解决方案
我不太喜欢Android,现在只是想学习。你能让它像这样工作吗->
CellInfoGsm gsm = mirror.android.telephony.CellInfoGsm.ctor.newInstance(); CellIdentityGsm identityGsm = mirror.android.telephony.CellInfoGsm.mCellIdentityGsm.get(gsm); CellSignalStrengthGsm strengthGsm = mirror.android.telephony.CellInfoGsm.mCellSignalStrengthGsm.get(gsm); mirror.android.telephony.CellIdentityGsm.mMcc.set(identityGsm,cell.mcc);mirror.android.telephony.CellIdentityGsm.mMnc.set(identityGsm,cell.mnc);mirror.android.telephony.CellIdentityGsm.mLac.set(identityGsm,cell.lac);mirror.android.telephony.CellIdentityGsm.mCid.set(identityGsm,cell.cid);mirror.android.telephony.CellSignalStrengthGsm.mSignalStrength.set(strengthGsm, 20); mirror.android.telephony.CellSignalStrengthGsm.mBitErrorRate.set(strengthGsm, 0);
推荐阅读
- python - 当函数在导入的库中具有全局状态时出现多重处理问题
- python - Gurobi/Python 崩溃并显示“堆已损坏”错误消息
- graphviz - 强制一些连接是水平的
- html - 如何在 css/html 中实现这种风格?
- c# - 为什么 SQL Server 视图不适合与实体框架一起使用
- android - 是否可以使用 Android 或 WebOS 为普通电视开发自己的界面?
- javascript - javascript onclick是否在段落中显示时间和日期
- php - Wordpress Post Meta 仅适用于循环中的一篇文章
- python - 如何使用 Python 删除二叉搜索树中的节点
- sql-server - 如何让触发器等待?