pc: Enhance stability integration test with AbslStringify and prioritized checks - Added AbslStringify to FactorySignature::Id to support logging its name. - Updated BasicOfferAnswerPayloadTypesStable to check codec content (unordered) before checking sequence, providing better failure signals. - Enhanced failure messages to include the Factory ID. - Added a unit test for DumpAsResultingCodecList to verify its output. Bug: webrtc:397895867 Change-Id: Ia6fe1ca3dc6f5154b597c132969fef3574c4b59d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/456062 Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47127}
diff --git a/pc/peer_connection_stability_integrationtest.cc b/pc/peer_connection_stability_integrationtest.cc index 8d30522..eb8948b 100644 --- a/pc/peer_connection_stability_integrationtest.cc +++ b/pc/peer_connection_stability_integrationtest.cc
@@ -48,6 +48,7 @@ using ::testing::ElementsAreArray; using ::testing::Eq; using ::testing::Not; +using ::testing::UnorderedElementsAreArray; class FactorySignature { public: @@ -61,6 +62,28 @@ kWebRtcAndroid, kGoogleInternal, }; + + template <typename Sink> + friend void AbslStringify(Sink& sink, Id id) { + switch (id) { + case Id::kNotRecognized: + sink.Append("kNotRecognized"); + break; + case Id::kWebRtcTipOfTree: + sink.Append("kWebRtcTipOfTree"); + break; + case Id::kWebRtcMoreConfigs1: + sink.Append("kWebRtcMoreConfigs1"); + break; + case Id::kWebRtcAndroid: + sink.Append("kWebRtcAndroid"); + break; + case Id::kGoogleInternal: + sink.Append("kGoogleInternal"); + break; + } + } + Id id() { return id_; } FactorySignature() { ExtractSignatureStrings(); @@ -377,10 +400,7 @@ std::vector<std::string> callee_local, std::vector<std::string> callee_remote) { StringBuilder sb; - // TODO: issues.webrtc.org/397895867 - change kChangeThis to the name of - // the value. Requires adding an AbslStringifier to the enum. - sb << "\n{" << ".factory_id = FactorySignature::Id::kChangeThis" - << static_cast<int>(id) << ",\n" + sb << "\n{" << ".factory_id = FactorySignature::Id::" << id << ",\n" << ".caller_local = {"; for (const std::string& str : caller_local) { sb << "\"" << str << "\",\n"; @@ -940,13 +960,54 @@ const ResultingCodecList& this_golden = *this_golden_it; EXPECT_THAT(CodecList(*caller()->pc()->local_description()), - ElementsAreArray(this_golden.caller_local)); + UnorderedElementsAreArray(this_golden.caller_local)) + << "Factory ID: " << factory_signature.id(); EXPECT_THAT(CodecList(*caller()->pc()->remote_description()), - ElementsAreArray(this_golden.caller_remote)); + UnorderedElementsAreArray(this_golden.caller_remote)) + << "Factory ID: " << factory_signature.id(); EXPECT_THAT(CodecList(*callee()->pc()->local_description()), - ElementsAreArray(this_golden.callee_local)); + UnorderedElementsAreArray(this_golden.callee_local)) + << "Factory ID: " << factory_signature.id(); EXPECT_THAT(CodecList(*callee()->pc()->remote_description()), - ElementsAreArray(this_golden.callee_remote)); + UnorderedElementsAreArray(this_golden.callee_remote)) + << "Factory ID: " << factory_signature.id(); + + if (HasFailure()) { + return; + } + + EXPECT_THAT(CodecList(*caller()->pc()->local_description()), + ElementsAreArray(this_golden.caller_local)) + << "Factory ID: " << factory_signature.id(); + EXPECT_THAT(CodecList(*caller()->pc()->remote_description()), + ElementsAreArray(this_golden.caller_remote)) + << "Factory ID: " << factory_signature.id(); + EXPECT_THAT(CodecList(*callee()->pc()->local_description()), + ElementsAreArray(this_golden.callee_local)) + << "Factory ID: " << factory_signature.id(); + EXPECT_THAT(CodecList(*callee()->pc()->remote_description()), + ElementsAreArray(this_golden.callee_remote)) + << "Factory ID: " << factory_signature.id(); +} + +TEST_F(PeerConnectionIntegrationTest, + DumpAsResultingCodecListProducesExpectedOutput) { + std::vector<std::string> caller_local = {"cl1"}; + std::vector<std::string> caller_remote = {"cr1"}; + std::vector<std::string> callee_local = {"ce_l1"}; + std::vector<std::string> callee_remote = {"ce_r1"}; + + std::string output = DumpAsResultingCodecList( + FactorySignature::Id::kWebRtcTipOfTree, caller_local, caller_remote, + callee_local, callee_remote); + + EXPECT_THAT(output, + Eq("\n{.factory_id = FactorySignature::Id::kWebRtcTipOfTree,\n" + ".caller_local = {\"cl1\",\n},\n" + " .caller_remote = {\"cr1\",\n},\n" + " .callee_local = {\"ce_l1\",\n},\n" + " .callee_remote = {\"ce_r1\",\n" + "}}\n")); } } // namespace