diff options
author | tedchoc <tedchoc@chromium.org> | 2014-10-30 11:35:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-30 18:35:36 +0000 |
commit | 6a2f36fbd3787eb085f9ba8db8add19166bb7b27 (patch) | |
tree | eccfa5588319b78bb05953149fb0901097d758ec | |
parent | eb85cd11fa9087049cb5008272f7b11c45b24ade (diff) | |
download | chromium_src-6a2f36fbd3787eb085f9ba8db8add19166bb7b27.zip chromium_src-6a2f36fbd3787eb085f9ba8db8add19166bb7b27.tar.gz chromium_src-6a2f36fbd3787eb085f9ba8db8add19166bb7b27.tar.bz2 |
[Android] Remove non-static version of TouchCommon.
BUG=427031
Review URL: https://codereview.chromium.org/691623002
Cr-Commit-Position: refs/heads/master@{#302115}
9 files changed, 29 insertions, 84 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java index 840fbaa..d87a66a 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java @@ -251,8 +251,7 @@ public class AwContentsClientFullScreenTest extends AwTestBase { // html5 controls are shadow html elements without any ids. In fullscreen we can still // tap the play button because this is rendered in the center of the custom view. // In embedded mode we don't have an easy way of retrieving its location. - TouchCommon touchCommon = new TouchCommon(AwContentsClientFullScreenTest.this); - touchCommon.singleClickView(mContentsClient.getCustomView()); + TouchCommon.singleClickView(mContentsClient.getCustomView()); } else { fail("Unable to tap standard html5 play control in embedded mode"); } diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java index e0e6c2b..7a3367b 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java @@ -181,8 +181,7 @@ public class AutofillPopupTest extends ChromeShellTestBase { waitForAutofillPopopShow(popup); - TouchCommon touchCommon = new TouchCommon(this); - touchCommon.singleClickViewRelative(popup.getListView(), 10, 10); + TouchCommon.singleClickViewRelative(popup.getListView(), 10, 10); waitForInputFieldFill(webContents); } diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java index dc50e9a..6c99720 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java @@ -136,8 +136,7 @@ public class AutofillTest extends ChromeShellTestBase { assertTrue(openAutofillPopupAndWaitUntilReady(suggestions)); assertEquals(2, mAutofillPopup.getListView().getCount()); - TouchCommon touchCommon = new TouchCommon(this); - touchCommon.singleClickViewRelative(mAutofillPopup.getListView(), 10, 10); + TouchCommon.singleClickViewRelative(mAutofillPopup.getListView(), 10, 10); assertTrue(mMockAutofillCallback.waitForCallback()); assertEquals(0, mMockAutofillCallback.mListIndex); diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java index 928f07c..8999761e 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/infobar/InfoBarTest.java @@ -59,9 +59,9 @@ public class InfoBarTest extends ChromeShellTestBase { List<InfoBar> infoBars = getActivity().getActiveTab().getInfoBarContainer().getInfoBars(); assertEquals("Wrong infobar count", 1, infoBars.size()); - assertTrue(InfoBarUtil.hasPrimaryButton(this, infoBars.get(0))); - assertFalse(InfoBarUtil.hasSecondaryButton(this, infoBars.get(0))); - InfoBarUtil.clickPrimaryButton(this, infoBars.get(0)); + assertTrue(InfoBarUtil.hasPrimaryButton(infoBars.get(0))); + assertFalse(InfoBarUtil.hasSecondaryButton(infoBars.get(0))); + InfoBarUtil.clickPrimaryButton(infoBars.get(0)); assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished()); assertEquals("Wrong infobar count", 0, infoBars.size()); @@ -83,8 +83,8 @@ public class InfoBarTest extends ChromeShellTestBase { // Make sure it has OK/Cancel buttons. List<InfoBar> infoBars = getActivity().getActiveTab().getInfoBarContainer().getInfoBars(); assertEquals("Wrong infobar count", 1, infoBars.size()); - assertTrue(InfoBarUtil.hasPrimaryButton(this, infoBars.get(0))); - assertTrue(InfoBarUtil.hasSecondaryButton(this, infoBars.get(0))); + assertTrue(InfoBarUtil.hasPrimaryButton(infoBars.get(0))); + assertTrue(InfoBarUtil.hasSecondaryButton(infoBars.get(0))); loadUrlWithSanitization(HELLO_WORLD_URL); assertTrue("InfoBar not removed.", mListener.removeInfoBarAnimationFinished()); diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/translate/TranslateInfoBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/translate/TranslateInfoBarTest.java index 70163ad..a8d31c5 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/translate/TranslateInfoBarTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/translate/TranslateInfoBarTest.java @@ -49,8 +49,8 @@ public class TranslateInfoBarTest extends ChromeShellTestBase { loadUrlWithSanitization(TestHttpServerClient.getUrl(TRANSLATE_PAGE)); assertTrue("InfoBar not opened.", mListener.addInfoBarAnimationFinished()); InfoBar infoBar = infoBars.get(0); - assertTrue(InfoBarUtil.hasPrimaryButton(this, infoBar)); - assertTrue(InfoBarUtil.hasSecondaryButton(this, infoBar)); + assertTrue(InfoBarUtil.hasPrimaryButton(infoBar)); + assertTrue(InfoBarUtil.hasSecondaryButton(infoBar)); assertTrue("Language Panel not opened.", TranslateUtil.openLanguagePanel(this, infoBar)); } @@ -67,14 +67,14 @@ public class TranslateInfoBarTest extends ChromeShellTestBase { assertTrue("InfoBar not opened.", mListener.addInfoBarAnimationFinished()); InfoBar infoBar = infoBars.get(0); - assertTrue(InfoBarUtil.clickCloseButton(this, infoBar)); + assertTrue(InfoBarUtil.clickCloseButton(infoBar)); assertTrue(mListener.removeInfoBarAnimationFinished()); // Reload the page so the infobar shows again loadUrlWithSanitization(TestHttpServerClient.getUrl(TRANSLATE_PAGE)); assertTrue("InfoBar not opened", mListener.addInfoBarAnimationFinished()); infoBar = infoBars.get(0); - assertTrue(InfoBarUtil.clickCloseButton(this, infoBar)); + assertTrue(InfoBarUtil.clickCloseButton(infoBar)); assertTrue("Never Panel not opened.", TranslateUtil.verifyInfoBarText(infoBar, NEVER_TRANSLATE_MESSAGE)); diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/InfoBarUtil.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/InfoBarUtil.java index cafacff..7a9e37c 100644 --- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/InfoBarUtil.java +++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/InfoBarUtil.java @@ -4,7 +4,6 @@ package org.chromium.chrome.test.util; -import android.test.ActivityInstrumentationTestCase2; import android.view.View; import org.chromium.chrome.R; @@ -19,11 +18,10 @@ public class InfoBarUtil { * Finds, and optionally clicks, the button with the specified ID in the given InfoBar. * @return True if the View was found. */ - private static boolean findButton(ActivityInstrumentationTestCase2<?> test, - InfoBar infoBar, int buttonId, boolean click) { + private static boolean findButton(InfoBar infoBar, int buttonId, boolean click) { View button = infoBar.getContentWrapper().findViewById(buttonId); if (button == null) return false; - if (click) new TouchCommon(test).singleClickView(button); + if (click) TouchCommon.singleClickView(button); return true; } @@ -31,44 +29,39 @@ public class InfoBarUtil { * Checks if the primary button exists on the InfoBar. * @return True if the View was found. */ - public static boolean hasPrimaryButton(ActivityInstrumentationTestCase2<?> test, - InfoBar infoBar) { - return findButton(test, infoBar, R.id.button_primary, false); + public static boolean hasPrimaryButton(InfoBar infoBar) { + return findButton(infoBar, R.id.button_primary, false); } /** * Checks if the secondary button exists on the InfoBar. * @return True if the View was found. */ - public static boolean hasSecondaryButton(ActivityInstrumentationTestCase2<?> test, - InfoBar infoBar) { - return findButton(test, infoBar, R.id.button_secondary, false); + public static boolean hasSecondaryButton(InfoBar infoBar) { + return findButton(infoBar, R.id.button_secondary, false); } /** * Simulates clicking the Close button in the specified infobar. * @return True if the View was found. */ - public static boolean clickCloseButton(ActivityInstrumentationTestCase2<?> test, - InfoBar infoBar) { - return findButton(test, infoBar, R.id.infobar_close_button, true); + public static boolean clickCloseButton(InfoBar infoBar) { + return findButton(infoBar, R.id.infobar_close_button, true); } /** * Simulates clicking the primary button in the specified infobar. * @return True if the View was found. */ - public static boolean clickPrimaryButton(ActivityInstrumentationTestCase2<?> test, - InfoBar infoBar) { - return findButton(test, infoBar, R.id.button_primary, true); + public static boolean clickPrimaryButton(InfoBar infoBar) { + return findButton(infoBar, R.id.button_primary, true); } /** * Simulates clicking the secondary button in the specified infobar. * @return True if the View was found. */ - public static boolean clickSecondaryButton(ActivityInstrumentationTestCase2<?> test, - InfoBar infoBar) { - return findButton(test, infoBar, R.id.button_secondary, true); + public static boolean clickSecondaryButton(InfoBar infoBar) { + return findButton(infoBar, R.id.button_secondary, true); } } diff --git a/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java b/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java index fcccd59..1c3b079 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/InterstitialPageTest.java @@ -123,8 +123,7 @@ public class InterstitialPageTest extends ContentShellTestBase { assertTrue("Interstitial never shown.", waitForInterstitial(true)); assertTrue("WebContentsObserver not notified of interstitial showing", observer.isInterstitialShowing()); - TouchCommon touchCommon = new TouchCommon(this); - touchCommon.singleClickViewRelative(getContentViewCore().getContainerView(), 10, 10); + TouchCommon.singleClickViewRelative(getContentViewCore().getContainerView(), 10, 10); assertTrue("Interstitial never hidden.", waitForInterstitial(false)); assertTrue("WebContentsObserver not notified of interstitial hiding", !observer.isInterstitialShowing()); diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java index a8967ba..0b444df 100644 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java @@ -159,8 +159,7 @@ public class DOMUtils { final ContentViewCore viewCore, String nodeId) throws InterruptedException, TimeoutException { int[] clickTarget = getClickTargetForNode(viewCore, nodeId); - TouchCommon touchCommon = new TouchCommon(activityTestCase); - touchCommon.singleClickView(viewCore.getContainerView(), clickTarget[0], clickTarget[1]); + TouchCommon.singleClickView(viewCore.getContainerView(), clickTarget[0], clickTarget[1]); } /** @@ -170,8 +169,7 @@ public class DOMUtils { final ContentViewCore viewCore, String nodeId) throws InterruptedException, TimeoutException { int[] clickTarget = getClickTargetForNode(viewCore, nodeId); - TouchCommon touchCommon = new TouchCommon(activityTestCase); - touchCommon.longPressView(viewCore.getContainerView(), clickTarget[0], clickTarget[1]); + TouchCommon.longPressView(viewCore.getContainerView(), clickTarget[0], clickTarget[1]); } /** diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TouchCommon.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TouchCommon.java index 711aa4d..3cbb585 100644 --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TouchCommon.java +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TouchCommon.java @@ -6,7 +6,6 @@ package org.chromium.content.browser.test.util; import android.app.Activity; import android.os.SystemClock; -import android.test.ActivityInstrumentationTestCase2; import android.test.TouchUtils; import android.view.MotionEvent; import android.view.View; @@ -21,49 +20,8 @@ import java.util.concurrent.ExecutionException; * Touch-related functionality reused across test cases. */ public class TouchCommon { - private ActivityInstrumentationTestCase2<?> mActivityTestCase; - - // TODO(tedchoc): This method should receive and use an activity - // instead of the ActivityInstrumentationTestCase2. However this is causing - // problems downstream. Any fix for this should be landed downstream first. - public TouchCommon(ActivityInstrumentationTestCase2<?> activityTestCase) { - mActivityTestCase = activityTestCase; - } - - /** - * @see #dragStart(Activity, float, float, long) - */ - public void dragStart(float x, float y, long downTime) { - dragStart(mActivityTestCase.getActivity(), x, y, downTime); - } - - /** - * @see #dragTo(Activity, float, float, float, float, int, long) - */ - public void dragTo( - float fromX, float toX, float fromY, float toY, int stepCount, long downTime) { - dragTo(mActivityTestCase.getActivity(), fromX, toX, fromY, toY, stepCount, downTime); - } - - /** - * @see #dragEnd(Activity, float, float, long) - */ - public void dragEnd(float x, float y, long downTime) { - dragEnd(mActivityTestCase.getActivity(), x, y, downTime); - } - - /** - * @see #singleClick(Activity, float, float) - */ - public void singleClick(float x, float y) { - singleClick(mActivityTestCase.getActivity(), x, y); - } - - /** - * @see #longPress(Activity, float, float) - */ - public void longPress(float x, float y) { - longPress(mActivityTestCase.getActivity(), x, y); + // Prevent instantiation. + private TouchCommon() { } /** |