首页 > 解决方案 > 如何为单元测试创​​建 CellInfo 对象?

问题描述

我正在编写单元测试用例,我无法理解的是如何制作 CellinfoGsm 或任何技术的虚拟对象并从中测试我的代码。我确实阅读了 CellInfo 的文档和基类,但我不明白如何使用 Creator,谁能给我一个示例,说明如何使用我自己的值制作我自己的对象以用于测试目的。任何帮助将不胜感激。

标签: androidunit-testingparcelablecellinfocellinfogsm

解决方案


我不太喜欢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);


推荐阅读