Introduce quic::AllSupportedVersionsWithTls()

Since we have an increasing number of TLS-only tests, more of them have a need for AllSupportedVersionsWithTls. This CL moves that out of one test and into shared code.

gfe-relnote: n/a, test-only
PiperOrigin-RevId: 305786311
Change-Id: I89218730762fbc0d19fdce81f16d176e25d284cf
diff --git a/quic/core/crypto/transport_parameters_test.cc b/quic/core/crypto/transport_parameters_test.cc
index 4c66546..29e1636 100644
--- a/quic/core/crypto/transport_parameters_test.cc
+++ b/quic/core/crypto/transport_parameters_test.cc
@@ -99,16 +99,6 @@
       preferred_address);
 }
 
-std::vector<ParsedQuicVersion> AllSupportedTlsVersions() {
-  std::vector<ParsedQuicVersion> tls_versions;
-  for (const ParsedQuicVersion& version : AllSupportedVersions()) {
-    if (version.handshake_protocol == PROTOCOL_TLS1_3) {
-      tls_versions.push_back(version);
-    }
-  }
-  return tls_versions;
-}
-
 }  // namespace
 
 class TransportParametersTest : public QuicTestWithParam<ParsedQuicVersion> {
@@ -120,7 +110,7 @@
 
 INSTANTIATE_TEST_SUITE_P(TransportParametersTests,
                          TransportParametersTest,
-                         ::testing::ValuesIn(AllSupportedTlsVersions()),
+                         ::testing::ValuesIn(AllSupportedVersionsWithTls()),
                          ::testing::PrintToStringParamName());
 
 TEST_P(TransportParametersTest, Comparator) {
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 5be7334..2bf7c3c 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -269,6 +269,17 @@
   return versions;
 }
 
+ParsedQuicVersionVector AllSupportedVersionsWithTls() {
+  ParsedQuicVersionVector versions;
+  for (const ParsedQuicVersion& version : AllSupportedVersions()) {
+    if (version.handshake_protocol == PROTOCOL_TLS1_3) {
+      versions.push_back(version);
+    }
+  }
+  QUIC_BUG_IF(versions.empty()) << "No version with TLS handshake found.";
+  return versions;
+}
+
 ParsedQuicVersionVector CurrentSupportedVersionsWithTls() {
   ParsedQuicVersionVector versions;
   for (const ParsedQuicVersion& version : CurrentSupportedVersions()) {
diff --git a/quic/core/quic_versions.h b/quic/core/quic_versions.h
index 8843d58..f861f19 100644
--- a/quic/core/quic_versions.h
+++ b/quic/core/quic_versions.h
@@ -407,6 +407,10 @@
 QUIC_EXPORT_PRIVATE ParsedQuicVersionVector
 CurrentSupportedVersionsWithQuicCrypto();
 
+// Returns a subset of AllSupportedVersions() with
+// handshake_protocol == PROTOCOL_TLS1_3, in the same order.
+QUIC_EXPORT_PRIVATE ParsedQuicVersionVector AllSupportedVersionsWithTls();
+
 // Returns a subset of CurrentSupportedVersions() with handshake_protocol ==
 // PROTOCOL_TLS1_3.
 QUIC_EXPORT_PRIVATE ParsedQuicVersionVector CurrentSupportedVersionsWithTls();