• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.car.dialer.testutils;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.car.Car;
22 import android.content.Context;
23 import android.os.Handler;
24 
25 import org.robolectric.annotation.Implementation;
26 import org.robolectric.annotation.Implements;
27 
28 /**
29  * Shadow class for {@link Car}.
30  */
31 @Implements(Car.class)
32 public class ShadowCar {
33 
34     private static Car sCar;
35 
36     /**
37      * Returns a mocked version of a {@link Car} object. If sCar is not set, returns null.
38      */
39     @Implementation
40     @Nullable
createCar(Context context)41     public static Car createCar(Context context) {
42         return sCar;
43     }
44 
45     /**
46      * Returns a mocked version of a {@link Car} object. If sCar is not set, returns null.
47      */
48     @Implementation
49     @Nullable
createCar(@onNull Context context, @Nullable Handler handler, long waitTimeoutMs, @NonNull Car.CarServiceLifecycleListener statusChangeListener)50     public static Car createCar(@NonNull Context context,
51             @Nullable Handler handler, long waitTimeoutMs,
52             @NonNull Car.CarServiceLifecycleListener statusChangeListener) {
53         return sCar;
54     }
55 
56     /**
57      * Returns a mocked version of a {@link Car} object. If sCar is not set, returns null.
58      */
59     @Implementation
60     @Nullable
createCar(Context context, @Nullable Handler handler)61     public static Car createCar(Context context, @Nullable Handler handler) {
62         return sCar;
63     }
64 
65     /**
66      * Sets {@code sCar}.
67      */
setCar(Car car)68     public static void setCar(Car car) {
69         sCar = car;
70     }
71 }
72