blob: d28ffb30683b17e161eeff7d538c56ce118aee74 [file] [log] [blame]
/*
* 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.common;
import static com.android.car.settings.common.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
import android.car.drivingstate.CarUxRestrictions;
import android.content.Context;
import com.android.car.settings.CarSettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
/**
* Unit test for {@link BasePreferenceController}.
*/
@RunWith(CarSettingsRobolectricTestRunner.class)
public class NoSetupPreferenceControllerTest {
private static final String PREFERENCE_KEY = "preference_key";
private Context mContext;
private NoSetupPreferenceController mController;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mController = new NoSetupPreferenceController(mContext, PREFERENCE_KEY);
}
@Test
public void getAvailabilityStatus_available() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void isAvailable_baselineRestrictions_returnsTrue() {
CarUxRestrictions restrictionInfo = new CarUxRestrictions.Builder(/* reqOpt= */ true,
CarUxRestrictions.UX_RESTRICTIONS_BASELINE, /* timestamp= */ 0).build();
mController.onUxRestrictionsChanged(restrictionInfo);
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void isAvailable_noSetupRestrictions_returnsFalse() {
CarUxRestrictions restrictionInfo = new CarUxRestrictions.Builder(/* reqOpt= */ true,
CarUxRestrictions.UX_RESTRICTIONS_NO_SETUP, /* timestamp= */ 0).build();
mController.onUxRestrictionsChanged(restrictionInfo);
assertThat(mController.isAvailable()).isFalse();
}
}