File tree Expand file tree Collapse file tree
tests/tests/text/src/android/text/method/cts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import android .util .DisplayMetrics ;
3030import android .util .TypedValue ;
3131import android .view .MotionEvent ;
32+ import android .view .ViewConfiguration ;
3233import android .view .ViewGroup ;
3334import 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 (() -> {
You can’t perform that action at this time.
0 commit comments