perfetto: further cleanup and consolidate test code

With the introduction of test helper, integration tests have already been made much cleaner.
Now the next step is to take this further and reduce coupling between producer
service and consumer. We can do this by making the producer emit data without
the test explicitly requesting it (like ftrace) if a flag in config is enabled.

Moreover, we can also consolidate all checkpointing code inside the helper class instead
of every file defining its own.

Bug: 74380167
Change-Id: Idbe24586a4aaadb17f934f6e06c5c6d378be0ec3
diff --git a/test/test_helper.h b/test/test_helper.h
index 563345f..b26a88d 100644
--- a/test/test_helper.h
+++ b/test/test_helper.h
@@ -43,19 +43,27 @@
   FakeProducer* ConnectFakeProducer();
   void ConnectConsumer();
   void StartTracing(const TraceConfig& config);
-  void ReadData(std::function<void(const protos::TracePacket&)> packet_callback,
-                std::function<void()> on_finish_callback);
+  void ReadData();
+
+  void WaitForConsumerConnect();
+  void WaitForProducerEnabled();
+  void WaitForTracingDisabled();
+  void WaitForReadData();
 
   std::function<void()> WrapTask(const std::function<void()>& function);
 
   TaskRunnerThread* service_thread() { return &service_thread_; }
   TaskRunnerThread* producer_thread() { return &producer_thread_; }
+  const std::vector<protos::TracePacket>& trace() { return trace_; }
 
  private:
   base::TestTaskRunner* task_runner_ = nullptr;
 
-  std::function<void(const protos::TracePacket&)> packet_callback_;
-  std::function<void()> continuation_callack_;
+  std::function<void()> on_connect_callback_;
+  std::function<void()> on_packets_finished_callback_;
+  std::function<void()> on_stop_tracing_callback_;
+
+  std::vector<protos::TracePacket> trace_;
 
   TaskRunnerThread service_thread_;
   TaskRunnerThread producer_thread_;