OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 2875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2886 CreateOfferAsLocalDescription(); | 2886 CreateOfferAsLocalDescription(); |
2887 std::vector<std::string> subsequent_ufrags = | 2887 std::vector<std::string> subsequent_ufrags = |
2888 GetUfrags(pc_->local_description()); | 2888 GetUfrags(pc_->local_description()); |
2889 ASSERT_EQ(2, subsequent_ufrags.size()); | 2889 ASSERT_EQ(2, subsequent_ufrags.size()); |
2890 | 2890 |
2891 // Ensure that only the ufrag for the second m= section changed. | 2891 // Ensure that only the ufrag for the second m= section changed. |
2892 EXPECT_EQ(initial_ufrags[0], subsequent_ufrags[0]); | 2892 EXPECT_EQ(initial_ufrags[0], subsequent_ufrags[0]); |
2893 EXPECT_NE(initial_ufrags[1], subsequent_ufrags[1]); | 2893 EXPECT_NE(initial_ufrags[1], subsequent_ufrags[1]); |
2894 } | 2894 } |
2895 | 2895 |
| 2896 // Tests that the methods to return current/pending descriptions work as |
| 2897 // expected at different points in the offer/answer exchange. This test does |
| 2898 // one offer/answer exchange as the offerer, then another as the answerer. |
| 2899 TEST_F(PeerConnectionInterfaceTest, CurrentAndPendingDescriptions) { |
| 2900 // This disables DTLS so we can apply an answer to ourselves. |
| 2901 CreatePeerConnection(); |
| 2902 |
| 2903 // Create initial local offer and get SDP (which will also be used as |
| 2904 // answer/pranswer); |
| 2905 std::unique_ptr<SessionDescriptionInterface> offer; |
| 2906 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); |
| 2907 std::string sdp; |
| 2908 EXPECT_TRUE(offer->ToString(&sdp)); |
| 2909 |
| 2910 // Set local offer. |
| 2911 SessionDescriptionInterface* local_offer = offer.release(); |
| 2912 EXPECT_TRUE(DoSetLocalDescription(local_offer)); |
| 2913 EXPECT_EQ(local_offer, pc_->pending_local_description()); |
| 2914 EXPECT_EQ(nullptr, pc_->pending_remote_description()); |
| 2915 EXPECT_EQ(nullptr, pc_->current_local_description()); |
| 2916 EXPECT_EQ(nullptr, pc_->current_remote_description()); |
| 2917 |
| 2918 // Set remote pranswer. |
| 2919 SessionDescriptionInterface* remote_pranswer = |
| 2920 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, |
| 2921 sdp, nullptr); |
| 2922 EXPECT_TRUE(DoSetRemoteDescription(remote_pranswer)); |
| 2923 EXPECT_EQ(local_offer, pc_->pending_local_description()); |
| 2924 EXPECT_EQ(remote_pranswer, pc_->pending_remote_description()); |
| 2925 EXPECT_EQ(nullptr, pc_->current_local_description()); |
| 2926 EXPECT_EQ(nullptr, pc_->current_remote_description()); |
| 2927 |
| 2928 // Set remote answer. |
| 2929 SessionDescriptionInterface* remote_answer = webrtc::CreateSessionDescription( |
| 2930 SessionDescriptionInterface::kAnswer, sdp, nullptr); |
| 2931 EXPECT_TRUE(DoSetRemoteDescription(remote_answer)); |
| 2932 EXPECT_EQ(nullptr, pc_->pending_local_description()); |
| 2933 EXPECT_EQ(nullptr, pc_->pending_remote_description()); |
| 2934 EXPECT_EQ(local_offer, pc_->current_local_description()); |
| 2935 EXPECT_EQ(remote_answer, pc_->current_remote_description()); |
| 2936 |
| 2937 // Set remote offer. |
| 2938 SessionDescriptionInterface* remote_offer = webrtc::CreateSessionDescription( |
| 2939 SessionDescriptionInterface::kOffer, sdp, nullptr); |
| 2940 EXPECT_TRUE(DoSetRemoteDescription(remote_offer)); |
| 2941 EXPECT_EQ(remote_offer, pc_->pending_remote_description()); |
| 2942 EXPECT_EQ(nullptr, pc_->pending_local_description()); |
| 2943 EXPECT_EQ(local_offer, pc_->current_local_description()); |
| 2944 EXPECT_EQ(remote_answer, pc_->current_remote_description()); |
| 2945 |
| 2946 // Set local pranswer. |
| 2947 SessionDescriptionInterface* local_pranswer = |
| 2948 webrtc::CreateSessionDescription(SessionDescriptionInterface::kPrAnswer, |
| 2949 sdp, nullptr); |
| 2950 EXPECT_TRUE(DoSetLocalDescription(local_pranswer)); |
| 2951 EXPECT_EQ(remote_offer, pc_->pending_remote_description()); |
| 2952 EXPECT_EQ(local_pranswer, pc_->pending_local_description()); |
| 2953 EXPECT_EQ(local_offer, pc_->current_local_description()); |
| 2954 EXPECT_EQ(remote_answer, pc_->current_remote_description()); |
| 2955 |
| 2956 // Set local answer. |
| 2957 SessionDescriptionInterface* local_answer = webrtc::CreateSessionDescription( |
| 2958 SessionDescriptionInterface::kAnswer, sdp, nullptr); |
| 2959 EXPECT_TRUE(DoSetLocalDescription(local_answer)); |
| 2960 EXPECT_EQ(nullptr, pc_->pending_remote_description()); |
| 2961 EXPECT_EQ(nullptr, pc_->pending_local_description()); |
| 2962 EXPECT_EQ(remote_offer, pc_->current_remote_description()); |
| 2963 EXPECT_EQ(local_answer, pc_->current_local_description()); |
| 2964 } |
| 2965 |
2896 class PeerConnectionMediaConfigTest : public testing::Test { | 2966 class PeerConnectionMediaConfigTest : public testing::Test { |
2897 protected: | 2967 protected: |
2898 void SetUp() override { | 2968 void SetUp() override { |
2899 pcf_ = new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); | 2969 pcf_ = new rtc::RefCountedObject<PeerConnectionFactoryForTest>(); |
2900 pcf_->Initialize(); | 2970 pcf_->Initialize(); |
2901 } | 2971 } |
2902 const cricket::MediaConfig& TestCreatePeerConnection( | 2972 const cricket::MediaConfig& TestCreatePeerConnection( |
2903 const PeerConnectionInterface::RTCConfiguration& config, | 2973 const PeerConnectionInterface::RTCConfiguration& config, |
2904 const MediaConstraintsInterface *constraints) { | 2974 const MediaConstraintsInterface *constraints) { |
2905 pcf_->create_media_controller_called_ = false; | 2975 pcf_->create_media_controller_called_ = false; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3157 EXPECT_TRUE(updated_answer_options.has_video()); | 3227 EXPECT_TRUE(updated_answer_options.has_video()); |
3158 } | 3228 } |
3159 | 3229 |
3160 TEST(RtcErrorTest, OstreamOperator) { | 3230 TEST(RtcErrorTest, OstreamOperator) { |
3161 std::ostringstream oss; | 3231 std::ostringstream oss; |
3162 oss << webrtc::RtcError::NONE << ' ' | 3232 oss << webrtc::RtcError::NONE << ' ' |
3163 << webrtc::RtcError::INVALID_PARAMETER << ' ' | 3233 << webrtc::RtcError::INVALID_PARAMETER << ' ' |
3164 << webrtc::RtcError::INTERNAL_ERROR; | 3234 << webrtc::RtcError::INTERNAL_ERROR; |
3165 EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str()); | 3235 EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str()); |
3166 } | 3236 } |
OLD | NEW |