From ae7508f9b5807b846b1afbd8d2fbe0c601dbaafa Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Wed, 25 Aug 2021 18:00:20 +0900 Subject: Fix IpSecAlgorithmTest on S The test may be run on S builds older than itself, in which case the resource ID may not match. Query the resource ID dynamically instead of using the constant. IpSecAlgorithm is not updatable in S, which is why it can use hidden/unstable platform resources, so the test could also be skipped altogether on S. But considering that keeping it around is not very costly yet, this change fixes it for running on S. Bug: 197489543 Test: atest IpSecAlgorithmTest Change-Id: I533eede3a360a8db9089e65e017b9d7453b35539 --- tests/unit/java/android/net/IpSecAlgorithmTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/unit/java/android/net/IpSecAlgorithmTest.java') diff --git a/tests/unit/java/android/net/IpSecAlgorithmTest.java b/tests/unit/java/android/net/IpSecAlgorithmTest.java index c2a759b83a..c473e82945 100644 --- a/tests/unit/java/android/net/IpSecAlgorithmTest.java +++ b/tests/unit/java/android/net/IpSecAlgorithmTest.java @@ -217,8 +217,11 @@ public class IpSecAlgorithmTest { final Set optionalAlgoSet = getOptionalAlgos(); final String[] optionalAlgos = optionalAlgoSet.toArray(new String[0]); - doReturn(optionalAlgos).when(mMockResources) - .getStringArray(com.android.internal.R.array.config_optionalIpSecAlgorithms); + // Query the identifier instead of using the R.array constant, as the test may be built + // separately from the platform and they may not match. + final int resId = Resources.getSystem().getIdentifier("config_optionalIpSecAlgorithms", + "array", "android"); + doReturn(optionalAlgos).when(mMockResources).getStringArray(resId); final Set enabledAlgos = new HashSet<>(IpSecAlgorithm.loadAlgos(mMockResources)); final Set expectedAlgos = ALGO_TO_REQUIRED_FIRST_SDK.keySet(); -- cgit v1.2.3