[Touchpad & Mouse] Update title based on conditions
Update preference and page title based on device condition. Bug: 364536531 Flag: NONE, bug fix for string title. Test: verify on device Change-Id: Id5b01680314c45f1b86661c60f9e7acedca8b6eb
This commit is contained in:
committed by
Shaowei Shen
parent
1c57667439
commit
3ec1567922
@@ -25,6 +25,7 @@ import static org.junit.Assume.assumeTrue;
|
||||
import android.content.Context;
|
||||
import android.view.InputDevice;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -53,14 +54,31 @@ public class TrackpadSettingsControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private TrackpadSettingsController mController;
|
||||
private Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mController = new TrackpadSettingsController(mContext, PREFERENCE_KEY);
|
||||
mPreference = new Preference(mContext);
|
||||
ShadowInputDevice.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_setTitleBasedOnDeviceSource() {
|
||||
int deviceId = 1;
|
||||
ShadowInputDevice.sDeviceIds = new int[]{deviceId};
|
||||
InputDevice device = ShadowInputDevice.makeInputDevicebyIdWithSources(deviceId,
|
||||
InputDevice.SOURCE_TOUCHPAD);
|
||||
ShadowInputDevice.addDevice(deviceId, device);
|
||||
String expectedTitle = mContext.getString(
|
||||
NewKeyboardSettingsUtils.getTouchpadAndMouseTitleTitleResId());
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getTitle()).isEqualTo(expectedTitle);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_isTouchpadAvailable() {
|
||||
int deviceId = 1;
|
||||
|
Reference in New Issue
Block a user