Fix quicsession::willingandabletowrite to check connection level flow control for send control stream and qpack streams. protected by gfe2_reloadable_flag_quic_fix_willing_and_able_to_write.

PiperOrigin-RevId: 313853837
Change-Id: I3f2516d4ac11b8867ffafc45cbacb2b0ff0cbd9b
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index 9e1280a..1e36258 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -2988,6 +2988,26 @@
   }
 }
 
+TEST_P(QuicSpdySessionTestServer,
+       H3ControlStreamsLimitedByConnectionFlowControl) {
+  if (!VersionUsesHttp3(transport_version())) {
+    return;
+  }
+  // Ensure connection level flow control blockage.
+  QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
+  EXPECT_TRUE(session_.IsConnectionFlowControlBlocked());
+
+  QuicSendControlStream* send_control_stream =
+      QuicSpdySessionPeer::GetSendControlStream(&session_);
+  // Mark send_control stream write blocked.
+  session_.MarkConnectionLevelWriteBlocked(send_control_stream->id());
+  if (GetQuicReloadableFlag(quic_fix_willing_and_able_to_write)) {
+    EXPECT_FALSE(session_.WillingAndAbleToWrite());
+  } else {
+    EXPECT_TRUE(session_.WillingAndAbleToWrite());
+  }
+}
+
 TEST_P(QuicSpdySessionTestServer, PeerClosesCriticalSendStream) {
   if (!VersionUsesHttp3(transport_version())) {
     return;