InputDispatcher_test: Fix flakiness when verifying traced events

Fix the flakiness when verifying all events are traced by doing the
verification before stopping Dispatcher.

When verifying traced events, we wait for all expected events to be
traced. If the Dispatcher is stopped before this waiting process, it's
possible that the InputTracer's thread is also stopped before it can
write all queued events into the backend. We eliminate the race
condition between stopping the Dispatcher and verifying the events by
doing the verification first.

Bug: 210460522
Bug: 323347575
Test: atest inputflinger_tests --rerun-until-failure
Change-Id: I454ca85174c97c848f1da45157d5b993935a261e
1 file changed