import android.text.Editable;
import android.text.Selection;
import android.view.KeyEvent;
+import android.view.View;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
-import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.RenderCoordinates;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.DOMUtils;
-import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper;
import org.chromium.content.browser.test.util.TestTouchUtils;
import org.chromium.content.browser.test.util.TouchCommon;
import org.chromium.content_shell_apk.ContentShellTestBase;
+/**
+ * Tests the insertion handle that allows users to paste text.
+ */
public class InsertionHandleTest extends ContentShellTestBase {
private static final String META_DISABLE_ZOOM =
"<meta name=\"viewport\" content=\"" +
// The TestInputMethodManagerWrapper intercepts showSoftInput so that a keyboard is never
// brought up.
- getImeAdapter().setInputMethodManagerWrapper(
+ getContentViewCore().getImeAdapterForTest().setInputMethodManagerWrapper(
new TestInputMethodManagerWrapper(getContentViewCore()));
}
clickNodeToShowInsertionHandle(TEXTAREA_ID);
// Unselecting should cause the handle to disappear.
- getImeAdapter().unselect();
+ unselectOnMainSync();
assertTrue(waitForHandleShowingEquals(false));
}
// The input box does not go to the edge of the screen, and neither should the insertion
// handle.
- dragToX = getContentView().getWidth();
+ dragToX = getContentViewCore().getContainerView().getWidth();
dragHandleTo(dragToX, dragToY);
assertTrue(handle.getPositionX() < dragToX - 100);
}
// click (only if it changes the selection), the insertion handle is displayed. So that the
// second click changes the selection, the two clicks should be in sufficiently different
// locations.
- Rect nodeBounds = DOMUtils.getNodeBounds(getContentView(),
- new TestCallbackHelperContainer(getContentView()), nodeId);
+ Rect nodeBounds = DOMUtils.getNodeBounds(getContentViewCore(), nodeId);
- RenderCoordinates renderCoordinates = getContentView().getRenderCoordinates();
- int offsetX = getContentView().getContentViewCore().getViewportSizeOffsetWidthPix();
- int offsetY = getContentView().getContentViewCore().getViewportSizeOffsetHeightPix();
+ RenderCoordinates renderCoordinates = getContentViewCore().getRenderCoordinates();
+ int offsetX = getContentViewCore().getViewportSizeOffsetWidthPix();
+ int offsetY = getContentViewCore().getViewportSizeOffsetHeightPix();
float left = renderCoordinates.fromLocalCssToPix(nodeBounds.left) + offsetX;
float right = renderCoordinates.fromLocalCssToPix(nodeBounds.right) + offsetX;
float top = renderCoordinates.fromLocalCssToPix(nodeBounds.top) + offsetY;
float bottom = renderCoordinates.fromLocalCssToPix(nodeBounds.bottom) + offsetY;
TouchCommon touchCommon = new TouchCommon(this);
- touchCommon.singleClickView(getContentView(),
+ touchCommon.singleClickView(getContentViewCore().getContainerView(),
(int)(left + 3 * (right - left) / 4), (int)(top + (bottom - top) / 2));
assertTrue(waitForHasSelectionPosition());
// TODO(cjhopman): Wait for keyboard display finished?
- touchCommon.singleClickView(getContentView(),
+ touchCommon.singleClickView(getContentViewCore().getContainerView(),
(int)(left + (right - left) / 4), (int)(top + (bottom - top) / 2));
assertTrue(waitForHandleShowingEquals(true));
assertTrue(waitForHandleViewStopped());
HandleView handle = ihc.getHandleViewForTest();
int initialX = handle.getPositionX();
int initialY = handle.getPositionY();
- ContentView view = getContentView();
+ View view = getContentViewCore().getContainerView();
int fromLocation[] = TestTouchUtils.getAbsoluteLocationFromRelative(view, initialX,
initialY + VERTICAL_OFFSET);
});
}
+ private void unselectOnMainSync() {
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ getContentViewCore().getImeAdapterForTest().unselect();
+ }
+ });
+ }
+
private int getSelectionStart() {
return Selection.getSelectionStart(getEditable());
}
(ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
clipMgr.setPrimaryClip(ClipData.newPlainText(null, text));
}
-
- private ImeAdapter getImeAdapter() {
- return getContentViewCore().getImeAdapterForTest();
- }
}