Disambiguate MockVisitor

Chrome places multiple tests in one binary, and that does not work well when there are conflicting names that don't live in anonymous namespaces. This CL fixes the problem by adding both a belt and suspenders: it renames the visitor and adds an anonymous namespace to prevent folks from accidentally adding the problem back.

PiperOrigin-RevId: 400026052
diff --git a/quic/core/http/capsule_test.cc b/quic/core/http/capsule_test.cc
index 634cdae..adb613c 100644
--- a/quic/core/http/capsule_test.cc
+++ b/quic/core/http/capsule_test.cc
@@ -22,13 +22,6 @@
 namespace quic {
 namespace test {
 
-namespace {
-constexpr DatagramFormatType kFakeFormatType =
-    static_cast<DatagramFormatType>(0x123456);
-constexpr ContextCloseCode kFakeCloseCode =
-    static_cast<ContextCloseCode>(0x654321);
-}  // namespace
-
 class CapsuleParserPeer {
  public:
   static std::string* buffered_data(CapsuleParser* capsule_parser) {
@@ -36,10 +29,19 @@
   }
 };
 
-class MockVisitor : public CapsuleParser::Visitor {
+namespace {
+
+constexpr DatagramFormatType kFakeFormatType =
+    static_cast<DatagramFormatType>(0x123456);
+constexpr ContextCloseCode kFakeCloseCode =
+    static_cast<ContextCloseCode>(0x654321);
+
+class MockCapsuleParserVisitor : public CapsuleParser::Visitor {
  public:
-  MockVisitor() { ON_CALL(*this, OnCapsule(_)).WillByDefault(Return(true)); }
-  ~MockVisitor() override = default;
+  MockCapsuleParserVisitor() {
+    ON_CALL(*this, OnCapsule(_)).WillByDefault(Return(true));
+  }
+  ~MockCapsuleParserVisitor() override = default;
   MOCK_METHOD(bool, OnCapsule, (const Capsule& capsule), (override));
   MOCK_METHOD(void, OnCapsuleParseFailure, (const std::string& error_message),
               (override));
@@ -66,7 +68,7 @@
         expected_bytes.size());
   }
 
-  ::testing::StrictMock<MockVisitor> visitor_;
+  ::testing::StrictMock<MockCapsuleParserVisitor> visitor_;
   CapsuleParser capsule_parser_;
 };
 
@@ -295,5 +297,6 @@
   }
 }
 
+}  // namespace
 }  // namespace test
 }  // namespace quic
diff --git a/quic/core/http/http_decoder_test.cc b/quic/core/http/http_decoder_test.cc
index 51ad987..95d5913 100644
--- a/quic/core/http/http_decoder_test.cc
+++ b/quic/core/http/http_decoder_test.cc
@@ -27,7 +27,6 @@
 using ::testing::Return;
 
 namespace quic {
-
 namespace test {
 
 class HttpDecoderPeer {
@@ -37,9 +36,11 @@
   }
 };
 
-class MockVisitor : public HttpDecoder::Visitor {
+namespace {
+
+class MockHttpDecoderVisitor : public HttpDecoder::Visitor {
  public:
-  ~MockVisitor() override = default;
+  ~MockHttpDecoderVisitor() override = default;
 
   // Called if an error is detected.
   MOCK_METHOD(void, OnError, (HttpDecoder*), (override));
@@ -164,7 +165,7 @@
     return processed_bytes;
   }
 
-  testing::StrictMock<MockVisitor> visitor_;
+  testing::StrictMock<MockHttpDecoderVisitor> visitor_;
   HttpDecoder decoder_;
 };
 
@@ -635,7 +636,7 @@
       /*one byte of payload*/ sizeof(uint8_t);
   char input[max_input_length];
   for (uint64_t frame_type = 0; frame_type < 1025; frame_type++) {
-    ::testing::NiceMock<MockVisitor> visitor;
+    ::testing::NiceMock<MockHttpDecoderVisitor> visitor;
     HttpDecoder decoder(&visitor);
     QuicDataWriter writer(max_input_length, input);
     ASSERT_TRUE(writer.WriteVarInt62(frame_type));         // frame type.
@@ -1068,7 +1069,7 @@
 TEST(HttpDecoderTestNoFixture, WebTransportStream) {
   HttpDecoder::Options options;
   options.allow_web_transport_stream = true;
-  testing::StrictMock<MockVisitor> visitor;
+  testing::StrictMock<MockHttpDecoderVisitor> visitor;
   HttpDecoder decoder(&visitor, options);
 
   // WebTransport stream for session ID 0x104, with four bytes of extra data.
@@ -1081,7 +1082,7 @@
 TEST(HttpDecoderTestNoFixture, WebTransportStreamError) {
   HttpDecoder::Options options;
   options.allow_web_transport_stream = true;
-  testing::StrictMock<MockVisitor> visitor;
+  testing::StrictMock<MockHttpDecoderVisitor> visitor;
   HttpDecoder decoder(&visitor, options);
 
   std::string input = absl::HexStringToBytes("404100");
@@ -1130,6 +1131,6 @@
   EXPECT_FALSE(HttpDecoder::DecodeSettings(input.data(), input.size(), &out));
 }
 
+}  // namespace
 }  // namespace test
-
 }  // namespace quic