Files
app_Settings/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
Yanting Yang 5035ef9f94 Remove silky flag from System for official release
Remove the silky condition and clean up redundant files.

Bug: 183670633
Test: robotests & visual
Change-Id: I2743a65869c4fe2ea684e259373ddc309dea59c3
2021-05-27 13:53:18 +08:00

83 lines
2.6 KiB
Java

/*
* Copyright (C) 2017 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.settings.gestures;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
import android.app.Activity;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.core.AbstractPreferenceController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class GesturesSettingsPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Activity mActivity;
private GesturesSettingPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest();
mController = new GesturesSettingPreferenceController(mActivity);
}
@Test
public void isAvailable_hasGesture_shouldReturnTrue() {
final List<AbstractPreferenceController> mControllers = new ArrayList<>();
mControllers.add(new AbstractPreferenceController(RuntimeEnvironment.application) {
@Override
public boolean isAvailable() {
return true;
}
@Override
public String getPreferenceKey() {
return "test_key";
}
});
ReflectionHelpers.setField(mController, "mGestureControllers", mControllers);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void isAvailable_noGesture_shouldReturnFalse() {
ReflectionHelpers.setField(mController, "mGestureControllers",
new ArrayList<AbstractPreferenceController>());
assertThat(mController.isAvailable()).isFalse();
}
}