Migrates the remaining tests from TestDataFrameSource -> VisitorDataSource.

Also removes TestDataFrameSource.

PiperOrigin-RevId: 633389586
diff --git a/quiche/http2/adapter/oghttp2_adapter_metadata_test.cc b/quiche/http2/adapter/oghttp2_adapter_metadata_test.cc
index 6928bcd..7e75920 100644
--- a/quiche/http2/adapter/oghttp2_adapter_metadata_test.cc
+++ b/quiche/http2/adapter/oghttp2_adapter_metadata_test.cc
@@ -366,13 +366,13 @@
                  {":path", "/this/is/request/one"}});
 
   const std::string kBody = std::string(100 * 1024, 'a');
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, false);
-  body1->AppendPayload(kBody);
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, kBody);
+  visitor.SetEndData(1, false);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
 
   const int32_t stream_id1 =
       adapter->SubmitRequest(headers1, std::move(body1), false, nullptr);
-  ASSERT_GT(stream_id1, 0);
+  ASSERT_EQ(stream_id1, 1);
 
   EXPECT_CALL(visitor, OnBeforeFrameSent(SETTINGS, 0, _, 0x0));
   EXPECT_CALL(visitor, OnFrameSent(SETTINGS, 0, _, 0x0, 0));
@@ -580,9 +580,9 @@
 
   // The body source must indicate that the end of the body is not the end of
   // the stream.
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, false);
-  body1->AppendPayload(kBody);
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, kBody);
+  visitor.SetEndData(1, false);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int submit_result = adapter->SubmitResponse(
       1, ToHeaders({{":status", "200"}, {"x-comment", "Sure, sounds good."}}),
       std::move(body1), false);
diff --git a/quiche/http2/adapter/oghttp2_session_test.cc b/quiche/http2/adapter/oghttp2_session_test.cc
index 6e35d66..654bde1 100644
--- a/quiche/http2/adapter/oghttp2_session_test.cc
+++ b/quiche/http2/adapter/oghttp2_session_test.cc
@@ -88,16 +88,16 @@
 
   // Submit a request to ensure the first stream is created.
   const char* kSentinel1 = "arbitrary pointer 1";
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, true);
-  body1->AppendPayload("This is an example request body.");
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, "This is an example request body.");
+  visitor.SetEndData(1, true);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int stream_id = session.SubmitRequest(
       ToHeaders({{":method", "POST"},
                  {":scheme", "http"},
                  {":authority", "example.com"},
                  {":path", "/this/is/request/one"}}),
       std::move(body1), false, const_cast<char*>(kSentinel1));
-  EXPECT_EQ(stream_id, 1);
+  ASSERT_EQ(stream_id, 1);
 
   // Submit another request to ensure the next stream is created.
   int stream_id2 =
@@ -274,16 +274,16 @@
   EXPECT_EQ(0, session.GetHpackEncoderDynamicTableSize());
 
   const char* kSentinel1 = "arbitrary pointer 1";
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, true);
-  body1->AppendPayload("This is an example request body.");
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, "This is an example request body.");
+  visitor.SetEndData(1, true);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int stream_id = session.SubmitRequest(
       ToHeaders({{":method", "POST"},
                  {":scheme", "http"},
                  {":authority", "example.com"},
                  {":path", "/this/is/request/one"}}),
       std::move(body1), false, const_cast<char*>(kSentinel1));
-  EXPECT_GT(stream_id, 0);
+  ASSERT_EQ(stream_id, 1);
   EXPECT_TRUE(session.want_write());
   EXPECT_EQ(kSentinel1, session.GetStreamUserData(stream_id));
 
@@ -385,16 +385,16 @@
   EXPECT_THAT(visitor.data(), EqualsFrames({SpdyFrameType::SETTINGS}));
   visitor.Clear();
 
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, true);
-  body1->AppendPayload(std::string(20000, 'a'));
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, std::string(20000, 'a'));
+  visitor.SetEndData(1, true);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int stream_id =
       session.SubmitRequest(ToHeaders({{":method", "POST"},
                                        {":scheme", "http"},
                                        {":authority", "example.com"},
                                        {":path", "/this/is/request/one"}}),
                             std::move(body1), false, nullptr);
