Skip to content

Commit e236b17

Browse files
Automated Code Change
PiperOrigin-RevId: 598534755
1 parent 7a0feb6 commit e236b17

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

espresso/core/java/androidx/test/espresso/util/HumanReadables.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.Locale;
3838
import java.util.regex.Matcher;
3939
import java.util.regex.Pattern;
40-
import kotlin.text.StringsKt;
4140

4241
/** Text converters for various Android objects. */
4342
public 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");

0 commit comments

Comments
 (0)