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.utils 18 19 import android.tools.Timestamps 20 import android.tools.traces.TraceConfig 21 import android.tools.traces.TraceConfigs 22 23 object TestTraces { 24 object LayerTrace { 25 private const val ASSET = "layers_trace.perfetto-trace" 26 val START_TIME = Timestamps.from(systemUptimeNanos = 1618663562444) 27 val SLICE_TIME = Timestamps.from(systemUptimeNanos = 1618715108595) 28 val END_TIME = Timestamps.from(systemUptimeNanos = 1620770824112) 29 val FILE 30 get() = readAssetAsFile(ASSET) 31 } 32 33 object WMTrace { 34 private const val ASSET = "wm_trace.winscope" 35 val START_TIME = Timestamps.from(elapsedNanos = 1618650751245) 36 val SLICE_TIME = Timestamps.from(elapsedNanos = 1618730362295) 37 val END_TIME = Timestamps.from(elapsedNanos = 1620756218174) 38 val FILE 39 get() = readAssetAsFile(ASSET) 40 } 41 42 object EventLog { 43 private const val ASSET = "eventlog.winscope" 44 // from CUJ event 45 val START_TIME = Timestamps.from(unixNanos = 100) 46 val SLICE_TIME = Timestamps.from(unixNanos = 1670594384516466159) 47 val END_TIME = Timestamps.from(unixNanos = 1670594389958451901) 48 val FILE 49 get() = readAssetAsFile(ASSET) 50 } 51 52 object TransactionTrace { 53 private const val ASSET = "transactions_trace.perfetto-trace" 54 val START_TIME = 55 Timestamps.from(systemUptimeNanos = 1556111744859, elapsedNanos = 1556111744859) 56 val VALID_SLICE_TIME = 57 Timestamps.from(systemUptimeNanos = 1556147625539, elapsedNanos = 1556147625539) 58 val INVALID_SLICE_TIME = Timestamps.from(systemUptimeNanos = 1622127714039 + 1) 59 val END_TIME = 60 Timestamps.from(systemUptimeNanos = 1622127714039, elapsedNanos = 1622127714039) 61 val FILE 62 get() = readAssetAsFile(ASSET) 63 } 64 65 object LegacyTransitionTrace { 66 private const val WM_ASSET = "wm_transition_trace.winscope" 67 private const val SHELL_ASSET = "shell_transition_trace.winscope" 68 69 val START_TIME = 70 Timestamps.from(elapsedNanos = 760760231809, systemUptimeNanos = 0, unixNanos = 0) 71 val VALID_SLICE_TIME = 72 Timestamps.from( 73 elapsedNanos = 2770105426934 - 1000, 74 systemUptimeNanos = 0, 75 unixNanos = 0 76 ) 77 val INVALID_SLICE_TIME = 78 Timestamps.from( 79 elapsedNanos = 2770105426934 + 1, 80 systemUptimeNanos = 0, 81 unixNanos = 0, 82 ) 83 val END_TIME = 84 Timestamps.from(elapsedNanos = 2770105426934, systemUptimeNanos = 0, unixNanos = 0) 85 86 val WM_FILE 87 get() = readAssetAsFile(WM_ASSET) 88 val SHELL_FILE 89 get() = readAssetAsFile(SHELL_ASSET) 90 } 91 92 object TransitionTrace { 93 private const val ASSET = "transitions.perfetto-trace" 94 95 val START_TIME = 96 Timestamps.from(elapsedNanos = 479583450794, systemUptimeNanos = 0, unixNanos = 0) 97 val VALID_SLICE_TIME = 98 Timestamps.from( 99 elapsedNanos = 479583450794 + 5000, 100 systemUptimeNanos = 0, 101 unixNanos = 0 102 ) 103 val INVALID_SLICE_TIME = 104 Timestamps.from( 105 elapsedNanos = 487330863192 + 1, 106 systemUptimeNanos = 0, 107 unixNanos = 0, 108 ) 109 val END_TIME = 110 Timestamps.from(elapsedNanos = 487330863192, systemUptimeNanos = 0, unixNanos = 0) 111 112 val FILE 113 get() = readAssetAsFile(ASSET) 114 } 115 116 object ProtoLogTrace { 117 private const val ASSET = "protolog.perfetto-trace" 118 119 val START_TIME = 120 Timestamps.from(elapsedNanos = 3663230963946, systemUptimeNanos = 0, unixNanos = 0) 121 val VALID_SLICE_TIME = 122 Timestamps.from( 123 elapsedNanos = 3663230963946 + 5000, 124 systemUptimeNanos = 0, 125 unixNanos = 0 126 ) 127 val INVALID_SLICE_TIME = 128 Timestamps.from( 129 elapsedNanos = 3672045108074 + 1, 130 systemUptimeNanos = 0, 131 unixNanos = 0, 132 ) 133 val END_TIME = 134 Timestamps.from(elapsedNanos = 3672045108074, systemUptimeNanos = 0, unixNanos = 0) 135 136 val FILE 137 get() = readAssetAsFile(ASSET) 138 } 139 140 val TIME_5 = Timestamps.from(5, 5, 5) 141 val TIME_10 = Timestamps.from(10, 10, 10) 142 143 val TEST_TRACE_CONFIG = 144 TraceConfigs( 145 wmTrace = 146 TraceConfig(required = false, allowNoChange = false, usingExistingTraces = false), 147 layersTrace = 148 TraceConfig(required = false, allowNoChange = false, usingExistingTraces = false), 149 transitionsTrace = 150 TraceConfig(required = false, allowNoChange = false, usingExistingTraces = false), 151 transactionsTrace = 152 TraceConfig(required = false, allowNoChange = false, usingExistingTraces = false) 153 ) 154 } 155