From e6181b0c47c161be56bbc07f69275fe768634b82 Mon Sep 17 00:00:00 2001 From: Hugo Benichi Date: Thu, 23 Mar 2017 12:32:27 +0900 Subject: [PATCH] Fix NetworkNotificationManagerTest The testNotificationsShownAndCleared test was not doing anything because the list of notification to show was always empty. This patch fixes this issue and actually makes the test loop on non-empty collections, and also fixes another ordering issue in assertions themselves, hidden until now by the first issue. Bug: 32561414 Test: runtest -x frameworks/base/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java Merged-In: I4837b1175d7c9133e9156e33acaa1e7e3341cc62 Change-Id: Ia30587bd68a87b83b62f57eeeb28fef7d95dbf81 (cherry picked from commit f8b804be5aeb5d0a36ff88649d7c5ecdc47c3ad1) --- .../connectivity/NetworkNotificationManagerTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java b/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java index 21c2de79d68b7..f201bc7a7d3cd 100644 --- a/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java +++ b/tests/net/java/com/android/server/connectivity/NetworkNotificationManagerTest.java @@ -91,7 +91,7 @@ public class NetworkNotificationManagerTest extends TestCase { final int NETWORK_ID_BASE = 100; List types = Arrays.asList(NotificationType.values()); List ids = new ArrayList<>(types.size()); - for (int i = 0; i < ids.size(); i++) { + for (int i = 0; i < types.size(); i++) { ids.add(NETWORK_ID_BASE + i); } Collections.shuffle(ids); @@ -101,9 +101,10 @@ public class NetworkNotificationManagerTest extends TestCase { mManager.showNotification(ids.get(i), types.get(i), mWifiNai, mCellNai, null, false); } - Collections.shuffle(ids); + List idsToClear = new ArrayList<>(ids); + Collections.shuffle(idsToClear); for (int i = 0; i < ids.size(); i++) { - mManager.clearNotification(ids.get(i)); + mManager.clearNotification(idsToClear.get(i)); } for (int i = 0; i < ids.size(); i++) {