blob: bbe7eba149c6bd87974a697c111f4a82cb759cd7 [file] [log] [blame]
Artem Iglikov026e9332017-06-01 13:06:29 +01001/*
2 * Copyright (C) 2017 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.server.backup.testing;
18
19import com.android.server.backup.TransportManager;
20
21import java.util.HashSet;
22import java.util.Set;
23
24/**
25 * Stub implementation of TransportReadyCallback, which can tell which calls were made.
26 */
27public class TransportReadyCallbackStub implements
28 TransportManager.TransportReadyCallback {
29 private final Set<String> mSuccessCalls = new HashSet<>();
30 private final Set<Integer> mFailureCalls = new HashSet<>();
31
32 @Override
33 public void onSuccess(String transportName) {
34 mSuccessCalls.add(transportName);
35 }
36
37 @Override
38 public void onFailure(int reason) {
39 mFailureCalls.add(reason);
40 }
41
42 /**
43 * Returns set of transport names for which {@link #onSuccess(String)} was called.
44 */
45 public Set<String> getSuccessCalls() {
46 return mSuccessCalls;
47 }
48
49 /**
50 * Returns set of reasons for which {@link #onFailure(int)} } was called.
51 */
52 public Set<Integer> getFailureCalls() {
53 return mFailureCalls;
54 }
55}