File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
espresso/core/java/androidx/test/espresso/util Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 3737import java .util .Locale ;
3838import java .util .regex .Matcher ;
3939import java .util .regex .Pattern ;
40- import kotlin .text .StringsKt ;
4140
4241/** Text converters for various Android objects. */
4342public final class HumanReadables {
@@ -106,18 +105,21 @@ public static String getViewHierarchyErrorMessage(
106105 }
107106
108107 List <String > tokens = new ArrayList <>();
108+
109109 for (ViewAndDistance viewAndDistance : depthFirstViewTraversalWithDistance (rootView )) {
110- String formatString = "+%s%s " ;
110+ // Build a string that looks like "+----->View description [suffix]"
111+ StringBuilder token = new StringBuilder ();
112+ token .append ('+' );
113+ for (int i = 0 ; i < viewAndDistance .getDistanceFromRoot (); i ++) {
114+ token .append ('-' );
115+ }
116+ token .append ('>' );
117+ token .append (HumanReadables .describe (viewAndDistance .getView ()));
118+ token .append (' ' );
111119 if (problemViews != null && problemViews .contains (viewAndDistance .getView ())) {
112- formatString += problemViewSuffix ;
120+ token . append ( problemViewSuffix ) ;
113121 }
114- String token =
115- String .format (
116- Locale .ROOT ,
117- formatString ,
118- StringsKt .padStart (">" , viewAndDistance .getDistanceFromRoot () + 1 , '-' ),
119- HumanReadables .describe (viewAndDistance .getView ()));
120- tokens .add (token );
122+ tokens .add (token .toString ());
121123 }
122124
123125 String viewHierarchyDump = StringJoinerKt .joinToString (tokens , "\n |\n " );
You can’t perform that action at this time.
0 commit comments