CTS - Fix coverage reporting of varargs method params
bug: 27554789
Change-Id: Id50595fe54bc0d1a8735aec64696f8d3aaba2c35
diff --git a/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApiClass.java b/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApiClass.java
index 73cea67..2d24931 100644
--- a/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApiClass.java
+++ b/tools/cts-api-coverage/src/com/android/cts/apicoverage/ApiClass.java
@@ -197,6 +197,13 @@
}
/**
+ * @return true iff the parameter is a var arg parameter.
+ */
+ private static boolean isVarArg(String parameter) {
+ return parameter.endsWith("...");
+ }
+
+ /**
* Compare class types.
* @param apiType The type as reported by the api
* @param testType The type as found used in a test
@@ -206,7 +213,9 @@
private static boolean compareType(String apiType, String testType) {
return apiType.equals(testType) ||
isGenericType(apiType) && !testType.equals(VOID) ||
- isGenericArrayType(apiType) && isArrayType(testType) ;
+ isGenericArrayType(apiType) && isArrayType(testType) ||
+ isVarArg(apiType) && isArrayType(testType) &&
+ apiType.startsWith(testType.substring(0, testType.indexOf("[")));
}
/**