From ca014a873b6451ed6cdba76f5ab287f65dff94c2 Mon Sep 17 00:00:00 2001 From: Joshua Trask Date: Fri, 25 Mar 2022 15:20:17 -0400 Subject: [PATCH] Fix(?) for some disabled ChooserActivityTest cases These tests (testShortcutTarget{With,Without}ApplyAppLimits) are currently disabled by @Ignore annotations, and I'm not re-enabling them in this CL because I'm not sure that they won't flake -- I just know that this was an easy (and understandable) fix when I tried to run these tests locally, and I'd like to preserve that fix for posterity. Test: Re-enabled the tests and confirmed they passed only w/ fix Bug: 208803748 Change-Id: I5268e3324d3cec9f6a72aee5de9ec1f06e45e987 Merged-In: I5268e3324d3cec9f6a72aee5de9ec1f06e45e987 (cherry picked from commit 72b8b079b5efc524be04568877366a8b4e2fe25c) --- .../com/android/internal/app/ChooserActivityTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java index 9995c3e08516a..6ea708394654a 100644 --- a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +++ b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java @@ -3070,8 +3070,15 @@ public class ChooserActivityTest { // framework code on the device is up-to-date. // TODO: is there a better way to do this? (Other than abandoning inheritance-based DI wrapper?) private int getRuntimeResourceId(String name, String defType) { - int id = mActivityRule.getActivity().getResources().getIdentifier(name, defType, "android"); + int id = -1; + if (ChooserActivityOverrideData.getInstance().resources != null) { + id = ChooserActivityOverrideData.getInstance().resources.getIdentifier( + name, defType, "android"); + } else { + id = mActivityRule.getActivity().getResources().getIdentifier(name, defType, "android"); + } assertThat(id, greaterThan(0)); + return id; } }