blob: 92e9bbb77bd3ea44396ba873c3bf0ade8cab9ca4 [file] [log] [blame]
Will Brockmanfbaa7912019-10-24 15:15:09 -04001/*
2 * Copyright (C) 2019 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
17package com.android.internal.logging.testing;
18
19import com.android.internal.logging.UiEventLogger;
20
21import java.util.LinkedList;
22import java.util.Queue;
23
24/**
25 * Fake logger that queues up logged events for inspection.
26 *
27 * @hide.
28 */
29public class UiEventLoggerFake implements UiEventLogger {
30 /**
31 * Immutable data class used to record fake log events.
32 */
33 public class FakeUiEvent {
34 public final int eventId;
35 public final int uid;
36 public final String packageName;
37
38 public FakeUiEvent(int eventId, int uid, String packageName) {
39 this.eventId = eventId;
40 this.uid = uid;
41 this.packageName = packageName;
42 }
43 }
44
45 private Queue<FakeUiEvent> mLogs = new LinkedList<FakeUiEvent>();
46
47 @Override
48 public void log(UiEventEnum event) {
49 final int eventId = event.getId();
50 if (eventId > 0) {
51 mLogs.offer(new FakeUiEvent(eventId, 0, null));
52 }
53 }
54
55 public Queue<FakeUiEvent> getLogs() {
56 return mLogs;
57 }
58}