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 com.android.systemui.util
18 
19 /** A fake [com.android.systemui.util.EventLog] for tests. */
20 class FakeEventLog : EventLog {
21     data class Event(val tag: Int, val value: Any)
22 
23     private val _events: MutableList<Event> = mutableListOf()
24     val events: List<Event>
25         get() = _events
26 
clearnull27     fun clear() {
28         _events.clear()
29     }
30 
writeEventnull31     override fun writeEvent(tag: Int, value: Int): Int {
32         _events.add(Event(tag, value))
33         return 1
34     }
35 
writeEventnull36     override fun writeEvent(tag: Int, value: Long): Int {
37         _events.add(Event(tag, value))
38         return 1
39     }
40 
writeEventnull41     override fun writeEvent(tag: Int, value: Float): Int {
42         _events.add(Event(tag, value))
43         return 1
44     }
45 
writeEventnull46     override fun writeEvent(tag: Int, value: String): Int {
47         _events.add(Event(tag, value))
48         return 1
49     }
50 
writeEventnull51     override fun writeEvent(tag: Int, vararg values: Any): Int {
52         _events.add(Event(tag, values))
53         return 1
54     }
55 }
56