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 37
37
import java .util .Locale ;
38
38
import java .util .regex .Matcher ;
39
39
import java .util .regex .Pattern ;
40
- import kotlin .text .StringsKt ;
41
40
42
41
/** Text converters for various Android objects. */
43
42
public final class HumanReadables {
@@ -106,18 +105,21 @@ public static String getViewHierarchyErrorMessage(
106
105
}
107
106
108
107
List <String > tokens = new ArrayList <>();
108
+
109
109
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 (' ' );
111
119
if (problemViews != null && problemViews .contains (viewAndDistance .getView ())) {
112
- formatString += problemViewSuffix ;
120
+ token . append ( problemViewSuffix ) ;
113
121
}
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 ());
121
123
}
122
124
123
125
String viewHierarchyDump = StringJoinerKt .joinToString (tokens , "\n |\n " );
You can’t perform that action at this time.
0 commit comments