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

Side by Side Diff: webrtc/p2p/base/transportcontroller_unittest.cc

Issue 2396513003: Restore thread name consistency for webrtc/p2p/ . (Closed)
Patch Set: Do not reuse terms 'network thread' or 'worker thread' for the test relayserver. Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 class TransportControllerTest : public testing::Test, 44 class TransportControllerTest : public testing::Test,
45 public sigslot::has_slots<> { 45 public sigslot::has_slots<> {
46 public: 46 public:
47 TransportControllerTest() 47 TransportControllerTest()
48 : transport_controller_(new TransportControllerForTest()), 48 : transport_controller_(new TransportControllerForTest()),
49 signaling_thread_(rtc::Thread::Current()) { 49 signaling_thread_(rtc::Thread::Current()) {
50 ConnectTransportControllerSignals(); 50 ConnectTransportControllerSignals();
51 } 51 }
52 52
53 void CreateTransportControllerWithWorkerThread() { 53 void CreateTransportControllerWithNetworkThread() {
54 if (!worker_thread_) { 54 if (!network_thread_) {
55 worker_thread_.reset(new rtc::Thread()); 55 network_thread_.reset(new rtc::Thread());
danilchap 2016/10/05 14:56:13 may be network_thread_ = rtc::Thread::CreateWithSo
johan 2016/10/05 16:13:24 Acknowledged.
56 worker_thread_->Start(); 56 network_thread_->Start();
57 } 57 }
58 transport_controller_.reset( 58 transport_controller_.reset(
59 new TransportControllerForTest(worker_thread_.get())); 59 new TransportControllerForTest(network_thread_.get()));
60 ConnectTransportControllerSignals(); 60 ConnectTransportControllerSignals();
61 } 61 }
62 62
63 void ConnectTransportControllerSignals() { 63 void ConnectTransportControllerSignals() {
64 transport_controller_->SignalConnectionState.connect( 64 transport_controller_->SignalConnectionState.connect(
65 this, &TransportControllerTest::OnConnectionState); 65 this, &TransportControllerTest::OnConnectionState);
66 transport_controller_->SignalReceiving.connect( 66 transport_controller_->SignalReceiving.connect(
67 this, &TransportControllerTest::OnReceiving); 67 this, &TransportControllerTest::OnReceiving);
68 transport_controller_->SignalGatheringState.connect( 68 transport_controller_->SignalGatheringState.connect(
69 this, &TransportControllerTest::OnGatheringState); 69 this, &TransportControllerTest::OnGatheringState);
(...skipping 15 matching lines...) Expand all
85 Candidate CreateCandidate(int component) { 85 Candidate CreateCandidate(int component) {
86 Candidate c; 86 Candidate c;
87 c.set_address(rtc::SocketAddress("192.168.1.1", 8000)); 87 c.set_address(rtc::SocketAddress("192.168.1.1", 8000));
88 c.set_component(1); 88 c.set_component(1);
89 c.set_protocol(UDP_PROTOCOL_NAME); 89 c.set_protocol(UDP_PROTOCOL_NAME);
90 c.set_priority(1); 90 c.set_priority(1);
91 return c; 91 return c;
92 } 92 }
93 93
94 // Used for thread hopping test. 94 // Used for thread hopping test.
95 void CreateChannelsAndCompleteConnectionOnWorkerThread() { 95 void CreateChannelsAndCompleteConnectionOnNetworkThread() {
96 worker_thread_->Invoke<void>( 96 network_thread_->Invoke<void>(
97 RTC_FROM_HERE, 97 RTC_FROM_HERE,
98 rtc::Bind( 98 rtc::Bind(
99 &TransportControllerTest::CreateChannelsAndCompleteConnection_w, 99 &TransportControllerTest::CreateChannelsAndCompleteConnection_w,
100 this)); 100 this));
101 } 101 }
102 102
103 void CreateChannelsAndCompleteConnection_w() { 103 void CreateChannelsAndCompleteConnection_w() {
104 transport_controller_->SetIceRole(ICEROLE_CONTROLLING); 104 transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
105 FakeTransportChannel* channel1 = CreateChannel("audio", 1); 105 FakeTransportChannel* channel1 = CreateChannel("audio", 1);
106 ASSERT_NE(nullptr, channel1); 106 ASSERT_NE(nullptr, channel1);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void OnCandidatesGathered(const std::string& transport_name, 167 void OnCandidatesGathered(const std::string& transport_name,
168 const Candidates& candidates) { 168 const Candidates& candidates) {
169 if (!signaling_thread_->IsCurrent()) { 169 if (!signaling_thread_->IsCurrent()) {
170 signaled_on_non_signaling_thread_ = true; 170 signaled_on_non_signaling_thread_ = true;
171 } 171 }
172 candidates_[transport_name].insert(candidates_[transport_name].end(), 172 candidates_[transport_name].insert(candidates_[transport_name].end(),
173 candidates.begin(), candidates.end()); 173 candidates.begin(), candidates.end());
174 ++candidates_signal_count_; 174 ++candidates_signal_count_;
175 } 175 }
176 176
177 std::unique_ptr<rtc::Thread> worker_thread_; // Not used for most tests. 177 std::unique_ptr<rtc::Thread> network_thread_; // Not used for most tests.
178 std::unique_ptr<TransportControllerForTest> transport_controller_; 178 std::unique_ptr<TransportControllerForTest> transport_controller_;
179 179
180 // Information received from signals from transport controller. 180 // Information received from signals from transport controller.
181 IceConnectionState connection_state_ = kIceConnectionConnecting; 181 IceConnectionState connection_state_ = kIceConnectionConnecting;
182 bool receiving_ = false; 182 bool receiving_ = false;
183 IceGatheringState gathering_state_ = kIceGatheringNew; 183 IceGatheringState gathering_state_ = kIceGatheringNew;
184 // transport_name => candidates 184 // transport_name => candidates
185 std::map<std::string, Candidates> candidates_; 185 std::map<std::string, Candidates> candidates_;
186 // Counts of each signal emitted. 186 // Counts of each signal emitted.
187 int connection_state_signal_count_ = 0; 187 int connection_state_signal_count_ = 0;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 EXPECT_TRUE(transport_controller_->SetLocalTransportDescription( 655 EXPECT_TRUE(transport_controller_->SetLocalTransportDescription(
656 "audio", local_desc, CA_OFFER, &err)); 656 "audio", local_desc, CA_OFFER, &err));
657 transport_controller_->MaybeStartGathering(); 657 transport_controller_->MaybeStartGathering();
658 658
659 channel->SignalCandidateGathered(channel, CreateCandidate(1)); 659 channel->SignalCandidateGathered(channel, CreateCandidate(1));
660 EXPECT_EQ_WAIT(1, candidates_signal_count_, kTimeout); 660 EXPECT_EQ_WAIT(1, candidates_signal_count_, kTimeout);
661 EXPECT_EQ(1U, candidates_["audio"].size()); 661 EXPECT_EQ(1U, candidates_["audio"].size());
662 } 662 }
663 663
664 TEST_F(TransportControllerTest, TestSignalingOccursOnSignalingThread) { 664 TEST_F(TransportControllerTest, TestSignalingOccursOnSignalingThread) {
665 CreateTransportControllerWithWorkerThread(); 665 CreateTransportControllerWithNetworkThread();
666 CreateChannelsAndCompleteConnectionOnWorkerThread(); 666 CreateChannelsAndCompleteConnectionOnNetworkThread();
667 667
668 // connecting --> connected --> completed 668 // connecting --> connected --> completed
669 EXPECT_EQ_WAIT(kIceConnectionCompleted, connection_state_, kTimeout); 669 EXPECT_EQ_WAIT(kIceConnectionCompleted, connection_state_, kTimeout);
670 EXPECT_EQ(2, connection_state_signal_count_); 670 EXPECT_EQ(2, connection_state_signal_count_);
671 671
672 EXPECT_TRUE_WAIT(receiving_, kTimeout); 672 EXPECT_TRUE_WAIT(receiving_, kTimeout);
673 EXPECT_EQ(1, receiving_signal_count_); 673 EXPECT_EQ(1, receiving_signal_count_);
674 674
675 // new --> gathering --> complete 675 // new --> gathering --> complete
676 EXPECT_EQ_WAIT(kIceGatheringComplete, gathering_state_, kTimeout); 676 EXPECT_EQ_WAIT(kIceGatheringComplete, gathering_state_, kTimeout);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 // The endpoint that initiated an ICE restart should keep the existing role. 743 // The endpoint that initiated an ICE restart should keep the existing role.
744 TransportDescription ice_restart_desc(std::vector<std::string>(), kIceUfrag3, 744 TransportDescription ice_restart_desc(std::vector<std::string>(), kIceUfrag3,
745 kIcePwd3, ICEMODE_FULL, 745 kIcePwd3, ICEMODE_FULL,
746 CONNECTIONROLE_ACTPASS, nullptr); 746 CONNECTIONROLE_ACTPASS, nullptr);
747 EXPECT_TRUE(transport_controller_->SetLocalTransportDescription( 747 EXPECT_TRUE(transport_controller_->SetLocalTransportDescription(
748 "audio", ice_restart_desc, CA_OFFER, &err)); 748 "audio", ice_restart_desc, CA_OFFER, &err));
749 EXPECT_EQ(ICEROLE_CONTROLLED, channel->GetIceRole()); 749 EXPECT_EQ(ICEROLE_CONTROLLED, channel->GetIceRole());
750 } 750 }
751 751
752 } // namespace cricket { 752 } // namespace cricket {
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698