Add MockDatagramConnection

Bug: chromium:443019066
Change-Id: I82df2458f9a70d31e294872c23c758cb0ac5a99a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/416460
Commit-Queue: Tony Herre <herre@google.com>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45929}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 4d5de03..62f3d50 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -1673,6 +1673,20 @@
     ]
   }
 
+  rtc_library("mock_datagram_connection") {
+    visibility = [ "*" ]
+    testonly = true
+    sources = [ "test/mock_datagram_connection.h" ]
+    deps = [
+      ":array_view",
+      ":candidate",
+      ":datagram_connection",
+      "../p2p:transport_description",
+      "//test:test_support",
+      "//testing/gmock",
+    ]
+  }
+
   rtc_library("mock_datagram_connection_observer") {
     visibility = [ "*" ]
     testonly = true
diff --git a/api/DEPS b/api/DEPS
index 2d3296e..2460690 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -99,6 +99,10 @@
     "+p2p/base/transport_description.h",
   ],
 
+  "mock_datagram_connection\.h": [
+    "+p2p/base/transport_description.h",
+  ],
+
   "datagram_connection_factory\.h": [
     "+p2p/base/port_allocator.h",
     "+rtc_base/rtc_certificate.h",
diff --git a/api/test/mock_datagram_connection.h b/api/test/mock_datagram_connection.h
new file mode 100644
index 0000000..7d1413c
--- /dev/null
+++ b/api/test/mock_datagram_connection.h
@@ -0,0 +1,53 @@
+/*
+ *  Copyright (c) 2025 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+#ifndef API_TEST_MOCK_DATAGRAM_CONNECTION_H_
+#define API_TEST_MOCK_DATAGRAM_CONNECTION_H_
+
+#include <cstddef>
+#include <cstdint>
+
+#include "absl/functional/any_invocable.h"
+#include "absl/strings/string_view.h"
+#include "api/array_view.h"
+#include "api/candidate.h"
+#include "api/datagram_connection.h"
+#include "p2p/base/transport_description.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockDatagramConnection : public DatagramConnection {
+ public:
+  MOCK_METHOD(void,
+              SetRemoteIceParameters,
+              (const IceParameters& ice_parameters),
+              (override));
+  MOCK_METHOD(void,
+              AddRemoteCandidate,
+              (const Candidate& candidate),
+              (override));
+  MOCK_METHOD(bool, Writable, (), (override));
+  MOCK_METHOD(void,
+              SetRemoteDtlsParameters,
+              (absl::string_view digestAlgorithm,
+               const uint8_t* digest,
+               size_t digest_len,
+               DatagramConnection::SSLRole ssl_role),
+              (override));
+  MOCK_METHOD(bool, SendPacket, (ArrayView<const uint8_t> data), (override));
+  MOCK_METHOD(void,
+              Terminate,
+              (absl::AnyInvocable<void()> terminate_complete_callback),
+              (override));
+};
+
+}  // namespace webrtc
+
+#endif  // API_TEST_MOCK_DATAGRAM_CONNECTION_H_