Skip to content

Commit 775444e

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "DO NOT MERGE TouchTest: ensure scroll amount is larger than touch slop" into android10-tests-dev
2 parents c942740 + a36a45c commit 775444e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/tests/text/src/android/text/method/cts/TouchTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.util.DisplayMetrics;
3030
import android.util.TypedValue;
3131
import android.view.MotionEvent;
32+
import android.view.ViewConfiguration;
3233
import android.view.ViewGroup;
3334
import android.widget.TextView;
3435

@@ -117,17 +118,18 @@ public void testOnTouchEvent() throws Throwable {
117118
// Create a string that is wider than the screen.
118119
DisplayMetrics metrics = mActivity.getResources().getDisplayMetrics();
119120
int screenWidth = metrics.widthPixels;
121+
int touchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
120122
TextPaint paint = mTextView.getPaint();
121123
String text = LONG_TEXT;
122124
int textWidth = Math.round(paint.measureText(text));
123-
while (textWidth < screenWidth) {
125+
while (textWidth < screenWidth + touchSlop) {
124126
text += LONG_TEXT;
125127
textWidth = Math.round(paint.measureText(text));
126128
}
127129

128130
// Drag the difference between the text width and the screen width.
129131
int dragAmount = Math.min(screenWidth, textWidth - screenWidth);
130-
assertTrue(dragAmount > 0);
132+
assertTrue(dragAmount > touchSlop);
131133
final String finalText = text;
132134
final SpannableString spannable = new SpannableString(finalText);
133135
mActivityRule.runOnUiThread(() -> {

0 commit comments

Comments
 (0)