5package io.flutter.plugin.platform;
7import static io.flutter.Build.API_LEVELS;
8import static org.junit.Assert.assertEquals;
9import static org.mockito.Mockito.mock;
10import static org.mockito.Mockito.spy;
11import static org.mockito.Mockito.when;
13import android.annotation.TargetApi;
15import android.hardware.display.DisplayManager;
17import android.view.inputmethod.InputMethodManager;
18import androidx.test.core.app.ApplicationProvider;
19import androidx.test.ext.junit.runners.AndroidJUnit4;
21import org.junit.runner.RunWith;
22import org.robolectric.annotation.Config;
25@RunWith(AndroidJUnit4.class)
26@TargetApi(API_LEVELS.API_28)
30 public
void returnsOuterContextInputMethodManager() {
43 Context context = spy(ApplicationProvider.getApplicationContext());
44 InputMethodManager expected = mock(InputMethodManager.class);
45 when(context.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(expected);
46 DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
51 InputMethodManager actual =
52 (InputMethodManager) svp.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
56 assertEquals(expected, actual);
61 public
void returnsOuterContextInputMethodManager_createDisplayContext() {
65 Context context = spy(ApplicationProvider.getApplicationContext());
66 InputMethodManager expected = mock(InputMethodManager.class);
67 when(context.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(expected);
69 ((DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE)).getDisplay(0);
74 InputMethodManager actual =
77 .createDisplayContext(display)
78 .getSystemService(Context.INPUT_METHOD_SERVICE);
82 assertEquals(expected, actual);