This source file includes following definitions.
- showSoftInput
- hideSoftInputFromWindow
- isActive
- isHidden
- testHideImeOnLosingFocus
package org.chromium.content.browser;
import android.content.Context;
import android.os.IBinder;
import android.os.ResultReceiver;
import android.test.UiThreadTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.View;
import android.widget.EditText;
import org.chromium.content.browser.input.InputMethodManagerWrapper;
import org.chromium.content_shell.R;
import org.chromium.content_shell_apk.ContentShellTestBase;
public class ContentViewCoreFocusTest extends ContentShellTestBase {
private static class TestInputMethodManagerWrapper extends InputMethodManagerWrapper {
private boolean hidden = false;
public TestInputMethodManagerWrapper(Context context) {
super(context);
}
@Override
public void showSoftInput(View view, int flags, ResultReceiver resultReceiver) {
hidden = false;
}
@Override
public boolean hideSoftInputFromWindow(IBinder windowToken, int flags,
ResultReceiver resultReceiver) {
hidden = true;
return true;
}
@Override
public boolean isActive(View view) {
return true;
}
public boolean isHidden() {
return hidden;
}
}
@UiThreadTest
@SmallTest
public void testHideImeOnLosingFocus() throws Throwable {
final ContentViewCore contentViewCore = getContentViewCore();
final View view = contentViewCore.getContainerView();
final TestInputMethodManagerWrapper immw = new TestInputMethodManagerWrapper(getActivity());
assertTrue(view.requestFocus());
contentViewCore.setInputMethodManagerWrapperForTest(immw);
immw.showSoftInput(view, 0, null);
assertFalse(immw.isHidden());
final EditText urlBox = (EditText) getActivity().findViewById(R.id.url);
assertTrue(urlBox.requestFocus());
assertTrue(immw.isHidden());
}
}