Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2671)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java

Issue 521583003: Adding Text Selection Action Bar Unit Test cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the failed test case issue. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..04a3bf576799cf58981a5ce499a3d66b12791fee
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
@@ -0,0 +1,105 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.base.test.util.UrlUtils;
+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_shell_apk.ContentShellTestBase;
+
+/**
+ * Integration tests for text selection-related behavior.
+ */
+public class ContentViewCoreSelectionTest extends ContentShellTestBase {
+ private static final String DATA_URL = UrlUtils.encodeHtmlDataUri(
+ "<html><head><meta name=\"viewport\"" +
+ "content=\"width=device-width, initial-scale=1.1, maximum-scale=1.5\" /></head>" +
+ "<body><form action=\"about:blank\">" +
+ "<input id=\"empty_input_text\" type=\"text\" />" +
+ "<br/><p><span id=\"plain_text_1\">This is Plain Text One</span></p>" +
+ "<br/><p><span id=\"plain_text_2\">This is Plain Text Two</span></p>" +
+ "<br/><input id=\"empty_input_text\" type=\"text\" />" +
+ "<br/><input id=\"input_text\" type=\"text\" value=\"Sample Text\" />" +
+ "<br/><textarea id=\"empty_textarea\" rows=\"2\" cols=\"20\"></textarea>" +
+ "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">Sample Text</textarea>" +
+ "</form></body></html>");
+
+ private ContentViewCore mContentViewCore;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ launchContentShellWithUrl(DATA_URL);
+ assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading());
+
+ mContentViewCore = getContentViewCore();
+ assertWaitForPageScaleFactorMatch(1.1f);
+ assertWaitForSelectActionBarStatus(false);
+ }
+
+ @SmallTest
+ @Feature({"TextSelection"})
+ public void testSelectActionBarShownOnLongPressingPlainText() throws Exception {
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1");
+ assertWaitForSelectActionBarStatus(true);
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text");
+ assertWaitForSelectActionBarStatus(false);
+ }
+
+ @SmallTest
+ @Feature({"TextSelection"})
+ public void testSelectActionBarClearedOnTappingOutsideSelection() throws Exception {
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1");
+ assertWaitForSelectActionBarStatus(true);
+ DOMUtils.clickNode(this, mContentViewCore, "plain_text_2");
+ assertWaitForSelectActionBarStatus(false);
+ }
+
+ @SmallTest
+ @Feature({"TextSelection"})
+ public void testSelectActionBarStaysOnLongPressingDifferentPlainTexts() throws Exception {
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1");
+ assertWaitForSelectActionBarStatus(true);
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2");
+ assertWaitForSelectActionBarStatus(true);
+ }
+
+ @SmallTest
+ @Feature({"TextSelection"})
+ public void testSelectActionBarStaysOnLongPressingDifferentNonEmptyInputs() throws Exception {
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea");
+ assertWaitForSelectActionBarStatus(true);
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text");
+ assertWaitForSelectActionBarStatus(true);
+ }
+
+ @SmallTest
+ @Feature({"TextSelection"})
+ public void testSelectActionBarNotShownOnLongPressingDifferentEmptyInputs() throws Exception {
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1");
+ assertWaitForSelectActionBarStatus(true);
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text");
+ assertWaitForSelectActionBarStatus(false);
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2");
+ assertWaitForSelectActionBarStatus(true);
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_textarea");
+ assertWaitForSelectActionBarStatus(false);
+ }
+
+ private void assertWaitForSelectActionBarStatus(
+ final boolean show) throws InterruptedException {
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return show == mContentViewCore.isSelectActionBarShowing();
+ }
+ }));
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698