InputTracingTest: Fix test flakiness

There was a bug in the logic for tracking when the tracing thread is
idle. The thread can only be idle when the queue is empty, so prevent
it from being marked as idle when there are still events left to be
processed.

Also, a waitForTracerIdle() was missing in the TraceWindowDispatch test.

Bug: 333544493
Test: InputTracingTest passes 10000 times
Change-Id: I90feaeefc80d1a0e43732ee7e75d4074a9634bd7
diff --git a/services/inputflinger/tests/InputTracingTest.cpp b/services/inputflinger/tests/InputTracingTest.cpp
index fe4d6d9..23fa045 100644
--- a/services/inputflinger/tests/InputTracingTest.cpp
+++ b/services/inputflinger/tests/InputTracingTest.cpp
@@ -626,6 +626,8 @@
     consumed = window->consumeMotionEvent(WithMotionAction(ACTION_CANCEL));
     s.expectMotionTraced(Level::NONE, *consumed);
     s.expectDispatchTraced(Level::REDACTED, {*consumed, window});
+
+    waitForTracerIdle();
 }
 
 TEST_F(InputTracingTest, SimultaneousTracingSessions) {