Make QUIC end-to-end test use the parametrized event loop object from the server

PiperOrigin-RevId: 463650493
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc
index d52ba93..a682a80 100644
--- a/quiche/quic/core/http/end_to_end_test.cc
+++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -504,6 +504,7 @@
         crypto_test_utils::ProofSourceForTesting(), server_config_,
         server_supported_versions_, &memory_cache_backend_,
         expected_server_connection_id_length_);
+    test_server->SetEventLoopFactory(GetParam().event_loop);
     server_thread_ =
         std::make_unique<ServerThread>(std::move(test_server), server_address_);
     if (chlo_multiplier_ != 0) {
diff --git a/quiche/quic/test_tools/quic_test_server.cc b/quiche/quic/test_tools/quic_test_server.cc
index 83a060d..b8499ff 100644
--- a/quiche/quic/test_tools/quic_test_server.cc
+++ b/quiche/quic/test_tools/quic_test_server.cc
@@ -8,6 +8,7 @@
 
 #include "absl/memory/memory.h"
 #include "absl/strings/string_view.h"
+#include "quiche/quic/core/io/quic_default_event_loop.h"
 #include "quiche/quic/core/quic_default_connection_helper.h"
 #include "quiche/quic/tools/quic_simple_crypto_server_stream_helper.h"
 #include "quiche/quic/tools/quic_simple_dispatcher.h"
@@ -198,6 +199,18 @@
       ->SetCryptoStreamFactory(factory);
 }
 
+void QuicTestServer::SetEventLoopFactory(QuicEventLoopFactory* factory) {
+  event_loop_factory_ = factory;
+}
+
+std::unique_ptr<QuicEventLoop> QuicTestServer::CreateEventLoop() {
+  QuicEventLoopFactory* factory = event_loop_factory_;
+  if (factory == nullptr) {
+    factory = GetDefaultEventLoop();
+  }
+  return factory->Create(QuicDefaultClock::Get());
+}
+
 ///////////////////////////   TEST SESSIONS ///////////////////////////////
 
 ImmediateGoAwaySession::ImmediateGoAwaySession(
diff --git a/quiche/quic/test_tools/quic_test_server.h b/quiche/quic/test_tools/quic_test_server.h
index f986bdc..c0be6f0 100644
--- a/quiche/quic/test_tools/quic_test_server.h
+++ b/quiche/quic/test_tools/quic_test_server.h
@@ -88,6 +88,15 @@
   // Sets a custom crypto stream factory, owned by the caller, for easy custom
   // crypto logic.  This is incompatible with setting a session factory.
   void SetCryptoStreamFactory(CryptoStreamFactory* factory);
+
+  // Sets the override for the default event loop factory used by the server.
+  void SetEventLoopFactory(QuicEventLoopFactory* factory);
+
+ protected:
+  std::unique_ptr<QuicEventLoop> CreateEventLoop() override;
+
+ private:
+  QuicEventLoopFactory* event_loop_factory_ = nullptr;
 };
 
 // Useful test sessions for the QuicTestServer.