diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-03-22 17:52:45 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-22 17:52:45 +0000 |
commit | 2a6ee5d89d34b2008adb34002f7609064c576978 (patch) | |
tree | 155fbef0aad5610f312c73c1fb9a811c00ee2e59 | |
parent | c1b6dc93fcb8fa3c94f059657b014e3e69579375 (diff) | |
parent | e277262caf58aa7a6a1daf6558ef8f9524a766b2 (diff) | |
download | Nfc-2a6ee5d89d34b2008adb34002f7609064c576978.tar.gz |
Merge "Test : New Test Case testGetForegroundUids added in ForegroundUtilsTest" into main
-rw-r--r-- | src/com/android/nfc/ForegroundUtils.java | 5 | ||||
-rw-r--r-- | tests/unit/src/com/android/nfc/ForegroundUtilsTest.java | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/com/android/nfc/ForegroundUtils.java b/src/com/android/nfc/ForegroundUtils.java index 6b6eabe8..ad8d1e30 100644 --- a/src/com/android/nfc/ForegroundUtils.java +++ b/src/com/android/nfc/ForegroundUtils.java @@ -189,4 +189,9 @@ public class ForegroundUtils implements ActivityManager.OnUidImportanceListener public SparseArray<List<Callback>> getBackgroundCallbacks() { return mBackgroundCallbacks; } + + @VisibleForTesting + public void clearForegroundlist() { + mForegroundUids.clear(); + } } diff --git a/tests/unit/src/com/android/nfc/ForegroundUtilsTest.java b/tests/unit/src/com/android/nfc/ForegroundUtilsTest.java index 5ce638ed..1e8e4cfa 100644 --- a/tests/unit/src/com/android/nfc/ForegroundUtilsTest.java +++ b/tests/unit/src/com/android/nfc/ForegroundUtilsTest.java @@ -103,6 +103,7 @@ public class ForegroundUtilsTest { public void testOnUidImportance() { if (!mNfcSupported) return; + mForegroundUtils.clearForegroundlist(); mForegroundUtils.onUidImportance(0, ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND); List<Integer> uids = mForegroundUtils.getForegroundUids(); @@ -140,4 +141,20 @@ public class ForegroundUtilsTest { callbacks = backGroundCallbacks.get(0); Assert.assertNull(callbacks); } -} + + @Test + public void testGetForegroundUids() { + if (!mNfcSupported) return; + + mForegroundUtils.onUidImportance(0, + ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND); + mForegroundUtils.onUidImportance(1, + ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND); + mForegroundUtils.onUidImportance(2, + ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND); + List<Integer> uids = mForegroundUtils.getForegroundUids(); + Assert.assertNotNull(uids); + int uid = uids.get(0); + Assert.assertEquals(0, uid); + } +}
\ No newline at end of file |