Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1224)

Unified Diff: webrtc/p2p/base/transportdescriptionfactory_unittest.cc

Issue 1336553003: Revert change which removes GICE (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/transportdescriptionfactory.cc ('k') | webrtc/p2p/base/turnport_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/transportdescriptionfactory_unittest.cc
diff --git a/webrtc/p2p/base/transportdescriptionfactory_unittest.cc b/webrtc/p2p/base/transportdescriptionfactory_unittest.cc
index e3992dfdd361c252203bacb3940a74d069211295..2222fddbf334cebcbfcd358dd0716fad9e219f65 100644
--- a/webrtc/p2p/base/transportdescriptionfactory_unittest.cc
+++ b/webrtc/p2p/base/transportdescriptionfactory_unittest.cc
@@ -32,10 +32,11 @@ class TransportDescriptionFactoryTest : public testing::Test {
new rtc::FakeSSLIdentity("User2")).Pass())) {
}
- void CheckDesc(const TransportDescription* desc,
+ void CheckDesc(const TransportDescription* desc, const std::string& type,
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),
@@ -120,13 +121,33 @@ class TransportDescriptionFactoryTest : public testing::Test {
rtc::scoped_refptr<rtc::RTCCertificate> cert2_;
};
-TEST_F(TransportDescriptionFactoryTest, TestOfferDefault) {
+// Test that in the default case, we generate the expected G-ICE offer.
+TEST_F(TransportDescriptionFactoryTest, TestOfferGice) {
+ f1_.set_protocol(cricket::ICEPROTO_GOOGLE);
scoped_ptr<TransportDescription> desc(f1_.CreateOffer(
TransportOptions(), NULL));
- CheckDesc(desc.get(), "", "", "", "");
+ CheckDesc(desc.get(), cricket::NS_GINGLE_P2P, "", "", "", "");
}
-TEST_F(TransportDescriptionFactoryTest, TestOfferDtls) {
+// 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);
f1_.set_secure(cricket::SEC_ENABLED);
f1_.set_certificate(cert1_);
std::string digest_alg;
@@ -134,24 +155,28 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtls) {
&digest_alg));
scoped_ptr<TransportDescription> desc(f1_.CreateOffer(
TransportOptions(), NULL));
- CheckDesc(desc.get(), "", "", "", digest_alg);
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "google-ice", "", "",
+ digest_alg);
// Ensure it also works with SEC_REQUIRED.
f1_.set_secure(cricket::SEC_REQUIRED);
desc.reset(f1_.CreateOffer(TransportOptions(), NULL));
- CheckDesc(desc.get(), "", "", "", digest_alg);
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "google-ice", "", "",
+ digest_alg);
}
-// Test generating an offer with DTLS fails with no identity.
-TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsWithNoIdentity) {
+// Test generating a hybrid offer with DTLS fails with no identity.
+TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtlsWithNoIdentity) {
+ f1_.set_protocol(cricket::ICEPROTO_HYBRID);
f1_.set_secure(cricket::SEC_ENABLED);
scoped_ptr<TransportDescription> desc(f1_.CreateOffer(
TransportOptions(), NULL));
ASSERT_TRUE(desc.get() == NULL);
}
-// Test updating an offer with DTLS to pick ICE.
+// Test updating a hybrid offer with DTLS to pick ICE.
// The ICE credentials should stay the same in the new offer.
-TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsReofferDtls) {
+TEST_F(TransportDescriptionFactoryTest, TestOfferHybridDtlsReofferIceDtls) {
+ f1_.set_protocol(cricket::ICEPROTO_HYBRID);
f1_.set_secure(cricket::SEC_ENABLED);
f1_.set_certificate(cert1_);
std::string digest_alg;
@@ -160,26 +185,104 @@ TEST_F(TransportDescriptionFactoryTest, TestOfferDtlsReofferDtls) {
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(), "",
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "",
old_desc->ice_ufrag, old_desc->ice_pwd, digest_alg);
}
-TEST_F(TransportDescriptionFactoryTest, TestAnswerDefault) {
+// 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);
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(), "", "", "", "");
+ CheckDesc(desc.get(), cricket::NS_GINGLE_P2P, "", "", "", "");
+ // 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(), "", "", "", "");
+ 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);
}
// Test that we can update an answer properly; ICE credentials shouldn't change.
-TEST_F(TransportDescriptionFactoryTest, TestReanswer) {
+TEST_F(TransportDescriptionFactoryTest, TestAnswerIceToIceReanswer) {
+ 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);
@@ -190,25 +293,29 @@ TEST_F(TransportDescriptionFactoryTest, TestReanswer) {
f2_.CreateAnswer(offer.get(), TransportOptions(),
old_desc.get()));
ASSERT_TRUE(desc.get() != NULL);
- CheckDesc(desc.get(), "",
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "",
old_desc->ice_ufrag, old_desc->ice_pwd, "");
}
// Test that we handle answering an offer with DTLS with no DTLS.
-TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToNoDtls) {
+TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridToHybridDtls) {
+ f1_.set_protocol(cricket::ICEPROTO_HYBRID);
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(), "", "", "", "");
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", "");
}
// Test that we handle answering an offer without DTLS if we have DTLS enabled,
// but fail if we require DTLS.
-TEST_F(TransportDescriptionFactoryTest, TestAnswerNoDtlsToDtls) {
+TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybrid) {
+ f1_.set_protocol(cricket::ICEPROTO_HYBRID);
+ f2_.set_protocol(cricket::ICEPROTO_HYBRID);
f2_.set_secure(cricket::SEC_ENABLED);
f2_.set_certificate(cert2_);
scoped_ptr<TransportDescription> offer(
@@ -216,7 +323,7 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerNoDtlsToDtls) {
ASSERT_TRUE(offer.get() != NULL);
scoped_ptr<TransportDescription> desc(
f2_.CreateAnswer(offer.get(), TransportOptions(), NULL));
- CheckDesc(desc.get(), "", "", "", "");
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", "");
f2_.set_secure(cricket::SEC_REQUIRED);
desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(),
NULL));
@@ -225,10 +332,12 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerNoDtlsToDtls) {
// Test that we handle answering an DTLS offer with DTLS, both if we have
// DTLS enabled and required.
-TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToDtls) {
+TEST_F(TransportDescriptionFactoryTest, TestAnswerHybridDtlsToHybridDtls) {
+ f1_.set_protocol(cricket::ICEPROTO_HYBRID);
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
@@ -242,11 +351,11 @@ TEST_F(TransportDescriptionFactoryTest, TestAnswerDtlsToDtls) {
ASSERT_TRUE(offer.get() != NULL);
scoped_ptr<TransportDescription> desc(
f2_.CreateAnswer(offer.get(), TransportOptions(), NULL));
- CheckDesc(desc.get(), "", "", "", digest_alg2);
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", digest_alg2);
f2_.set_secure(cricket::SEC_REQUIRED);
desc.reset(f2_.CreateAnswer(offer.get(), TransportOptions(),
NULL));
- CheckDesc(desc.get(), "", "", "", digest_alg2);
+ CheckDesc(desc.get(), cricket::NS_JINGLE_ICE_UDP, "", "", "", digest_alg2);
}
// Test that ice ufrag and password is changed in an updated offer and answer
« no previous file with comments | « webrtc/p2p/base/transportdescriptionfactory.cc ('k') | webrtc/p2p/base/turnport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698