-  EXPECT_GT(stream_id, 0);
+  ASSERT_EQ(stream_id, 1);
   EXPECT_TRUE(session.want_write());
 
   EXPECT_CALL(visitor, OnBeforeFrameSent(HEADERS, stream_id, _, 0x4));
@@ -420,8 +420,7 @@
   EXPECT_FALSE(session.want_write());
 
   const char* kSentinel1 = "arbitrary pointer 1";
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, true);
-  TestDataFrameSource* body_ref = body1.get();
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int stream_id = session.SubmitRequest(
       ToHeaders({{":method", "POST"},
                  {":scheme", "http"},
@@ -449,8 +448,8 @@
   visitor.Clear();
   EXPECT_FALSE(session.want_write());
 
-  body_ref->AppendPayload("This is an example request body.");
-  body_ref->EndData();
+  visitor.AppendPayloadForStream(1, "This is an example request body.");
+  visitor.SetEndData(1, true);
   EXPECT_TRUE(session.ResumeStream(stream_id));
   EXPECT_TRUE(session.want_write());
 
@@ -476,8 +475,7 @@
   EXPECT_FALSE(session.want_write());
 
   const char* kSentinel1 = "arbitrary pointer 1";
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, true);
-  TestDataFrameSource* body_ref = body1.get();
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int stream_id = session.SubmitRequest(
       ToHeaders({{":method", "POST"},
                  {":scheme", "http"},
@@ -505,7 +503,7 @@
   visitor.Clear();
   EXPECT_FALSE(session.want_write());
 
-  body_ref->EndData();
+  visitor.SetEndData(1, true);
   EXPECT_TRUE(session.ResumeStream(stream_id));
   EXPECT_TRUE(session.want_write());
 
@@ -531,9 +529,9 @@
   EXPECT_FALSE(session.want_write());
 
   const char* kSentinel1 = "arbitrary pointer 1";
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, true);
-  body1->AppendPayload("This is an example request body.");
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, "This is an example request body.");
+  visitor.SetEndData(1, true);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int stream_id = session.SubmitRequest(
       ToHeaders({{":method", "POST"},
                  {":scheme", "http"},
@@ -805,8 +803,8 @@
   EXPECT_FALSE(session.want_write());
   // A data fin is not sent so that the stream remains open, and the flow
   // control state can be verified.
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, false);
-  body1->AppendPayload("This is an example response body.");
+  visitor.AppendPayloadForStream(1, "This is an example response body.");
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int submit_result = session.SubmitResponse(
       1,
       ToHeaders({{":status", "404"},
@@ -896,9 +894,9 @@
 
   // The body source must indicate that the end of the body is not the end of
   // the stream.
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, false);
-  body1->AppendPayload("This is an example response body.");
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, "This is an example response body.");
+  visitor.SetEndData(1, false);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int submit_result = session.SubmitResponse(
       1, ToHeaders({{":status", "200"}, {"x-comment", "Sure, sounds good."}}),
       std::move(body1), false);
@@ -988,9 +986,9 @@
 
   // The body source must indicate that the end of the body is not the end of
   // the stream.
-  auto body1 = std::make_unique<TestDataFrameSource>(visitor, false);
-  body1->AppendPayload("This is an example response body.");
-  body1->EndData();
+  visitor.AppendPayloadForStream(1, "This is an example response body.");
+  visitor.SetEndData(1, false);
+  auto body1 = std::make_unique<VisitorDataSource>(visitor, 1);
   int submit_result = session.SubmitResponse(
       1, ToHeaders({{":status", "200"}, {"x-comment", "Sure, sounds good."}}),
       std::move(body1), false);
diff --git a/quiche/http2/adapter/test_utils.cc b/quiche/http2/adapter/test_utils.cc
index 7151ee2..a72bc1d 100644
--- a/quiche/http2/adapter/test_utils.cc
+++ b/quiche/http2/adapter/test_utils.cc
@@ -113,72 +113,6 @@
   return visitor_.SendDataFrame(stream_id_, frame_header, payload_length);
 }
 
-TestDataFrameSource::TestDataFrameSource(Http2VisitorInterface& visitor,
-                                         bool has_fin)
-    : visitor_(visitor), has_fin_(has_fin) {}
-
-void TestDataFrameSource::AppendPayload(absl::string_view payload) {
-  QUICHE_CHECK(!end_data_);
-  if (!payload.empty()) {
-    payload_fragments_.push_back(std::string(payload));
-    current_fragment_ = payload_fragments_.front();
-  }
-}
-
-void TestDataFrameSource::EndData() { end_data_ = true; }
-
-std::pair<int64_t, bool> TestDataFrameSource::SelectPayloadLength(
-    size_t max_length) {
-  if (return_error_) {
-    return {DataFrameSource::kError, false};
-  }
-  // The stream is done if there's no more data, or if |max_length| is at least
-  // as large as the remaining data.
-  const bool end_data = end_data_ && (current_fragment_.empty() ||
-                                      (payload_fragments_.size() == 1 &&
-                                       max_length >= current_fragment_.size()));
-  const int64_t length = std::min(max_length, current_fragment_.size());
-  return {length, end_data};
-}
-
-bool TestDataFrameSource::Send(absl::string_view frame_header,
-                               size_t payload_length) {
-  QUICHE_LOG_IF(DFATAL, payload_length > current_fragment_.size())
-      << "payload_length: " << payload_length
-      << " current_fragment_size: " << current_fragment_.size();
-  const std::string concatenated =
-      absl::StrCat(frame_header, current_fragment_.substr(0, payload_length));
-  const int64_t result = visitor_.OnReadyToSend(concatenated);
-  if (result < 0) {
-    // Write encountered error.
-    visitor_.OnConnectionError(ConnectionError::kSendError);
-    current_fragment_ = {};
-    payload_fragments_.clear();
-    return false;
-  } else if (result == 0) {
-    // Write blocked.
-    return false;
-  } else if (static_cast<size_t>(result) < concatenated.size()) {
-    // Probably need to handle this better within this test class.
-    QUICHE_LOG(DFATAL)
-        << "DATA frame not fully flushed. Connection will be corrupt!";
-    visitor_.OnConnectionError(ConnectionError::kSendError);
-    current_fragment_ = {};
-    payload_fragments_.clear();
-    return false;
-  }
-  if (payload_length > 0) {
-    current_fragment_.remove_prefix(payload_length);
-  }
-  if (current_fragment_.empty() && !payload_fragments_.empty()) {
-    payload_fragments_.erase(payload_fragments_.begin());
-    if (!payload_fragments_.empty()) {
-      current_fragment_ = payload_fragments_.front();
-    }
-  }
-  return true;
-}
-
 std::string EncodeHeaders(const spdy::Http2HeaderBlock& entries) {
   spdy::HpackEncoder encoder;
   encoder.DisableCompression();
diff --git a/quiche/http2/adapter/test_utils.h b/quiche/http2/adapter/test_utils.h
index 803675d..047da91 100644
--- a/quiche/http2/adapter/test_utils.h
+++ b/quiche/http2/adapter/test_utils.h
@@ -118,32 +118,6 @@
   bool has_fin_ = false;
 };
 
-// A test DataFrameSource. Starts out in the empty, blocked state.
-// Deprecated in favor of VisitorDataSource.
-class QUICHE_NO_EXPORT TestDataFrameSource : public DataFrameSource {
- public:
-  TestDataFrameSource(Http2VisitorInterface& visitor, bool has_fin);
-
-  void AppendPayload(absl::string_view payload);
-  void EndData();
-  void SimulateError() { return_error_ = true; }
-
-  std::pair<int64_t, bool> SelectPayloadLength(size_t max_length) override;
-  bool Send(absl::string_view frame_header, size_t payload_length) override;
-  bool send_fin() const override { return has_fin_; }
-
- private:
-  Http2VisitorInterface& visitor_;
-  std::vector<std::string> payload_fragments_;
-  absl::string_view current_fragment_;
-  // Whether the stream should end with the final frame of data.
-  const bool has_fin_;
-  // Whether |payload_fragments_| contains the final segment of data.
-  bool end_data_ = false;
-  // Whether SelectPayloadLength() should return an error.
-  bool return_error_ = false;
-};
-
 class QUICHE_NO_EXPORT TestMetadataSource : public MetadataSource {
  public:
   explicit TestMetadataSource(const spdy::Http2HeaderBlock& entries);