/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.car.settings.testutils;

import static org.robolectric.shadow.api.Shadow.newInstanceOf;
import android.car.Car;
import android.car.user.CarUserManager;
import android.content.Context;
import android.os.Handler;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;

/** Robolectric shadow class for {@link Car} */
@Implements(Car.class)
public class ShadowCar {
    @Implementation
    public static Car createCar(Context context) {
        return newInstanceOf(Car.class);
    }

    @Implementation
    public static Car createCar(
            Context context,
            Handler handler,
            long waitTimeoutMs,
            Car.CarServiceLifecycleListener statusChangeListener) {
        return newInstanceOf(Car.class);
    }

    @Implementation
    public Object getCarManager(String serviceName) {
        if (Car.CAR_USER_SERVICE.equals(serviceName)) {
            return newInstanceOf(CarUserManager.class);
        }
        throw new UnsupportedOperationException("Only Car.CAR_USER_SERVICE is supported");
    }
}
