| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2021 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 | #include <gmock/gmock.h> | 
|  | 18 | #include <gtest/gtest.h> | 
|  | 19 |  | 
|  | 20 | #include <gui/SurfaceComposerClient.h> | 
|  | 21 |  | 
|  | 22 | #include "Tracing/RingBuffer.h" | 
|  | 23 | #include "Tracing/TransactionTracing.h" | 
|  | 24 |  | 
|  | 25 | using namespace android::surfaceflinger; | 
|  | 26 |  | 
|  | 27 | namespace android { | 
|  | 28 |  | 
|  | 29 | class TransactionTracingTest : public testing::Test { | 
|  | 30 | protected: | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 31 | static constexpr size_t SMALL_BUFFER_SIZE = 1024; | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 32 | TransactionTracing mTracing; | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 33 |  | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 34 | void flush(int64_t vsyncId) { mTracing.flush(vsyncId); } | 
|  | 35 | proto::TransactionTraceFile writeToProto() { return mTracing.writeToProto(); } | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 36 |  | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 37 | proto::TransactionTraceEntry bufferFront() { | 
|  | 38 | std::scoped_lock<std::mutex> lock(mTracing.mTraceLock); | 
| Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 39 | proto::TransactionTraceEntry entry; | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 40 | entry.ParseFromString(mTracing.mBuffer.front()); | 
| Vishnu Nair | 6286355 | 2021-12-10 13:34:48 -0800 | [diff] [blame] | 41 | return entry; | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 42 | } | 
|  | 43 |  | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 44 | void queueAndCommitTransaction(int64_t vsyncId) { | 
|  | 45 | TransactionState transaction; | 
|  | 46 | transaction.id = static_cast<uint64_t>(vsyncId * 3); | 
|  | 47 | transaction.originUid = 1; | 
|  | 48 | transaction.originPid = 2; | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 49 | mTracing.addQueuedTransaction(transaction); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 50 | std::vector<TransactionState> transactions; | 
|  | 51 | transactions.emplace_back(transaction); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 52 | mTracing.addCommittedTransactions(transactions, vsyncId); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 53 | flush(vsyncId); | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 54 | } | 
|  | 55 |  | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 56 | void verifyEntry(const proto::TransactionTraceEntry& actualProto, | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 57 | const std::vector<TransactionState>& expectedTransactions, | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 58 | int64_t expectedVsyncId) { | 
|  | 59 | EXPECT_EQ(actualProto.vsync_id(), expectedVsyncId); | 
|  | 60 | EXPECT_EQ(actualProto.transactions().size(), | 
|  | 61 | static_cast<int32_t>(expectedTransactions.size())); | 
|  | 62 | for (uint32_t i = 0; i < expectedTransactions.size(); i++) { | 
|  | 63 | EXPECT_EQ(actualProto.transactions(static_cast<int32_t>(i)).pid(), | 
|  | 64 | expectedTransactions[i].originPid); | 
|  | 65 | } | 
|  | 66 | } | 
|  | 67 | }; | 
|  | 68 |  | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 69 | TEST_F(TransactionTracingTest, addTransactions) { | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 70 | std::vector<TransactionState> transactions; | 
|  | 71 | transactions.reserve(100); | 
|  | 72 | for (uint64_t i = 0; i < 100; i++) { | 
|  | 73 | TransactionState transaction; | 
|  | 74 | transaction.id = i; | 
|  | 75 | transaction.originPid = static_cast<int32_t>(i); | 
|  | 76 | transactions.emplace_back(transaction); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 77 | mTracing.addQueuedTransaction(transaction); | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 78 | } | 
|  | 79 |  | 
|  | 80 | // Split incoming transactions into two and commit them in reverse order to test out of order | 
|  | 81 | // commits. | 
|  | 82 | std::vector<TransactionState> firstTransactionSet = | 
|  | 83 | std::vector<TransactionState>(transactions.begin() + 50, transactions.end()); | 
|  | 84 | int64_t firstTransactionSetVsyncId = 42; | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 85 | mTracing.addCommittedTransactions(firstTransactionSet, firstTransactionSetVsyncId); | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 86 |  | 
|  | 87 | int64_t secondTransactionSetVsyncId = 43; | 
|  | 88 | std::vector<TransactionState> secondTransactionSet = | 
|  | 89 | std::vector<TransactionState>(transactions.begin(), transactions.begin() + 50); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 90 | mTracing.addCommittedTransactions(secondTransactionSet, secondTransactionSetVsyncId); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 91 | flush(secondTransactionSetVsyncId); | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 92 |  | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 93 | proto::TransactionTraceFile proto = writeToProto(); | 
| Vishnu Nair | b8f2a2d | 2022-01-13 08:10:10 -0800 | [diff] [blame] | 94 | EXPECT_EQ(proto.entry().size(), 2); | 
|  | 95 | verifyEntry(proto.entry(0), firstTransactionSet, firstTransactionSetVsyncId); | 
|  | 96 | verifyEntry(proto.entry(1), secondTransactionSet, secondTransactionSetVsyncId); | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 97 | } | 
|  | 98 |  | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 99 | class TransactionTracingLayerHandlingTest : public TransactionTracingTest { | 
|  | 100 | protected: | 
|  | 101 | void SetUp() override { | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 102 | // add layers | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 103 | mTracing.setBufferSize(SMALL_BUFFER_SIZE); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 104 | const sp<IBinder> fakeLayerHandle = new BBinder(); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 105 | mTracing.onLayerAdded(fakeLayerHandle->localBinder(), mParentLayerId, "parent", | 
|  | 106 | 123 /* flags */, -1 /* parentId */); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 107 | const sp<IBinder> fakeChildLayerHandle = new BBinder(); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 108 | mTracing.onLayerAdded(fakeChildLayerHandle->localBinder(), mChildLayerId, "child", | 
|  | 109 | 456 /* flags */, mParentLayerId); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 110 |  | 
|  | 111 | // add some layer transaction | 
|  | 112 | { | 
|  | 113 | TransactionState transaction; | 
|  | 114 | transaction.id = 50; | 
|  | 115 | ComposerState layerState; | 
|  | 116 | layerState.state.surface = fakeLayerHandle; | 
|  | 117 | layerState.state.what = layer_state_t::eLayerChanged; | 
|  | 118 | layerState.state.z = 42; | 
|  | 119 | transaction.states.add(layerState); | 
|  | 120 | ComposerState childState; | 
|  | 121 | childState.state.surface = fakeChildLayerHandle; | 
| Vishnu Nair | 473838d | 2021-12-08 09:46:02 -0800 | [diff] [blame] | 122 | childState.state.what = layer_state_t::eLayerChanged; | 
|  | 123 | childState.state.z = 43; | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 124 | transaction.states.add(childState); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 125 | mTracing.addQueuedTransaction(transaction); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 126 |  | 
|  | 127 | std::vector<TransactionState> transactions; | 
|  | 128 | transactions.emplace_back(transaction); | 
|  | 129 | VSYNC_ID_FIRST_LAYER_CHANGE = ++mVsyncId; | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 130 | mTracing.addCommittedTransactions(transactions, VSYNC_ID_FIRST_LAYER_CHANGE); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 131 | flush(VSYNC_ID_FIRST_LAYER_CHANGE); | 
|  | 132 | } | 
|  | 133 |  | 
|  | 134 | // add transactions that modify the layer state further so we can test that layer state | 
|  | 135 | // gets merged | 
|  | 136 | { | 
|  | 137 | TransactionState transaction; | 
|  | 138 | transaction.id = 51; | 
|  | 139 | ComposerState layerState; | 
|  | 140 | layerState.state.surface = fakeLayerHandle; | 
|  | 141 | layerState.state.what = layer_state_t::eLayerChanged | layer_state_t::ePositionChanged; | 
|  | 142 | layerState.state.z = 41; | 
|  | 143 | layerState.state.x = 22; | 
|  | 144 | transaction.states.add(layerState); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 145 | mTracing.addQueuedTransaction(transaction); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 146 |  | 
|  | 147 | std::vector<TransactionState> transactions; | 
|  | 148 | transactions.emplace_back(transaction); | 
|  | 149 | VSYNC_ID_SECOND_LAYER_CHANGE = ++mVsyncId; | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 150 | mTracing.addCommittedTransactions(transactions, VSYNC_ID_SECOND_LAYER_CHANGE); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 151 | flush(VSYNC_ID_SECOND_LAYER_CHANGE); | 
|  | 152 | } | 
|  | 153 |  | 
|  | 154 | // remove child layer | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 155 | mTracing.onLayerRemoved(2); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 156 | VSYNC_ID_CHILD_LAYER_REMOVED = ++mVsyncId; | 
|  | 157 | queueAndCommitTransaction(VSYNC_ID_CHILD_LAYER_REMOVED); | 
|  | 158 |  | 
|  | 159 | // remove layer | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 160 | mTracing.onLayerRemoved(1); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 161 | queueAndCommitTransaction(++mVsyncId); | 
|  | 162 | } | 
|  | 163 |  | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 164 | int mParentLayerId = 1; | 
| Vishnu Nair | 473838d | 2021-12-08 09:46:02 -0800 | [diff] [blame] | 165 | int mChildLayerId = 2; | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 166 | int64_t mVsyncId = 0; | 
|  | 167 | int64_t VSYNC_ID_FIRST_LAYER_CHANGE; | 
|  | 168 | int64_t VSYNC_ID_SECOND_LAYER_CHANGE; | 
|  | 169 | int64_t VSYNC_ID_CHILD_LAYER_REMOVED; | 
|  | 170 | }; | 
|  | 171 |  | 
|  | 172 | TEST_F(TransactionTracingLayerHandlingTest, addStartingState) { | 
|  | 173 | // add transactions until we drop the transaction with the first layer change | 
|  | 174 | while (bufferFront().vsync_id() <= VSYNC_ID_FIRST_LAYER_CHANGE) { | 
|  | 175 | queueAndCommitTransaction(++mVsyncId); | 
|  | 176 | } | 
|  | 177 | proto::TransactionTraceFile proto = writeToProto(); | 
|  | 178 | // verify we can still retrieve the layer change from the first entry containing starting | 
|  | 179 | // states. | 
|  | 180 | EXPECT_GT(proto.entry().size(), 0); | 
| Vishnu Nair | 685cfef | 2022-02-02 10:01:25 -0800 | [diff] [blame] | 181 | EXPECT_EQ(proto.entry(0).transactions().size(), 1); | 
|  | 182 | EXPECT_EQ(proto.entry(0).added_layers().size(), 2); | 
| Vishnu Nair | 473838d | 2021-12-08 09:46:02 -0800 | [diff] [blame] | 183 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 2); | 
|  | 184 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).layer_id(), mParentLayerId); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 185 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).z(), 42); | 
| Vishnu Nair | 473838d | 2021-12-08 09:46:02 -0800 | [diff] [blame] | 186 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(1).layer_id(), mChildLayerId); | 
|  | 187 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(1).z(), 43); | 
| Vishnu Nair | 0cc69e1 | 2021-11-18 09:05:49 -0800 | [diff] [blame] | 188 | } | 
|  | 189 |  | 
|  | 190 | TEST_F(TransactionTracingLayerHandlingTest, updateStartingState) { | 
|  | 191 | // add transactions until we drop the transaction with the second layer change | 
|  | 192 | while (bufferFront().vsync_id() <= VSYNC_ID_SECOND_LAYER_CHANGE) { | 
|  | 193 | queueAndCommitTransaction(++mVsyncId); | 
|  | 194 | } | 
|  | 195 | proto::TransactionTraceFile proto = writeToProto(); | 
|  | 196 | // verify starting states are updated correctly | 
|  | 197 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).z(), 41); | 
|  | 198 | } | 
|  | 199 |  | 
|  | 200 | TEST_F(TransactionTracingLayerHandlingTest, removeStartingState) { | 
|  | 201 | // add transactions until we drop the transaction which removes the child layer | 
|  | 202 | while (bufferFront().vsync_id() <= VSYNC_ID_CHILD_LAYER_REMOVED) { | 
|  | 203 | queueAndCommitTransaction(++mVsyncId); | 
|  | 204 | } | 
|  | 205 | proto::TransactionTraceFile proto = writeToProto(); | 
|  | 206 | // verify the child layer has been removed from the trace | 
|  | 207 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 1); | 
|  | 208 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).layer_id(), mParentLayerId); | 
|  | 209 | } | 
|  | 210 |  | 
|  | 211 | TEST_F(TransactionTracingLayerHandlingTest, startingStateSurvivesBufferFlush) { | 
|  | 212 | // add transactions until we drop the transaction with the second layer change | 
|  | 213 | while (bufferFront().vsync_id() <= VSYNC_ID_SECOND_LAYER_CHANGE) { | 
|  | 214 | queueAndCommitTransaction(++mVsyncId); | 
|  | 215 | } | 
|  | 216 | proto::TransactionTraceFile proto = writeToProto(); | 
|  | 217 | // verify we have two starting states | 
|  | 218 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 2); | 
|  | 219 |  | 
|  | 220 | // Continue adding transactions until child layer is removed | 
|  | 221 | while (bufferFront().vsync_id() <= VSYNC_ID_CHILD_LAYER_REMOVED) { | 
|  | 222 | queueAndCommitTransaction(++mVsyncId); | 
|  | 223 | } | 
|  | 224 | proto = writeToProto(); | 
|  | 225 | // verify we still have the parent layer state | 
|  | 226 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 1); | 
|  | 227 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(0).layer_id(), mParentLayerId); | 
|  | 228 | } | 
|  | 229 |  | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 230 | class TransactionTracingMirrorLayerTest : public TransactionTracingTest { | 
|  | 231 | protected: | 
|  | 232 | void SetUp() override { | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 233 | // add layers | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 234 | mTracing.setBufferSize(SMALL_BUFFER_SIZE); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 235 | const sp<IBinder> fakeLayerHandle = new BBinder(); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 236 | mTracing.onLayerAdded(fakeLayerHandle->localBinder(), mLayerId, "Test Layer", | 
|  | 237 | 123 /* flags */, -1 /* parentId */); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 238 | const sp<IBinder> fakeMirrorLayerHandle = new BBinder(); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 239 | mTracing.onMirrorLayerAdded(fakeMirrorLayerHandle->localBinder(), mMirrorLayerId, "Mirror", | 
|  | 240 | mLayerId); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 241 |  | 
|  | 242 | // add some layer transaction | 
|  | 243 | { | 
|  | 244 | TransactionState transaction; | 
|  | 245 | transaction.id = 50; | 
|  | 246 | ComposerState layerState; | 
|  | 247 | layerState.state.surface = fakeLayerHandle; | 
|  | 248 | layerState.state.what = layer_state_t::eLayerChanged; | 
|  | 249 | layerState.state.z = 42; | 
|  | 250 | transaction.states.add(layerState); | 
|  | 251 | ComposerState mirrorState; | 
|  | 252 | mirrorState.state.surface = fakeMirrorLayerHandle; | 
|  | 253 | mirrorState.state.what = layer_state_t::eLayerChanged; | 
|  | 254 | mirrorState.state.z = 43; | 
|  | 255 | transaction.states.add(mirrorState); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 256 | mTracing.addQueuedTransaction(transaction); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 257 |  | 
|  | 258 | std::vector<TransactionState> transactions; | 
|  | 259 | transactions.emplace_back(transaction); | 
| Dominik Laskowski | 46471e6 | 2022-01-14 15:34:03 -0800 | [diff] [blame] | 260 | mTracing.addCommittedTransactions(transactions, ++mVsyncId); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 261 | flush(mVsyncId); | 
|  | 262 | } | 
|  | 263 | } | 
|  | 264 |  | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 265 | int mLayerId = 5; | 
|  | 266 | int mMirrorLayerId = 55; | 
|  | 267 | int64_t mVsyncId = 0; | 
|  | 268 | int64_t VSYNC_ID_FIRST_LAYER_CHANGE; | 
|  | 269 | int64_t VSYNC_ID_SECOND_LAYER_CHANGE; | 
|  | 270 | int64_t VSYNC_ID_CHILD_LAYER_REMOVED; | 
|  | 271 | }; | 
|  | 272 |  | 
|  | 273 | TEST_F(TransactionTracingMirrorLayerTest, canAddMirrorLayers) { | 
|  | 274 | proto::TransactionTraceFile proto = writeToProto(); | 
|  | 275 | // We don't have any starting states since no layer was removed from. | 
| Vishnu Nair | b8f2a2d | 2022-01-13 08:10:10 -0800 | [diff] [blame] | 276 | EXPECT_EQ(proto.entry().size(), 1); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 277 |  | 
|  | 278 | // Verify the mirror layer was added | 
| Vishnu Nair | b8f2a2d | 2022-01-13 08:10:10 -0800 | [diff] [blame] | 279 | EXPECT_EQ(proto.entry(0).transactions().size(), 1); | 
|  | 280 | EXPECT_EQ(proto.entry(0).added_layers().size(), 2); | 
|  | 281 | EXPECT_EQ(proto.entry(0).added_layers(1).layer_id(), mMirrorLayerId); | 
|  | 282 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes().size(), 2); | 
|  | 283 | EXPECT_EQ(proto.entry(0).transactions(0).layer_changes(1).z(), 43); | 
| Vishnu Nair | 84125ac | 2021-12-02 08:47:48 -0800 | [diff] [blame] | 284 | } | 
| Vishnu Nair | 7891e96 | 2021-11-11 12:07:21 -0800 | [diff] [blame] | 285 | } // namespace android |