Remove test-only HttpDecoder::current_frame_type() accessor. Add HttpDecoderPeer to use in tests instead. Also encode tests in test namespace, and override virtual destructor of HttpDecoderTest. gfe-relnote: n/a, test-only change in QUIC v99-only code. PiperOrigin-RevId: 254856727 Change-Id: Ic36c7d83495728d23c1c2b7b8dad66a728965c2f
diff --git a/quic/core/http/http_decoder.h b/quic/core/http/http_decoder.h index 0304b56..1df4620 100644 --- a/quic/core/http/http_decoder.h +++ b/quic/core/http/http_decoder.h
@@ -11,6 +11,12 @@ namespace quic { +namespace test { + +class HttpDecoderPeer; + +} // namespace test + class QuicDataReader; // Struct that stores meta data of an HTTP/3 frame. @@ -134,9 +140,10 @@ QuicErrorCode error() const { return error_; } const std::string& error_detail() const { return error_detail_; } - uint64_t current_frame_type() const { return current_frame_type_; } private: + friend test::HttpDecoderPeer; + // Represents the current state of the parsing state machine. enum HttpDecoderState { STATE_READING_FRAME_LENGTH,
diff --git a/quic/core/http/http_decoder_test.cc b/quic/core/http/http_decoder_test.cc index b74918a..2bb9eb2 100644 --- a/quic/core/http/http_decoder_test.cc +++ b/quic/core/http/http_decoder_test.cc
@@ -16,9 +16,18 @@ namespace quic { +namespace test { + +class HttpDecoderPeer { + public: + static uint64_t current_frame_type(HttpDecoder* decoder) { + return decoder->current_frame_type_; + } +}; + class MockVisitor : public HttpDecoder::Visitor { public: - virtual ~MockVisitor() = default; + ~MockVisitor() override = default; // Called if an error is detected. MOCK_METHOD1(OnError, void(HttpDecoder* decoder)); @@ -67,6 +76,11 @@ ON_CALL(visitor_, OnPushPromiseFrameEnd()).WillByDefault(Return(true)); decoder_.set_visitor(&visitor_); } + ~HttpDecoderTest() override = default; + + uint64_t current_frame_type() { + return HttpDecoderPeer::current_frame_type(&decoder_); + } HttpDecoder decoder_; testing::StrictMock<MockVisitor> visitor_; @@ -92,7 +106,7 @@ << n; EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); ASSERT_EQ("", decoder_.error_detail()); - EXPECT_EQ(type, decoder_.current_frame_type()); + EXPECT_EQ(type, current_frame_type()); } // Test on a arbitrary reserved frame with 2-byte type field by hard coding // variable length integer. @@ -103,7 +117,7 @@ EXPECT_EQ(3u, decoder_.ProcessInput(in, QUIC_ARRAYSIZE(in))); EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); ASSERT_EQ("", decoder_.error_detail()); - EXPECT_EQ(0xB + 0x1F * 3u, decoder_.current_frame_type()); + EXPECT_EQ(0xB + 0x1F * 3u, current_frame_type()); } TEST_F(HttpDecoderTest, ReservedFramesSmallPayload) { @@ -124,7 +138,7 @@ << n; EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); ASSERT_EQ("", decoder_.error_detail()); - EXPECT_EQ(type, decoder_.current_frame_type()); + EXPECT_EQ(type, current_frame_type()); } // Test on a arbitrary reserved frame with 2-byte type field by hard coding @@ -136,7 +150,7 @@ EXPECT_EQ(QUIC_ARRAYSIZE(in), decoder_.ProcessInput(in, QUIC_ARRAYSIZE(in))); EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); ASSERT_EQ("", decoder_.error_detail()); - EXPECT_EQ(0xB + 0x1F * 3u, decoder_.current_frame_type()); + EXPECT_EQ(0xB + 0x1F * 3u, current_frame_type()); } TEST_F(HttpDecoderTest, ReservedFramesLargePayload) { @@ -158,7 +172,7 @@ << n; EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); ASSERT_EQ("", decoder_.error_detail()); - EXPECT_EQ(type, decoder_.current_frame_type()); + EXPECT_EQ(type, current_frame_type()); } // Test on a arbitrary reserved frame with 2-byte type field by hard coding @@ -170,7 +184,7 @@ EXPECT_EQ(QUIC_ARRAYSIZE(in), decoder_.ProcessInput(in, QUIC_ARRAYSIZE(in))); EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); ASSERT_EQ("", decoder_.error_detail()); - EXPECT_EQ(0xB + 0x1F * 3u, decoder_.current_frame_type()); + EXPECT_EQ(0xB + 0x1F * 3u, current_frame_type()); } TEST_F(HttpDecoderTest, CancelPush) { @@ -517,7 +531,7 @@ } EXPECT_EQ(QUIC_NO_ERROR, decoder_.error()); EXPECT_EQ("", decoder_.error_detail()); - EXPECT_EQ(type, decoder_.current_frame_type()); + EXPECT_EQ(type, current_frame_type()); } TEST_F(HttpDecoderTest, GoAway) { @@ -675,4 +689,6 @@ EXPECT_EQ("Frame is too large", decoder_.error_detail()); } +} // namespace test + } // namespace quic