From 7fcbc2ecbdca9bd49eb1c08243b4eeaabb59118c Mon Sep 17 00:00:00 2001 From: Aaron Huang Date: Mon, 1 Aug 2022 15:16:24 +0800 Subject: [PATCH] Fix flaky testNotifyNoInternetAsDialogWhenHighPriority If the notification shade was swiped down, the activity that this test wants to verify will be behind the notification shade, and this causes the test failed. Thus, this change makes the screen back to home before starting the test to avoid the activity being hidden by the notification shade. Bug: 240891836 Test: NetworkNotificationManagerTest#testNotifyNoInternetAsDialogWhenHighPriority Change-Id: I4d903d2623c462fca4ec07eb0a0231ef527a200b --- .../server/connectivity/NetworkNotificationManagerTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java b/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java index 2cf5d8eaef..53097b6a2b 100644 --- a/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java +++ b/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java @@ -385,11 +385,13 @@ public class NetworkNotificationManagerTest { doReturn(true).when(mResources).getBoolean( R.bool.config_notifyNoInternetAsDialogWhenHighPriority); + final Instrumentation instr = InstrumentationRegistry.getInstrumentation(); + UiDevice.getInstance(instr).pressHome(); + mManager.showNotification(TEST_NOTIF_ID, NETWORK_SWITCH, mWifiNai, mCellNai, null, false); // Non-"no internet" notifications are not affected verify(mNotificationManager).notify(eq(TEST_NOTIF_TAG), eq(NETWORK_SWITCH.eventId), any()); - final Instrumentation instr = InstrumentationRegistry.getInstrumentation(); final Context ctx = instr.getContext(); final String testAction = "com.android.connectivity.coverage.TEST_DIALOG"; final Intent intent = new Intent(testAction)