Bug 1120796 - Part 1: Prepare code for explicit bool operators. r=Waldo

This commit is contained in:
Birunthan Mohanathas 2015-02-03 18:52:28 +02:00
parent 2d111ab8df
commit 847dbb9825
5 changed files with 61 additions and 49 deletions

View File

@ -3541,7 +3541,7 @@ public:
}
bool IsOffscreen() const {
return mScreen;
return !!mScreen;
}
GLScreenBuffer* Screen() const {

View File

@ -241,6 +241,18 @@ class JS_FRIEND_API(GCCellPtr)
uintptr_t ptr;
};
inline bool
operator==(const GCCellPtr &ptr1, const GCCellPtr &ptr2)
{
return ptr1.asCell() == ptr2.asCell();
}
inline bool
operator!=(const GCCellPtr &ptr1, const GCCellPtr &ptr2)
{
return !(ptr1 == ptr2);
}
} /* namespace JS */
namespace js {

View File

@ -433,8 +433,8 @@ protected:
local ? session.GetLocalDescription() : session.GetRemoteDescription();
SipccSdpParser parser;
UniquePtr<Sdp> parsed = parser.Parse(sdp);
ASSERT_TRUE(parsed) << "Parse failed on " << std::endl << sdp << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!parsed) << "Parse failed on " << std::endl << sdp << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_LT(0U, parsed->GetMediaSectionCount());
auto& msection_0 = parsed->GetMediaSection(0);
@ -531,8 +531,8 @@ private:
{
SipccSdpParser parser;
auto sdp = mozilla::Move(parser.Parse(sdp_str));
ASSERT_TRUE(sdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!sdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
size_t num_m_sections = sdp->GetMediaSectionCount();
for (size_t i = 0; i < num_m_sections; ++i) {
auto& msection = sdp->GetMediaSection(i);
@ -673,8 +673,8 @@ TEST_F(JsepSessionTest, OfferAnswerRecvOnlyLines)
SipccSdpParser parser;
auto outputSdp = mozilla::Move(parser.Parse(offer));
ASSERT_TRUE(outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_EQ(3U, outputSdp->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kAudio,
@ -732,8 +732,8 @@ TEST_F(JsepSessionTest, OfferAnswerSendOnlyLines)
SipccSdpParser parser;
auto outputSdp = mozilla::Move(parser.Parse(offer));
ASSERT_TRUE(outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_EQ(3U, outputSdp->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kAudio,
@ -793,8 +793,8 @@ TEST_F(JsepSessionTest, CreateOfferNoDatachannelDefault)
SipccSdpParser parser;
auto outputSdp = mozilla::Move(parser.Parse(offer));
ASSERT_TRUE(outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_EQ(2U, outputSdp->GetMediaSectionCount());
ASSERT_EQ(SdpMediaSection::kAudio,
@ -819,8 +819,8 @@ TEST_F(JsepSessionTest, ValidateOfferedCodecParams)
SipccSdpParser parser;
auto outputSdp = mozilla::Move(parser.Parse(offer));
ASSERT_TRUE(outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_EQ(2U, outputSdp->GetMediaSectionCount());
auto& video_section = outputSdp->GetMediaSection(1);
@ -856,7 +856,7 @@ TEST_F(JsepSessionTest, ValidateOfferedCodecParams)
// VP8
ASSERT_EQ("120", fmtps[0].format);
ASSERT_TRUE(fmtps[0].parameters);
ASSERT_TRUE(!!fmtps[0].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kVP8, fmtps[0].parameters->codec_type);
auto& parsed_vp8_params =
@ -868,7 +868,7 @@ TEST_F(JsepSessionTest, ValidateOfferedCodecParams)
// H264 packetization mode 1
ASSERT_EQ("126", fmtps[1].format);
ASSERT_TRUE(fmtps[1].parameters);
ASSERT_TRUE(!!fmtps[1].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kH264, fmtps[1].parameters->codec_type);
auto& parsed_h264_1_params =
@ -881,7 +881,7 @@ TEST_F(JsepSessionTest, ValidateOfferedCodecParams)
// H264 packetization mode 0
ASSERT_EQ("97", fmtps[2].format);
ASSERT_TRUE(fmtps[2].parameters);
ASSERT_TRUE(!!fmtps[2].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kH264, fmtps[2].parameters->codec_type);
auto& parsed_h264_0_params =
@ -937,8 +937,8 @@ TEST_F(JsepSessionTest, ValidateAnsweredCodecParams)
SipccSdpParser parser;
auto outputSdp = mozilla::Move(parser.Parse(answer));
ASSERT_TRUE(outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_EQ(2U, outputSdp->GetMediaSectionCount());
auto& video_section = outputSdp->GetMediaSection(1);
@ -977,7 +977,7 @@ TEST_F(JsepSessionTest, ValidateAnsweredCodecParams)
// VP8
ASSERT_EQ("120", fmtps[0].format);
ASSERT_TRUE(fmtps[0].parameters);
ASSERT_TRUE(!!fmtps[0].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kVP8, fmtps[0].parameters->codec_type);
auto& parsed_vp8_params =
@ -1094,8 +1094,8 @@ TEST_P(JsepSessionTest, TestRejectMline)
SipccSdpParser parser;
auto outputSdp = mozilla::Move(parser.Parse(answer));
ASSERT_TRUE(outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_TRUE(!!outputSdp) << "Should have valid SDP" << std::endl
<< "Errors were: " << GetParseErrors(parser);
ASSERT_NE(0U, outputSdp->GetMediaSectionCount());
SdpMediaSection* failed_section = nullptr;

View File

@ -869,8 +869,8 @@ class NewSdpTest : public ::testing::Test,
std::stringstream os;
if (expectSuccess) {
ASSERT_TRUE(mSdp) << "Parse failed on first pass: "
<< GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed on first pass: "
<< GetParseErrors();
}
if (mSdp) {
@ -880,7 +880,7 @@ class NewSdpTest : public ::testing::Test,
// Whether we expected the parse to work or not, it should
// succeed the second time if it succeeded the first.
ASSERT_TRUE(mSdp) << "Parse failed on second pass, SDP was: "
ASSERT_TRUE(!!mSdp) << "Parse failed on second pass, SDP was: "
<< std::endl << os.str() << std::endl
<< "Errors were: " << GetParseErrors();
@ -892,7 +892,7 @@ class NewSdpTest : public ::testing::Test,
}
if (expectSuccess) {
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(0U, mParser.GetParseErrors().size())
<< "Got unexpected parse errors/warnings: "
<< GetParseErrors();
@ -1199,7 +1199,7 @@ TEST_P(NewSdpTest, BasicAudioVideoSdpParse) {
TEST_P(NewSdpTest, CheckIceUfrag) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute(
SdpAttribute::kIceUfragAttribute));
auto ice_ufrag = mSdp->GetAttributeList().GetIceUfrag();
@ -1216,7 +1216,7 @@ TEST_P(NewSdpTest, CheckIceUfrag) {
TEST_P(NewSdpTest, CheckIcePwd) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute(
SdpAttribute::kIcePwdAttribute));
auto ice_pwd = mSdp->GetAttributeList().GetIcePwd();
@ -1235,7 +1235,7 @@ TEST_P(NewSdpTest, CheckIcePwd) {
TEST_P(NewSdpTest, CheckIceOptions) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute(
SdpAttribute::kIceOptionsAttribute));
auto ice_options = mSdp->GetAttributeList().GetIceOptions();
@ -1254,7 +1254,7 @@ TEST_P(NewSdpTest, CheckIceOptions) {
TEST_P(NewSdpTest, CheckFingerprint) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute(
SdpAttribute::kFingerprintAttribute));
auto fingerprints = mSdp->GetAttributeList().GetFingerprint();
@ -1273,7 +1273,7 @@ TEST_P(NewSdpTest, CheckFingerprint) {
TEST_P(NewSdpTest, CheckIdentity) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(mSdp->GetAttributeList().HasAttribute(
SdpAttribute::kIdentityAttribute));
auto identity = mSdp->GetAttributeList().GetIdentity();
@ -1282,13 +1282,13 @@ TEST_P(NewSdpTest, CheckIdentity) {
TEST_P(NewSdpTest, CheckNumberOfMediaSections) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
}
TEST_P(NewSdpTest, CheckMlines) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_EQ(SdpMediaSection::kAudio, mSdp->GetMediaSection(0).GetMediaType())
<< "Wrong type for first media section";
@ -1318,7 +1318,7 @@ TEST_P(NewSdpTest, CheckMlines) {
TEST_P(NewSdpTest, CheckSetup) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_TRUE(mSdp->GetMediaSection(0).GetAttributeList().HasAttribute(
@ -1336,7 +1336,7 @@ TEST_P(NewSdpTest, CheckSetup) {
TEST_P(NewSdpTest, CheckSsrc)
{
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_TRUE(mSdp->GetMediaSection(0).GetAttributeList().HasAttribute(
@ -1358,7 +1358,7 @@ TEST_P(NewSdpTest, CheckSsrc)
TEST_P(NewSdpTest, CheckRtpmap) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount())
<< "Wrong number of media sections";
@ -1488,7 +1488,7 @@ const std::string kH264AudioVideoOffer =
TEST_P(NewSdpTest, CheckFormatParameters) {
ParseSdp(kH264AudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount())
<< "Wrong number of media sections";
@ -1506,7 +1506,7 @@ TEST_P(NewSdpTest, CheckFormatParameters) {
mSdp->GetMediaSection(1).GetAttributeList().GetFmtp().mFmtps;
ASSERT_EQ(3U, video_format_params.size());
ASSERT_EQ("97", video_format_params[0].format);
ASSERT_TRUE(video_format_params[0].parameters);
ASSERT_TRUE(!!video_format_params[0].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kH264,
video_format_params[0].parameters->codec_type);
const SdpFmtpAttributeList::H264Parameters *h264_parameters(
@ -1522,7 +1522,7 @@ TEST_P(NewSdpTest, CheckFormatParameters) {
ASSERT_EQ(0U, h264_parameters->max_br);
ASSERT_EQ("98", video_format_params[1].format);
ASSERT_TRUE(video_format_params[1].parameters);
ASSERT_TRUE(!!video_format_params[1].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kH264,
video_format_params[1].parameters->codec_type);
h264_parameters =
@ -1538,7 +1538,7 @@ TEST_P(NewSdpTest, CheckFormatParameters) {
ASSERT_EQ(180000U, h264_parameters->max_br);
ASSERT_EQ("120", video_format_params[2].format);
ASSERT_TRUE(video_format_params[2].parameters);
ASSERT_TRUE(!!video_format_params[2].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kVP8,
video_format_params[2].parameters->codec_type);
const SdpFmtpAttributeList::VP8Parameters *vp8_parameters =
@ -1589,7 +1589,7 @@ TEST_P(NewSdpTest, CheckFlags) {
TEST_P(NewSdpTest, CheckConnectionLines) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount())
<< "Wrong number of media sections";
@ -1616,7 +1616,7 @@ TEST_P(NewSdpTest, CheckConnectionLines) {
TEST_P(NewSdpTest, CheckDirections) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(SdpDirectionAttribute::kSendonly,
mSdp->GetMediaSection(0).GetAttributeList().GetDirection());
ASSERT_EQ(SdpDirectionAttribute::kRecvonly,
@ -1627,7 +1627,7 @@ TEST_P(NewSdpTest, CheckDirections) {
TEST_P(NewSdpTest, CheckCandidates) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_TRUE(mSdp->GetMediaSection(0).GetAttributeList().HasAttribute(
@ -1705,7 +1705,7 @@ TEST_P(NewSdpTest, CheckMsid) {
TEST_P(NewSdpTest, CheckMediaLevelIceUfrag) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_TRUE(mSdp->GetMediaSection(0).GetAttributeList().HasAttribute(
@ -1724,7 +1724,7 @@ TEST_P(NewSdpTest, CheckMediaLevelIceUfrag) {
TEST_P(NewSdpTest, CheckMediaLevelIcePwd) {
ParseSdp(kBasicAudioVideoOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_TRUE(mSdp->GetMediaSection(0).GetAttributeList().HasAttribute(
@ -1832,7 +1832,7 @@ TEST_P(NewSdpTest, BasicAudioVideoDataSdpParse) {
TEST_P(NewSdpTest, CheckApplicationParameters) {
ParseSdp(kBasicAudioVideoDataOffer);
ASSERT_TRUE(mSdp);
ASSERT_TRUE(!!mSdp);
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_EQ(SdpMediaSection::kAudio, mSdp->GetMediaSection(0).GetMediaType())
<< "Wrong type for first media section";
@ -1862,7 +1862,7 @@ TEST_P(NewSdpTest, CheckApplicationParameters) {
TEST_P(NewSdpTest, CheckExtmap) {
ParseSdp(kBasicAudioVideoDataOffer);
ASSERT_TRUE(mSdp);
ASSERT_TRUE(!!mSdp);
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
ASSERT_TRUE(mSdp->GetMediaSection(0).GetAttributeList().HasAttribute(
@ -1897,7 +1897,7 @@ TEST_P(NewSdpTest, CheckExtmap) {
TEST_P(NewSdpTest, CheckRtcpFb) {
ParseSdp(kBasicAudioVideoDataOffer);
ASSERT_TRUE(mSdp);
ASSERT_TRUE(!!mSdp);
ASSERT_EQ(3U, mSdp->GetMediaSectionCount()) << "Wrong number of media sections";
auto& video_attrs = mSdp->GetMediaSection(1).GetAttributeList();
@ -1927,7 +1927,7 @@ TEST_P(NewSdpTest, CheckRtcpFb) {
TEST_P(NewSdpTest, CheckSctpmap) {
ParseSdp(kBasicAudioVideoDataOffer);
ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
ASSERT_EQ(3U, mSdp->GetMediaSectionCount())
<< "Wrong number of media sections";

View File

@ -22,7 +22,7 @@ using mozilla::Vector;
#define CHECK(c) \
do { \
bool cond = (c); \
bool cond = !!(c); \
MOZ_ASSERT(cond, "Failed assertion: " #c); \
if (!cond) { \
return false; \