JankTestBase

public class JankTestBase
extends InstrumentationTestCase

java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ android.test.InstrumentationTestCase
         ↳ android.support.test.jank.JankTestBase


用于测量Jank的基础测试类。 这个测试类在执行每种测试方法时自动监测jank。 根据'迭代'命令行参数,每个测试方法在循环中执行多次。 要为每次迭代执行其他设置/拆卸步骤,子类可以选择覆盖beforeLoop()afterLoop()方法。 测试方法必须使用JankTest注释进行配置。 至少要指定要测量的结果类型和期望帧的数量。

Summary

Public constructors

JankTestBase()

Public methods

void afterLoop()

每次迭代测试方法后调用。

void afterTest(Bundle metrics)

所有迭代完成后调用一次。

void beforeLoop()

在每次迭代测试方法之前调用。

void beforeTest()

在执行测试方法之前调用一次。

final int getCurrentIteration()

返回当前正在执行的迭代的索引。

Protected methods

IMonitorFactory createMonitorFactory()

创建一个 IMonitorFactory实例,该实例应该用于为 IMonitor中的测试方法构造 IMonitor (s)。

final Bundle getArguments()

返回包含命令行参数的 Bundle

IMonitorFactory getMonitorFactory()

对于给定的测试方法,返回应该用于构造适用的 IMonitor (s)的 IMonitorFactory实例。

List<IMonitor> getMonitors(Method method)

返回列表 IMonitor应适用于将指定的 method

void runTest()

Inherited methods

From class android.test.InstrumentationTestCase
From class junit.framework.TestCase
From class junit.framework.Assert
From class java.lang.Object
From interface junit.framework.Test

Public constructors

JankTestBase

JankTestBase ()

Public methods

afterLoop

void afterLoop ()

每次迭代测试方法后调用。

Throws
异常

afterTest

void afterTest (Bundle metrics)

所有迭代完成后调用一次。

注意:默认实现通过 sendStatus(int, Bundle)报告汇总的jank度量标准

Parameters
metrics Bundle: the aggregated jank metrics after looped execution

beforeLoop

void beforeLoop ()

在每次迭代测试方法之前调用。

Throws
异常

beforeTest

void beforeTest ()

在执行测试方法之前调用一次。

Throws
异常

getCurrentIteration

int getCurrentIteration ()

返回当前正在执行的迭代的索引。

Returns
int

Protected methods

createMonitorFactory

IMonitorFactory createMonitorFactory ()

创建一个 IMonitorFactory实例,该实例应该用于为 IMonitor中的测试方法构造 IMonitor (s)。

Returns
IMonitorFactory

getArguments

Bundle getArguments ()

返回包含命令行参数的 Bundle

Returns
Bundle

getMonitorFactory

IMonitorFactory getMonitorFactory ()

返回应该用于为给定测试方法构造适用 IMonitor (s)的 IMonitorFactory实例。

Returns
IMonitorFactory

getMonitors

List<IMonitor> getMonitors (Method method)

返回列表 IMonitor应适用于将指定的 method

Parameters
method 方法
Returns
List<IMonitor>

runTest

void runTest ()

Throws
Throwable