Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1570549 - P2 - refactor unit tests - r=bwc
Browse files Browse the repository at this point in the history
  • Loading branch information
na-g committed Nov 23, 2019
1 parent c021695 commit 83eb70f
Show file tree
Hide file tree
Showing 3 changed files with 564 additions and 531 deletions.
2 changes: 1 addition & 1 deletion media/webrtc/signaling/fuzztest/sdp_parser_libfuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

using namespace mozilla;

static mozilla::UniquePtr<Sdp> sdpPtr;
static mozilla::UniquePtr<SdpParser::Results> sdpPtr;
static SipccSdpParser mParser;

int FuzzingInitSdpParser(int* argc, char*** argv) { return 0; }
Expand Down
21 changes: 11 additions & 10 deletions media/webrtc/signaling/gtest/jsep_session_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,11 +1151,12 @@ class JsepSessionTest : public JsepSessionTestBase,
};

// For streaming parse errors
std::string GetParseErrors(const SipccSdpParser& parser) const {
std::string GetParseErrors(
const UniquePtr<SdpParser::Results>& results) const {
std::stringstream output;
for (auto e = parser.GetParseErrors().begin();
e != parser.GetParseErrors().end(); ++e) {
output << e->first << ": " << e->second << std::endl;
auto errors = std::move(results->Errors());
for (auto error : errors) {
output << error.first << ": " << error.second << std::endl;
}
return output.str();
}
Expand Down Expand Up @@ -1349,9 +1350,10 @@ class JsepSessionTest : public JsepSessionTestBase,

UniquePtr<Sdp> Parse(const std::string& sdp) const {
SipccSdpParser parser;
UniquePtr<Sdp> parsed = parser.Parse(sdp);
auto results = parser.Parse(sdp);
UniquePtr<Sdp> parsed = std::move(results->Sdp());
EXPECT_TRUE(parsed.get()) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
<< "Errors were: " << GetParseErrors(results);
return parsed;
}

Expand Down Expand Up @@ -4850,8 +4852,8 @@ TEST_P(JsepSessionTest, TestBalancedBundle) {
mSessionOff->SetBundlePolicy(kBundleBalanced);

std::string offer = CreateOffer();
SipccSdpParser parser;
UniquePtr<Sdp> parsedOffer = parser.Parse(offer);
UniquePtr<Sdp> parsedOffer = std::move(SipccSdpParser().Parse(offer)->Sdp());

ASSERT_TRUE(parsedOffer.get());

std::map<SdpMediaSection::MediaType, SdpMediaSection*> firstByType;
Expand Down Expand Up @@ -4886,8 +4888,7 @@ TEST_P(JsepSessionTest, TestMaxBundle) {
OfferAnswer();

std::string offer = mSessionOff->GetLocalDescription(kJsepDescriptionCurrent);
SipccSdpParser parser;
UniquePtr<Sdp> parsedOffer = parser.Parse(offer);
UniquePtr<Sdp> parsedOffer = std::move(SipccSdpParser().Parse(offer)->Sdp());
ASSERT_TRUE(parsedOffer.get());

ASSERT_FALSE(parsedOffer->GetMediaSection(0).GetAttributeList().HasAttribute(
Expand Down
Loading

0 comments on commit 83eb70f

Please sign in to comment.