diff options
author | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 19:16:45 +0000 |
---|---|---|
committer | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 19:16:45 +0000 |
commit | 195d1eb7a068747a335ef9774187edf5c94cb7de (patch) | |
tree | 5a4b9fa9680acf277983240c0e9a6a60a4143c18 /content/public | |
parent | bb8eceedd2847bc31bf02f4fc06d43e351a320cc (diff) | |
download | chromium_src-195d1eb7a068747a335ef9774187edf5c94cb7de.zip chromium_src-195d1eb7a068747a335ef9774187edf5c94cb7de.tar.gz chromium_src-195d1eb7a068747a335ef9774187edf5c94cb7de.tar.bz2 |
[Android] Restore the previous behaviour of TouchCommon.
The changes introduced in the behaviour and construction of TouchCommon by https://codereview.chromium.org/11085008/ have busted many of our downstream tests. Revert to the old behaviour for now.
BUG=155083
Review URL: https://codereview.chromium.org/11090050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
2 files changed, 14 insertions, 11 deletions
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 fcac2b4..6596463 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 @@ -78,7 +78,7 @@ public class DOMUtils { int clickX = (int)(bounds.exactCenterX() * scale + 0.5); int clickY = (int)(bounds.exactCenterY() * scale + 0.5); - TouchCommon touchCommon = new TouchCommon(activityTestCase.getActivity()); + TouchCommon touchCommon = new TouchCommon(activityTestCase); touchCommon.singleClickView(view, clickX, clickY); } @@ -97,7 +97,7 @@ public class DOMUtils { int clickX = (int)(bounds.exactCenterX() * scale + 0.5); int clickY = (int)(bounds.exactCenterY() * scale + 0.5); - TouchCommon touchCommon = new TouchCommon(activityTestCase.getActivity()); + TouchCommon touchCommon = new TouchCommon(activityTestCase); touchCommon.longPressView(view, clickX, clickY); } 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 757fd219..c99ff5b 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 @@ -4,22 +4,23 @@ package org.chromium.content.browser.test.util; -import android.app.Activity; import android.os.SystemClock; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; - -import org.chromium.content.browser.test.util.UiUtils; +import android.test.ActivityInstrumentationTestCase2; /** * Touch-related functionality reused across test cases. */ public class TouchCommon { - private Activity mActivity; + private ActivityInstrumentationTestCase2 mActivityTestCase; - public TouchCommon(Activity activity) { - mActivity = activity; + // TODO(leandrogracia): 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; } /** @@ -132,7 +133,8 @@ public class TouchCommon { MotionEvent.ACTION_DOWN, x, y, 0); dispatchTouchEvent(event); - int longPressTimeout = ViewConfiguration.get(mActivity).getLongPressTimeout(); + int longPressTimeout = ViewConfiguration.get( + mActivityTestCase.getActivity()).getLongPressTimeout(); // Long press is flaky with just longPressTimeout. Doubling the time to be safe. SystemClock.sleep(longPressTimeout * 2); @@ -162,9 +164,10 @@ public class TouchCommon { * @param event */ private void dispatchTouchEvent(final MotionEvent event) { - final View view = mActivity.findViewById(android.R.id.content).getRootView(); + final View view = mActivityTestCase.getActivity().findViewById( + android.R.id.content).getRootView(); try { - UiUtils.runOnUiThread(mActivity, new Runnable() { + mActivityTestCase.runTestOnUiThread(new Runnable() { @Override public void run() { view.dispatchTouchEvent(event); |