安全测试用例
public class SecurityTestCase
extends StsExtraBusinessLogicHostTestBase
java.lang.Object |
↳ | com.android.tradefed.testtype.junit4.BaseHostJUnit4Test |
| ↳ | com.android.compatibility.common.tradefed.testtype.BusinessLogicHostTestBase |
| | ↳ | com.android.compatibility.common.tradefed.testtype.ExtraBusinessLogicHostTestBase |
| | | ↳ | com.android.sts.common.tradefed.testtype.StsExtraBusinessLogicHostTestBase |
| | | | ↳ | com.android.sts.common.tradefed.testtype.SecurityTestCase |
所有 STS 测试的基础测试类。
请改用RootSecurityTestCase
或NonRootSecurityTestCase
。
概括
受保护的方法 |
---|
boolean | containsDriver (ITestDevice device, String driver, boolean checkReadable) 检查机器上是否存在驱动程序。 |
boolean | containsDriver (ITestDevice device, String driver) 检查驱动程序是否存在且可读。 |
常量
TIMEOUT_DEFAULT
protected static final int TIMEOUT_DEFAULT
常数值:60 (0x0000003c)
TIMEOUT_NONDETERMINISTIC
public static final int TIMEOUT_NONDETERMINISTIC
常数值:315 (0x0000013b)
领域
测试名称
public TestName testName
公共构造函数
安全测试用例
public SecurityTestCase ()
公共方法
断言匹配
public void assertMatches (String pattern,
String input)
参数 |
---|
pattern | String |
input | String |
断言匹配多行
public void assertMatchesMultiLine (String pattern,
String input)
参数 |
---|
pattern | String |
input | String |
assertNotKernelPointer
public void assertNotKernelPointer (Callable<String> getPtrFunction,
ITestDevice deviceToReboot)
运行提供的函数,该函数收集 String 以测试内核指针泄漏。 getPtrFunction 函数实现必须返回一个以指针开头的字符串。即“01234567”。除了 [0-9a-fA-F] 之外,允许使用尾随字符。如果指针似乎易受攻击,则会抛出 JUnit 断言。由于可以对内核指针进行散列处理,因此散列指针有可能重叠到正常的内核空间中。重新运行测试以使误报在统计上不显着。当内核指针在不重启的情况下不会改变时,提供一个设备来重启。
参数 |
---|
getPtrFunction | Callable :返回以指针开头的字符串的函数 |
deviceToReboot | ITestDevice :当内核指针不会改变时重启的设备 |
断言不匹配
public void assertNotMatches (String pattern,
String input)
参数 |
---|
pattern | String |
input | String |
assertNotMatchesMultiLine
public void assertNotMatchesMultiLine (String pattern,
String input)
参数 |
---|
pattern | String |
input | String |
断言 Wifi 已连接
public void assertWifiConnected (ITestDevice device)
断言 wifi 连接状态已连接。由于 STS 可以在运行测试之前立即重启设备,因此在测试运行之前可能无法连接 wifi。我们轮询 wifi,直到超时或 wifi 已连接。
参数 |
---|
device | ITestDevice :要运行的设备 |
assumeIsSupportedNfcDevice
public void assumeIsSupportedNfcDevice (ITestDevice device)
buildMetricsReportLog
public static MetricsReportLog buildMetricsReportLog (ITestDevice device)
创建WifiHelper
public WifiHelper createWifiHelper ()
投掷 |
---|
DeviceNotAvailableException | |
得到阿比
public static IAbi getAbi (ITestDevice device)
获取构建信息
public static IBuildInfo getBuildInfo (ITestDevice device)
获取PocPusher
public static PocPusher getPocPusher (ITestDevice device)
获取测试名
public static String getTestName (ITestDevice device)
moduleIsPlayManaged
public boolean moduleIsPlayManaged (String modulePackageName)
如果模块是播放管理的,则返回 true。
基于主线模块跳过测试的示例:
@Test
public void testPocCVE_1234_5678() throws Exception {
// This will skip the test if MODULE_METADATA mainline module is play managed.
assumeFalse(moduleIsPlayManaged("com.google.android.captiveportallogin"));
// Do testing...
}
参数 |
---|
modulePackageName | String |
安全重启
public void safeReboot ()
投掷 |
---|
DeviceNotAvailableException | |
设置
public void setUp ()
等待设备上线,标记设备的最近启动时间
拆除
public void tearDown ()
确保手机在线并检查设备是否崩溃
更新内核启动时间
public void updateKernelStartTime ()
如果在计划重启后调用,则允许测试通过。
投掷 |
---|
DeviceNotAvailableException | |
受保护的方法
包含驱动程序
protected boolean containsDriver (ITestDevice device,
String driver,
boolean checkReadable)
检查机器上是否存在驱动程序。
参数 |
---|
device | ITestDevice |
driver | String |
checkReadable | boolean |
包含驱动程序
protected boolean containsDriver (ITestDevice device,
String driver)
检查驱动程序是否存在且可读。
参数 |
---|
device | ITestDevice |
driver | String |