Fix flakiness of testTaskChangeCallBacks
The test verifies that there is no task removed event before the
test activity is finished. But the task launched by previous test
may be removed when running the current test because the destruction
of activity is not done immediately. That causes the assertion of
task removed event count to fail.
So just only count the event after the current test activity is
started to avoid the noise.
Bug: 130388819
Test: TaskStackChangedListenerTest#testTaskChangeCallBacks
Change-Id: I742cb2f2344a42483af54ecd98fff5a1038900ff
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
index 6046c9b2..d139141 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
@@ -198,6 +198,10 @@
@Override
public void onTaskRemoved(int taskId) throws RemoteException {
+ if (taskCreatedLaunchLatch.getCount() == 1) {
+ // The test activity hasn't started. Ignore the noise from previous test.
+ return;
+ }
params[0] = taskId;
taskRemovedLatch.countDown();
}