• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.device.traces.io
18 
19 import android.tools.common.Timestamp
20 import android.tools.common.io.Artifact
21 import android.tools.common.io.RunStatus
22 import android.tools.common.io.TransitionTimeRange
23 
24 /**
25  * Contents of a flicker run (e.g. files, status, event log)
26  *
27  * @param _artifact Path to the artifact file
28  * @param _transitionTimeRange Transition start and end time
29  * @param _executionError Transition execution error (if any)
30  */
31 open class ResultData(
32     _artifact: Artifact,
33     _transitionTimeRange: TransitionTimeRange,
34     _executionError: Throwable?
35 ) : IResultData {
36     final override val artifact: Artifact = _artifact
37     final override val transitionTimeRange: TransitionTimeRange = _transitionTimeRange
38     final override val executionError: Throwable? = _executionError
39     final override val runStatus: RunStatus
40         get() = artifact.runStatus
41 
42     /** {@inheritDoc} */
<lambda>null43     override fun slice(startTimestamp: Timestamp, endTimestamp: Timestamp) = apply {
44         require(startTimestamp.hasAllTimestamps)
45         require(endTimestamp.hasAllTimestamps)
46         return ResultData(
47             artifact,
48             TransitionTimeRange(startTimestamp, endTimestamp),
49             executionError
50         )
51     }
52 
<lambda>null53     override fun toString(): String = buildString {
54         append(artifact)
55         append(" (status=")
56         append(runStatus)
57         executionError?.let {
58             append(", error=")
59             append(it.message)
60         }
61         append(") ")
62     }
63 
64     /** {@inheritDoc} */
<lambda>null65     override fun updateStatus(newStatus: RunStatus) = apply { artifact.updateStatus(newStatus) }
66 }
67