OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // Verifies that IceCredentialsChanged returns true when either ufrag or pwd | 67 // Verifies that IceCredentialsChanged returns true when either ufrag or pwd |
68 // changed, and false in other cases. | 68 // changed, and false in other cases. |
69 TEST_F(JsepTransportTest, TestIceCredentialsChanged) { | 69 TEST_F(JsepTransportTest, TestIceCredentialsChanged) { |
70 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p2")); | 70 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p2")); |
71 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p1")); | 71 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u2", "p1")); |
72 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p2")); | 72 EXPECT_TRUE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p2")); |
73 EXPECT_FALSE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p1")); | 73 EXPECT_FALSE(cricket::IceCredentialsChanged("u1", "p1", "u1", "p1")); |
74 } | 74 } |
75 | 75 |
| 76 // Tests SetNeedsIceRestartFlag and NeedsIceRestart, ensuring NeedsIceRestart |
| 77 // only starts returning "false" once an ICE restart has been initiated. |
| 78 TEST_F(JsepTransportTest, NeedsIceRestart) { |
| 79 // Do initial offer/answer so there's something to restart. |
| 80 cricket::TransportDescription local_desc(kIceUfrag1, kIcePwd1); |
| 81 cricket::TransportDescription remote_desc(kIceUfrag1, kIcePwd1); |
| 82 ASSERT_TRUE(transport_->SetLocalTransportDescription( |
| 83 local_desc, cricket::CA_OFFER, nullptr)); |
| 84 ASSERT_TRUE(transport_->SetRemoteTransportDescription( |
| 85 remote_desc, cricket::CA_ANSWER, nullptr)); |
| 86 |
| 87 // Flag initially should be false. |
| 88 EXPECT_FALSE(transport_->NeedsIceRestart()); |
| 89 |
| 90 // After setting flag, it should be true. |
| 91 transport_->SetNeedsIceRestartFlag(); |
| 92 EXPECT_TRUE(transport_->NeedsIceRestart()); |
| 93 |
| 94 // Doing an identical offer/answer shouldn't clear the flag. |
| 95 ASSERT_TRUE(transport_->SetLocalTransportDescription( |
| 96 local_desc, cricket::CA_OFFER, nullptr)); |
| 97 ASSERT_TRUE(transport_->SetRemoteTransportDescription( |
| 98 remote_desc, cricket::CA_ANSWER, nullptr)); |
| 99 EXPECT_TRUE(transport_->NeedsIceRestart()); |
| 100 |
| 101 // Doing an offer/answer that restarts ICE should clear the flag. |
| 102 cricket::TransportDescription ice_restart_local_desc(kIceUfrag2, kIcePwd2); |
| 103 cricket::TransportDescription ice_restart_remote_desc(kIceUfrag2, kIcePwd2); |
| 104 ASSERT_TRUE(transport_->SetLocalTransportDescription( |
| 105 ice_restart_local_desc, cricket::CA_OFFER, nullptr)); |
| 106 ASSERT_TRUE(transport_->SetRemoteTransportDescription( |
| 107 ice_restart_remote_desc, cricket::CA_ANSWER, nullptr)); |
| 108 EXPECT_FALSE(transport_->NeedsIceRestart()); |
| 109 } |
| 110 |
76 TEST_F(JsepTransportTest, TestGetStats) { | 111 TEST_F(JsepTransportTest, TestGetStats) { |
77 EXPECT_TRUE(SetupChannel()); | 112 EXPECT_TRUE(SetupChannel()); |
78 cricket::TransportStats stats; | 113 cricket::TransportStats stats; |
79 EXPECT_TRUE(transport_->GetStats(&stats)); | 114 EXPECT_TRUE(transport_->GetStats(&stats)); |
80 // Note that this tests the behavior of a FakeTransportChannel. | 115 // Note that this tests the behavior of a FakeTransportChannel. |
81 ASSERT_EQ(1U, stats.channel_stats.size()); | 116 ASSERT_EQ(1U, stats.channel_stats.size()); |
82 EXPECT_EQ(1, stats.channel_stats[0].component); | 117 EXPECT_EQ(1, stats.channel_stats[0].component); |
83 // Set local transport description for FakeTransport before connecting. | 118 // Set local transport description for FakeTransport before connecting. |
84 TransportDescription faketransport_desc( | 119 TransportDescription faketransport_desc( |
85 std::vector<std::string>(), | 120 std::vector<std::string>(), |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 remote_desc.connection_role = param.remote_role; | 298 remote_desc.connection_role = param.remote_role; |
264 | 299 |
265 ASSERT_TRUE(transport_->SetRemoteTransportDescription( | 300 ASSERT_TRUE(transport_->SetRemoteTransportDescription( |
266 remote_desc, param.remote_action, nullptr)); | 301 remote_desc, param.remote_action, nullptr)); |
267 ASSERT_TRUE(transport_->SetLocalTransportDescription( | 302 ASSERT_TRUE(transport_->SetLocalTransportDescription( |
268 local_desc, param.local_action, nullptr)); | 303 local_desc, param.local_action, nullptr)); |
269 EXPECT_FALSE( | 304 EXPECT_FALSE( |
270 transport_->NegotiateRole(param.local_action, &ssl_role, &error_desc)); | 305 transport_->NegotiateRole(param.local_action, &ssl_role, &error_desc)); |
271 } | 306 } |
272 } | 307 } |
OLD | NEW |