1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.tools.common.io 18 19 import android.tools.common.Tag 20 import android.tools.common.Timestamp 21 import android.tools.common.traces.events.CujTrace 22 import android.tools.common.traces.events.EventLog 23 import android.tools.common.traces.surfaceflinger.LayersTrace 24 import android.tools.common.traces.surfaceflinger.TransactionsTrace 25 import android.tools.common.traces.wm.TransitionsTrace 26 import android.tools.common.traces.wm.WindowManagerTrace 27 28 /** Helper class to read results from a flicker artifact */ 29 interface Reader { 30 val artifact: Artifact 31 val artifactPath: String 32 val executionError: Throwable? 33 val runStatus: RunStatus 34 val isFailure: Boolean 35 get() = runStatus.isFailure 36 37 /** @return a [WindowManagerTrace] from the dump associated to [tag] */ readWmStatenull38 fun readWmState(tag: String): WindowManagerTrace? 39 40 /** @return a [WindowManagerTrace] for the part of the trace we want to run the assertions on */ 41 fun readWmTrace(): WindowManagerTrace? 42 43 /** @return a [LayersTrace] for the part of the trace we want to run the assertions on */ 44 fun readLayersTrace(): LayersTrace? 45 46 /** @return a [LayersTrace] from the dump associated to [tag] */ 47 fun readLayersDump(tag: String): LayersTrace? 48 49 /** @return a [TransactionsTrace] for the part of the trace we want to run the assertions on */ 50 fun readTransactionsTrace(): TransactionsTrace? 51 52 /** @return a [TransitionsTrace] for the part of the trace we want to run the assertions on */ 53 fun readTransitionsTrace(): TransitionsTrace? 54 55 /** @return an [EventLog] for the part of the trace we want to run the assertions on */ 56 fun readEventLogTrace(): EventLog? 57 58 /** @return a [CujTrace] for the part of the trace we want to run the assertions on */ 59 fun readCujTrace(): CujTrace? 60 61 /** @return an [Reader] for the subsection of the trace we are reading in this reader */ 62 fun slice(startTimestamp: Timestamp, endTimestamp: Timestamp): Reader 63 64 /** 65 * @return [ByteArray] with the contents of a file from the artifact, or null if the file 66 * doesn't exist 67 */ 68 fun readBytes(traceType: TraceType, tag: String = Tag.ALL): ByteArray? 69 } 70