Update KeyboardLayoutPickerControllerTest

The logic is changed, so we need to update the test. (https://screenshot.googleplex.com/AnrJgmGfK2fPxmQ.png)

Bug: 270109384
Test: atest KeyboardLayoutPickerControllerTest
[1/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#isAlwaysAvailable: PASSED (5.876s)
[2/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#test_createPreferenceHierarchy_shouldAddTwoPreference: PASSED (192ms)
[3/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#testOnDeviceRemove_getSameDevice_shouldFinish: PASSED (5.797s)
[4/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#testLifecycle_onStart_shouldRegisterInputManager: PASSED (1.495s)
[5/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#test_createPreferenceHierarchy_shouldAddOnePreference: PASSED (75ms)
[6/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#testOnDeviceRemove_getDifferentDevice_shouldNotFinish: PASSED (366ms)
[7/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#testLifecycle_onStop_shouldCancelRegisterInputManager: PASSED (65ms)
[8/8] com.android.settings.inputmethod.KeyboardLayoutPickerControllerTest#testLifecycle_onStart_NoInputDevice_shouldReturn: PASSED (309ms)

Change-Id: I018873cba9e73c6d684d828858cc1b08d3f2f7f9
This commit is contained in:
danielwbhuang
2023-03-07 16:31:15 +08:00
parent 39129e09d3
commit cf4be05b64

View File

@@ -93,13 +93,13 @@ public class KeyboardLayoutPickerControllerTest {
} }
@Test @Test
public void testLifecycle_onStart_NoInputDevice_shouldFinish() { public void testLifecycle_onStart_NoInputDevice_shouldReturn() {
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class); final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
when(mInputManager.getInputDeviceByDescriptor(anyString())).thenReturn(null); when(mInputManager.getInputDeviceByDescriptor(anyString())).thenReturn(null);
when(mFragment.getActivity()).thenReturn(activity); when(mFragment.getActivity()).thenReturn(activity);
mController.onStart(); mController.onStart();
assertThat(activity.isFinishing()).isTrue(); verify(mInputManager, never()).getEnabledKeyboardLayoutsForInputDevice(any());
} }
@Test @Test