Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java |
| index 390137ea2e62b4a714d64c7a7e4e664b2d7daf65..4ada0984a813f6efbcd1f2dc4cf7efea53551c15 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java |
| @@ -8,6 +8,7 @@ import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E |
| import android.content.DialogInterface; |
| import android.content.pm.ActivityInfo; |
| +import android.graphics.Point; |
| import android.os.Debug; |
| import android.os.SystemClock; |
| import android.support.test.filters.LargeTest; |
| @@ -352,6 +353,72 @@ public class TabsTest extends ChromeTabbedActivityTestBase { |
| assertWaitForKeyboardStatus(false); |
| } |
| + private void assertWaitForSelectedText(final String text) throws InterruptedException { |
| + CriteriaHelper.pollUiThread(new Criteria() { |
| + @Override |
| + public boolean isSatisfied() { |
| + updateFailureReason("expected selected text: [" + text + "]"); |
| + return text.equals( |
| + getActivity().getActivityTab().getContentViewCore().getSelectedText()); |
| + } |
| + }); |
| + } |
| + |
| + /** |
| + * Generate a fling sequence from the given start/end X,Y percentages, for the given steps. |
| + * Works in either landscape or portrait orientation. |
| + */ |
| + private void fling(float startX, float startY, float endX, float endY, int stepCount) { |
| + Point size = new Point(); |
| + getActivity().getWindowManager().getDefaultDisplay().getSize(size); |
| + float dragStartX = size.x * startX; |
| + float dragEndX = size.x * endX; |
| + float dragStartY = size.y * startY; |
| + float dragEndY = size.y * endY; |
| + long downTime = SystemClock.uptimeMillis(); |
| + dragStart(dragStartX, dragStartY, downTime); |
| + dragTo(dragStartX, dragEndX, dragStartY, dragEndY, stepCount, downTime); |
| + dragEnd(dragEndX, dragEndY, downTime); |
| + } |
| + |
| + private void scrollDown() { |
| + fling(0.f, 0.5f, 0.f, 0.75f, 100); |
| + } |
| + |
| + /** |
| + * Verify that the selection is collapsed when switching to the tab-switcher mode then switching |
| + * back. https://crbug.com/697756 |
| + */ |
| + @MediumTest |
| + @Restriction(ChromeRestriction.RESTRICTION_TYPE_PHONE) |
| + @Feature({"Android-TabSwitcher"}) |
| + @RetryOnFailure |
| + public void testTabSwitcherCollapseSelection() throws Exception { |
| + mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext()); |
| + |
| + ChromeTabUtils.fullyLoadUrlInNewTab( |
| + getInstrumentation(), getActivity(), mTestServer.getURL(TEST_FILE_PATH), false); |
| + DOMUtils.longPressNode(getActivity().getActivityTab().getContentViewCore(), "textarea"); |
| + assertWaitForKeyboardStatus(true); |
|
yabinh
2017/03/08 14:58:23
On a second thought, assertWaitForSelectedText("wo
|
| + |
| + // Switch to tab-switcher mode. |
| + OverviewModeBehaviorWatcher overviewModeWatcher = |
| + new OverviewModeBehaviorWatcher(getActivity().getLayoutManager(), true, false); |
| + View button = getActivity().findViewById(R.id.tab_switcher_button); |
| + assertNotNull("Could not find 'tab_switcher_button'", button); |
| + singleClickView(button); |
| + overviewModeWatcher.waitForBehavior(); |
| + |
| + // Switch back to the tab view from the tab-switcher mode. |
| + overviewModeWatcher = |
| + new OverviewModeBehaviorWatcher(getActivity().getLayoutManager(), false, true); |
| + singleClickView(button); |
| + overviewModeWatcher.waitForBehavior(); |
| + |
| + scrollDown(); |
| + assertWaitForSelectedText(""); |
| + } |
| + |
| /** |
| * Verify that opening a new tab and navigating immediately sets a size on the newly created |
| * renderer. https://crbug.com/434477. |