Index: webrtc/p2p/base/transportdescriptionfactory_unittest.cc |
diff --git a/webrtc/p2p/base/transportdescriptionfactory_unittest.cc b/webrtc/p2p/base/transportdescriptionfactory_unittest.cc |
index 2222fddbf334cebcbfcd358dd0716fad9e219f65..e3992dfdd361c252203bacb3940a74d069211295 100644 |
--- a/webrtc/p2p/base/transportdescriptionfactory_unittest.cc |
+++ b/webrtc/p2p/base/transportdescriptionfactory_unittest.cc |
@@ -32,11 +32,10 @@ class TransportDescriptionFactoryTest : public testing::Test { |
new rtc::FakeSSLIdentity("User2")).Pass())) { |
} |
- void CheckDesc(const TransportDescription* desc, const std::string& type, |
+ void CheckDesc(const TransportDescription* desc, |
const std::string& opt, const std::string& ice_ufrag, |
const std::string& ice_pwd, const std::string& dtls_alg) { |
ASSERT_TRUE(desc != NULL); |
- EXPECT_EQ(type, desc->transport_type); |
EXPECT_EQ(!opt.empty(), desc->HasOption(opt)); |
if (ice_ufrag.empty() && ice_pwd.empty()) { |
EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH), |
@@ -121,33 +120,13 @@ class TransportDescriptionFactoryTest : public testing::Test { |
rtc::scoped_refptr<rtc::RTCCertificate> cert2_; |
}; |
-// Test that in the default case, we generate the expected G-ICE offer. |
-TEST_F(TransportDescriptionFactoryTest, TestOfferGice) { |
- f1_.set_protocol(cricket::ICEPROTO_GOOGLE); |
+TEST_F(TransportDescriptionFactoryTest, TestOfferDefault) { |
scoped_ptr<TransportDescription> desc(f1_.CreateOffer( |
TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_GINGLE_P2P, "", "", "", ""); |
+ CheckDesc(desc.get(), "", "", "", ""); |
} |
-// Test generating a hybrid offer. |
-TEST_F(TransportDescriptionFactoryTest, TestOfferHybrid) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
- scoped_ptr<TransportDescription> desc(f1_.CreateOffer( |
- TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "google-ice", "", "", ""); |
-} |
- |
-// Test generating an ICE-only offer. |
-TEST_F(TransportDescriptionFactoryTest, TestOfferIce) { |
- f1_.set_protocol(cricket::ICEPROTO_RFC5245); |
- scoped_ptr<TransportDescription> desc(f1_.CreateOffer( |
- TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
-} |
- |
-// Test generating a hybrid offer with DTLS. |
-TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtls) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
+TEST_F(TransportDescriptionFactoryTest, TestOfferDtls) { |
f1_.set_secure(cricket::SEC_ENABLED); |
f1_.set_certificate(cert1_); |
std::string digest_alg; |
@@ -155,28 +134,24 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtls) { |
&digest_alg)); |
scoped_ptr<TransportDescription> desc(f1_.CreateOffer( |
TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "google-ice", "", "", |
- digest_alg); |
+ CheckDesc(desc.get(), "", "", "", digest_alg); |
// Ensure it also works with SEC_REQUIRED. |
f1_.set_secure(cricket::SEC_REQUIRED); |
desc.reset(f1_.CreateOffer(TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "google-ice", "", "", |
- digest_alg); |
+ CheckDesc(desc.get(), "", "", "", digest_alg); |
} |
-// Test generating a hybrid offer with DTLS fails with no identity. |
-TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtlsWithNoIdentity) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
+// Test generating an offer with DTLS fails with no identity. |
+TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsWithNoIdentity) { |
f1_.set_secure(cricket::SEC_ENABLED); |
scoped_ptr<TransportDescription> desc(f1_.CreateOffer( |
TransportOptions(), NULL)); |
ASSERT_TRUE(desc.get() == NULL); |
} |
-// Test updating a hybrid offer with DTLS to pick ICE. |
+// Test updating an offer with DTLS to pick ICE. |
// The ICE credentials should stay the same in the new offer. |
-TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtlsReofferIceDtls) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
+TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsReofferDtls) { |
f1_.set_secure(cricket::SEC_ENABLED); |
f1_.set_certificate(cert1_); |
std::string digest_alg; |
@@ -185,104 +160,26 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtlsReofferIceDtls) { |
scoped_ptr<TransportDescription> old_desc(f1_.CreateOffer( |
TransportOptions(), NULL)); |
ASSERT_TRUE(old_desc.get() != NULL); |
- f1_.set_protocol(cricket::ICEPROTO_RFC5245); |
scoped_ptr<TransportDescription> desc( |
f1_.CreateOffer(TransportOptions(), old_desc.get())); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", |
+ CheckDesc(desc.get(), "", |
old_desc->ice_ufrag, old_desc->ice_pwd, digest_alg); |
} |
-// Test that we can answer a GICE offer with GICE. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerGiceToGice) { |
- f1_.set_protocol(cricket::ICEPROTO_GOOGLE); |
- f2_.set_protocol(cricket::ICEPROTO_GOOGLE); |
+TEST_F(TransportDescriptionFactoryTest, TestAnswerDefault) { |
scoped_ptr<TransportDescription> offer(f1_.CreateOffer( |
TransportOptions(), NULL)); |
ASSERT_TRUE(offer.get() != NULL); |
scoped_ptr<TransportDescription> desc(f2_.CreateAnswer( |
offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_GINGLE_P2P, "", "", "", ""); |
- // Should get the same result when answering as hybrid. |
- f2_.set_protocol(cricket::ICEPROTO_HYBRID); |
+ CheckDesc(desc.get(), "", "", "", ""); |
desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(), |
NULL)); |
- CheckDesc(desc.get(), cricket::NS_GINGLE_P2P, "", "", "", ""); |
-} |
- |
-// Test that we can answer a hybrid offer with GICE. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerGiceToHybrid) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
- f2_.set_protocol(cricket::ICEPROTO_GOOGLE); |
- scoped_ptr<TransportDescription> offer(f1_.CreateOffer( |
- TransportOptions(), NULL)); |
- ASSERT_TRUE(offer.get() != NULL); |
- scoped_ptr<TransportDescription> desc( |
- f2_.CreateAnswer(offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_GINGLE_P2P, "", "", "", ""); |
-} |
- |
-// Test that we can answer a hybrid offer with ICE. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerIceToHybrid) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
- f2_.set_protocol(cricket::ICEPROTO_RFC5245); |
- scoped_ptr<TransportDescription> offer(f1_.CreateOffer( |
- TransportOptions(), NULL)); |
- ASSERT_TRUE(offer.get() != NULL); |
- scoped_ptr<TransportDescription> desc( |
- f2_.CreateAnswer(offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
- // Should get the same result when answering as hybrid. |
- f2_.set_protocol(cricket::ICEPROTO_HYBRID); |
- desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(), |
- NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
-} |
- |
-// Test that we can answer an ICE offer with ICE. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerIceToIce) { |
- f1_.set_protocol(cricket::ICEPROTO_RFC5245); |
- f2_.set_protocol(cricket::ICEPROTO_RFC5245); |
- scoped_ptr<TransportDescription> offer(f1_.CreateOffer( |
- TransportOptions(), NULL)); |
- ASSERT_TRUE(offer.get() != NULL); |
- scoped_ptr<TransportDescription> desc(f2_.CreateAnswer( |
- offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
- // Should get the same result when answering as hybrid. |
- f2_.set_protocol(cricket::ICEPROTO_HYBRID); |
- desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(), |
- NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
-} |
- |
-// Test that we can't answer a GICE offer with ICE. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerIceToGice) { |
- f1_.set_protocol(cricket::ICEPROTO_GOOGLE); |
- f2_.set_protocol(cricket::ICEPROTO_RFC5245); |
- scoped_ptr<TransportDescription> offer( |
- f1_.CreateOffer(TransportOptions(), NULL)); |
- ASSERT_TRUE(offer.get() != NULL); |
- scoped_ptr<TransportDescription> desc( |
- f2_.CreateAnswer(offer.get(), TransportOptions(), NULL)); |
- ASSERT_TRUE(desc.get() == NULL); |
-} |
- |
-// Test that we can't answer an ICE offer with GICE. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerGiceToIce) { |
- f1_.set_protocol(cricket::ICEPROTO_RFC5245); |
- f2_.set_protocol(cricket::ICEPROTO_GOOGLE); |
- scoped_ptr<TransportDescription> offer( |
- f1_.CreateOffer(TransportOptions(), NULL)); |
- ASSERT_TRUE(offer.get() != NULL); |
- scoped_ptr<TransportDescription> desc(f2_.CreateAnswer( |
- offer.get(), TransportOptions(), NULL)); |
- ASSERT_TRUE(desc.get() == NULL); |
+ CheckDesc(desc.get(), "", "", "", ""); |
} |
// Test that we can update an answer properly; ICE credentials shouldn't change. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerIceToIceReanswer) { |
- f1_.set_protocol(cricket::ICEPROTO_RFC5245); |
- f2_.set_protocol(cricket::ICEPROTO_RFC5245); |
+TEST_F(TransportDescriptionFactoryTest, TestReanswer) { |
scoped_ptr<TransportDescription> offer( |
f1_.CreateOffer(TransportOptions(), NULL)); |
ASSERT_TRUE(offer.get() != NULL); |
@@ -293,29 +190,25 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerIceToIceReanswer) { |
f2_.CreateAnswer(offer.get(), TransportOptions(), |
old_desc.get())); |
ASSERT_TRUE(desc.get() != NULL); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", |
+ CheckDesc(desc.get(), "", |
old_desc->ice_ufrag, old_desc->ice_pwd, ""); |
} |
// Test that we handle answering an offer with DTLS with no DTLS. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridToHybridDtls) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
+TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToNoDtls) { |
f1_.set_secure(cricket::SEC_ENABLED); |
f1_.set_certificate(cert1_); |
- f2_.set_protocol(cricket::ICEPROTO_HYBRID); |
scoped_ptr<TransportDescription> offer( |
f1_.CreateOffer(TransportOptions(), NULL)); |
ASSERT_TRUE(offer.get() != NULL); |
scoped_ptr<TransportDescription> desc( |
f2_.CreateAnswer(offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
+ CheckDesc(desc.get(), "", "", "", ""); |
} |
// Test that we handle answering an offer without DTLS if we have DTLS enabled, |
// but fail if we require DTLS. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybrid) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
- f2_.set_protocol(cricket::ICEPROTO_HYBRID); |
+TEST_F(TransportDescriptionFactoryTest, TestAnswerNoDtlsToDtls) { |
f2_.set_secure(cricket::SEC_ENABLED); |
f2_.set_certificate(cert2_); |
scoped_ptr<TransportDescription> offer( |
@@ -323,7 +216,7 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybrid) { |
ASSERT_TRUE(offer.get() != NULL); |
scoped_ptr<TransportDescription> desc( |
f2_.CreateAnswer(offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", ""); |
+ CheckDesc(desc.get(), "", "", "", ""); |
f2_.set_secure(cricket::SEC_REQUIRED); |
desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(), |
NULL)); |
@@ -332,12 +225,10 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybrid) { |
// Test that we handle answering an DTLS offer with DTLS, both if we have |
// DTLS enabled and required. |
-TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybridDtls) { |
- f1_.set_protocol(cricket::ICEPROTO_HYBRID); |
+TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToDtls) { |
f1_.set_secure(cricket::SEC_ENABLED); |
f1_.set_certificate(cert1_); |
- f2_.set_protocol(cricket::ICEPROTO_HYBRID); |
f2_.set_secure(cricket::SEC_ENABLED); |
f2_.set_certificate(cert2_); |
// f2_ produces the answer that is being checked in this test, so the |
@@ -351,11 +242,11 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybridDtls) { |
ASSERT_TRUE(offer.get() != NULL); |
scoped_ptr<TransportDescription> desc( |
f2_.CreateAnswer(offer.get(), TransportOptions(), NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", digest_alg2); |
+ CheckDesc(desc.get(), "", "", "", digest_alg2); |
f2_.set_secure(cricket::SEC_REQUIRED); |
desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(), |
NULL)); |
- CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", digest_alg2); |
+ CheckDesc(desc.get(), "", "", "", digest_alg2); |
} |
// Test that ice ufrag and password is changed in an updated offer and answer |