test: add NullConsumerEndpoint

Change-Id: I9de557fabeecfa483d1f63f02e370fcff4a84525
diff --git a/Android.bp b/Android.bp
index 2f1dc27..6266a07 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1868,6 +1868,11 @@
     name: "perfetto_include_perfetto_ext_tracing_core_core",
 }
 
+// GN: //include/perfetto/ext/tracing/core:test_support
+filegroup {
+    name: "perfetto_include_perfetto_ext_tracing_core_test_support",
+}
+
 // GN: //include/perfetto/ext/tracing/ipc:ipc
 filegroup {
     name: "perfetto_include_perfetto_ext_tracing_ipc_ipc",
@@ -1964,6 +1969,7 @@
         ":perfetto_include_perfetto_ext_traced_sys_stats_counters",
         ":perfetto_include_perfetto_ext_traced_traced",
         ":perfetto_include_perfetto_ext_tracing_core_core",
+        ":perfetto_include_perfetto_ext_tracing_core_test_support",
         ":perfetto_include_perfetto_ext_tracing_ipc_ipc",
         ":perfetto_include_perfetto_protozero_protozero",
         ":perfetto_include_perfetto_public_abi_base",
diff --git a/include/perfetto/ext/tracing/core/BUILD.gn b/include/perfetto/ext/tracing/core/BUILD.gn
index e21c4fb..601e0ce 100644
--- a/include/perfetto/ext/tracing/core/BUILD.gn
+++ b/include/perfetto/ext/tracing/core/BUILD.gn
@@ -35,3 +35,7 @@
     "tracing_service.h",
   ]
 }
+
+source_set("test_support") {
+  sources = [ "null_consumer_endpoint_for_testing.h" ]
+}
diff --git a/include/perfetto/ext/tracing/core/null_consumer_endpoint_for_testing.h b/include/perfetto/ext/tracing/core/null_consumer_endpoint_for_testing.h
new file mode 100644
index 0000000..2e85c92
--- /dev/null
+++ b/include/perfetto/ext/tracing/core/null_consumer_endpoint_for_testing.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INCLUDE_PERFETTO_EXT_TRACING_CORE_NULL_CONSUMER_ENDPOINT_FOR_TESTING_H_
+#define INCLUDE_PERFETTO_EXT_TRACING_CORE_NULL_CONSUMER_ENDPOINT_FOR_TESTING_H_
+
+#include "perfetto/ext/tracing/core/tracing_service.h"
+
+namespace perfetto {
+
+// An empty implemetation of ConsumerEndpoint. This is used only to handle
+// code in other repos like arctraceservice/PerfettoClient_test.cpp which
+// ended up depending on internal perfetto interfaces against our plans.
+// This allows to make changes to the ConsumerEndpoint without requiring 3way
+// patches when touching methods that are not overridden by other projects.
+class NullConsumerEndpointForTesting : public ConsumerEndpoint {
+ public:
+  ~NullConsumerEndpointForTesting() override {}
+
+  void EnableTracing(const TraceConfig&, base::ScopedFile) override {}
+  void ChangeTraceConfig(const perfetto::TraceConfig&) override {}
+  void StartTracing() override {}
+  void DisableTracing() override {}
+  void CloneSession(TracingSessionID, CloneSessionArgs) override {}
+  void Flush(uint32_t, FlushCallback, FlushFlags) override {}
+  void ReadBuffers() override {}
+  void FreeBuffers() override {}
+  void Detach(const std::string&) override {}
+  void Attach(const std::string&) override {}
+  void GetTraceStats() override {}
+  void ObserveEvents(uint32_t) override {}
+  void QueryServiceState(ConsumerEndpoint::QueryServiceStateArgs,
+                         ConsumerEndpoint::QueryServiceStateCallback) override {
+  }
+  void QueryCapabilities(ConsumerEndpoint::QueryCapabilitiesCallback) override {
+  }
+  void SaveTraceForBugreport(
+      ConsumerEndpoint::SaveTraceForBugreportCallback) override {}
+};
+
+}  // namespace perfetto
+
+#endif  // INCLUDE_PERFETTO_EXT_TRACING_CORE_NULL_CONSUMER_ENDPOINT_FOR_TESTING_H_
diff --git a/test/BUILD.gn b/test/BUILD.gn
index bb318b3..f0a5ae6 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -25,6 +25,7 @@
       "../gn:gtest_and_gmock",
       "../include/perfetto/ext/ipc",
       "../include/perfetto/ext/traced",
+      "../include/perfetto/ext/tracing/core:test_support",
       "../include/perfetto/protozero",
       "../protos/perfetto/config:cpp",
       "../protos/perfetto/config:zero",
diff --git a/test/traced_integrationtest.cc b/test/traced_integrationtest.cc
index 589e7cd..0ea703b 100644
--- a/test/traced_integrationtest.cc
+++ b/test/traced_integrationtest.cc
@@ -26,6 +26,7 @@
 #include "perfetto/ext/base/unix_socket.h"
 #include "perfetto/ext/base/utils.h"
 #include "perfetto/ext/tracing/core/commit_data_request.h"
+#include "perfetto/ext/tracing/core/null_consumer_endpoint_for_testing.h"
 #include "perfetto/ext/tracing/core/trace_packet.h"
 #include "perfetto/ext/tracing/core/tracing_service.h"
 #include "perfetto/protozero/scattered_heap_buffer.h"
@@ -57,6 +58,11 @@
 
 }  // namespace
 
+TEST(PerfettoTracedIntegrationTest, NullConsumerEndpointBuilds) {
+  NullConsumerEndpointForTesting npe;
+  npe.StartTracing();
+}
+
 TEST(PerfettoTracedIntegrationTest, TestFakeProducer) {
   base::TestTaskRunner task_runner;