2.0 KiB
2.0 KiB
TrustTests framework tests
These tests test the "trust" part of the platform primarily implemented via TrustManagerService in the system server and TrustAgentService in system apps.
Tests are separated into separate files based on major groupings. When creating new tests, find a closely matching existing test file or create a new test file. Prefer many test files over large test files.
Each test file has its own trust agent. To create a new trust agent:
- Create a new class extending from
BaseTrustAgentService
class in your test file - Add a new
<service>
stanza toAndroidManifest.xml
in this directory for the new agent following the pattern fo the existing agents.
To run:
atest TrustTests
Testing approach:
- Test the agent service as a black box; avoid inspecting internal state of the service or modifying the system code outside of this directory.
- The primary interface to the system is through these three points:
TrustAgentService
, your agent created by theTrustAgentRule
and accessible via theagent
property of the rule.- Call command methods (e.g.
grantTrust
) directly on the agent - Listen to events (e.g.
onUserRequestedUnlock
) by implementing the method in your test's agent class and tracking invocations. SeeUserUnlockRequestTest
for an example.
- Call command methods (e.g.
TrustManager
which is the interface the rest of the system (e.g. SystemUI) has to the service.- Through this API, simulate system events that the service cares about
(e.g.
reportUnlockAttempt
).
- Through this API, simulate system events that the service cares about
(e.g.
TrustListener
which is the interface the rest of the system (e.g. SystemUI) uses to receive events from the service.- Through this, verify behavior that affects the rest of the system. For example,
see
LockStateTrackingRule
.
- Through this, verify behavior that affects the rest of the system. For example,
see
- To re-use code between tests, prefer creating new rules alongside the existing rules or adding functionality to a closely matching existing rule.