Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
061bf534
Commit
061bf534
authored
1 year ago
by
Pablo Gamito
Committed by
Android (Google) Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Add test for tracing onFlush()" into main
parents
04fd24fc
f002f79b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/tests/coretests/src/android/tracing/perfetto/DataSourceTest.java
+46
-0
46 additions, 0 deletions
...oretests/src/android/tracing/perfetto/DataSourceTest.java
with
46 additions
and
0 deletions
core/tests/coretests/src/android/tracing/perfetto/DataSourceTest.java
+
46
−
0
View file @
061bf534
...
...
@@ -658,6 +658,52 @@ public class DataSourceTest {
Truth
.
assertThat
(
matchingPackets
).
hasSize
(
1
);
}
@Test
public
void
canTraceOnFlush
()
throws
InvalidProtocolBufferException
,
InterruptedException
{
final
int
singleIntValue
=
101
;
sInstanceProvider
=
(
ds
,
idx
,
config
)
->
new
TestDataSource
.
TestDataSourceInstance
(
ds
,
idx
,
(
args
)
->
{},
(
args
)
->
sTestDataSource
.
trace
(
ctx
->
{
final
ProtoOutputStream
protoOutputStream
=
ctx
.
newTracePacket
();
long
forTestingToken
=
protoOutputStream
.
start
(
FOR_TESTING
);
long
payloadToken
=
protoOutputStream
.
start
(
PAYLOAD
);
protoOutputStream
.
write
(
SINGLE_INT
,
singleIntValue
);
protoOutputStream
.
end
(
payloadToken
);
protoOutputStream
.
end
(
forTestingToken
);
ctx
.
flush
();
}),
(
args
)
->
{}
);
final
TraceMonitor
traceMonitor
=
PerfettoTraceMonitor
.
newBuilder
()
.
enableCustomTrace
(
PerfettoConfig
.
DataSourceConfig
.
newBuilder
()
.
setName
(
sTestDataSource
.
name
).
build
()).
build
();
try
{
traceMonitor
.
start
();
}
finally
{
traceMonitor
.
stop
(
mWriter
);
}
final
ResultReader
reader
=
new
ResultReader
(
mWriter
.
write
(),
mTraceConfig
);
final
byte
[]
rawProtoFromFile
=
reader
.
readBytes
(
TraceType
.
PERFETTO
,
Tag
.
ALL
);
assert
rawProtoFromFile
!=
null
;
final
perfetto
.
protos
.
TraceOuterClass
.
Trace
trace
=
perfetto
.
protos
.
TraceOuterClass
.
Trace
.
parseFrom
(
rawProtoFromFile
);
Truth
.
assertThat
(
trace
.
getPacketCount
()).
isGreaterThan
(
0
);
final
List
<
TracePacketOuterClass
.
TracePacket
>
tracePackets
=
trace
.
getPacketList
()
.
stream
().
filter
(
TracePacketOuterClass
.
TracePacket
::
hasForTesting
).
toList
();
final
List
<
TracePacketOuterClass
.
TracePacket
>
matchingPackets
=
tracePackets
.
stream
()
.
filter
(
it
->
it
.
getForTesting
().
getPayload
().
getSingleInt
()
==
singleIntValue
).
toList
();
Truth
.
assertThat
(
matchingPackets
).
hasSize
(
1
);
}
interface
RunnableCreator
{
Runnable
create
(
int
state
,
AtomicInteger
stateOut
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment