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

Side by Side Diff: talk/media/sctp/sctpdataengine_unittest.cc

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 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 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 bool writable_; 167 bool writable_;
168 }; 168 };
169 169
170 class SignalChannelClosedObserver : public sigslot::has_slots<> { 170 class SignalChannelClosedObserver : public sigslot::has_slots<> {
171 public: 171 public:
172 SignalChannelClosedObserver() {} 172 SignalChannelClosedObserver() {}
173 void BindSelf(cricket::SctpDataMediaChannel* channel) { 173 void BindSelf(cricket::SctpDataMediaChannel* channel) {
174 channel->SignalStreamClosedRemotely.connect( 174 channel->SignalStreamClosedRemotely.connect(
175 this, &SignalChannelClosedObserver::OnStreamClosed); 175 this, &SignalChannelClosedObserver::OnStreamClosed);
176 } 176 }
177 void OnStreamClosed(uint32 stream) { 177 void OnStreamClosed(uint32_t stream) { streams_.push_back(stream); }
178 streams_.push_back(stream);
179 }
180 178
181 int StreamCloseCount(uint32 stream) { 179 int StreamCloseCount(uint32_t stream) {
182 return std::count(streams_.begin(), streams_.end(), stream); 180 return std::count(streams_.begin(), streams_.end(), stream);
183 } 181 }
184 182
185 bool WasStreamClosed(uint32 stream) { 183 bool WasStreamClosed(uint32_t stream) {
186 return std::find(streams_.begin(), streams_.end(), stream) 184 return std::find(streams_.begin(), streams_.end(), stream)
187 != streams_.end(); 185 != streams_.end();
188 } 186 }
189 187
190 private: 188 private:
191 std::vector<uint32> streams_; 189 std::vector<uint32_t> streams_;
192 }; 190 };
193 191
194 class SignalChannelClosedReopener : public sigslot::has_slots<> { 192 class SignalChannelClosedReopener : public sigslot::has_slots<> {
195 public: 193 public:
196 SignalChannelClosedReopener(cricket::SctpDataMediaChannel* channel, 194 SignalChannelClosedReopener(cricket::SctpDataMediaChannel* channel,
197 cricket::SctpDataMediaChannel* peer) 195 cricket::SctpDataMediaChannel* peer)
198 : channel_(channel), peer_(peer) {} 196 : channel_(channel), peer_(peer) {}
199 197
200 void OnStreamClosed(int stream) { 198 void OnStreamClosed(int stream) {
201 cricket::StreamParams p(cricket::StreamParams::CreateLegacy(stream)); 199 cricket::StreamParams p(cricket::StreamParams::CreateLegacy(stream));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 cricket::SctpDataMediaChannel* channel = 294 cricket::SctpDataMediaChannel* channel =
297 static_cast<cricket::SctpDataMediaChannel*>(engine_->CreateChannel( 295 static_cast<cricket::SctpDataMediaChannel*>(engine_->CreateChannel(
298 cricket::DCT_SCTP)); 296 cricket::DCT_SCTP));
299 channel->SetInterface(net); 297 channel->SetInterface(net);
300 // When data is received, pass it to the SctpFakeDataReceiver. 298 // When data is received, pass it to the SctpFakeDataReceiver.
301 channel->SignalDataReceived.connect( 299 channel->SignalDataReceived.connect(
302 recv, &SctpFakeDataReceiver::OnDataReceived); 300 recv, &SctpFakeDataReceiver::OnDataReceived);
303 return channel; 301 return channel;
304 } 302 }
305 303
306 bool SendData(cricket::SctpDataMediaChannel* chan, uint32 ssrc, 304 bool SendData(cricket::SctpDataMediaChannel* chan,
305 uint32_t ssrc,
307 const std::string& msg, 306 const std::string& msg,
308 cricket::SendDataResult* result) { 307 cricket::SendDataResult* result) {
309 cricket::SendDataParams params; 308 cricket::SendDataParams params;
310 params.ssrc = ssrc; 309 params.ssrc = ssrc;
311 310
312 return chan->SendData(params, rtc::Buffer( 311 return chan->SendData(params, rtc::Buffer(
313 &msg[0], msg.length()), result); 312 &msg[0], msg.length()), result);
314 } 313 }
315 314
316 bool ReceivedData(const SctpFakeDataReceiver* recv, uint32 ssrc, 315 bool ReceivedData(const SctpFakeDataReceiver* recv,
317 const std::string& msg ) { 316 uint32_t ssrc,
317 const std::string& msg) {
318 return (recv->received() && 318 return (recv->received() &&
319 recv->last_params().ssrc == ssrc && 319 recv->last_params().ssrc == ssrc &&
320 recv->last_data() == msg); 320 recv->last_data() == msg);
321 } 321 }
322 322
323 bool ProcessMessagesUntilIdle() { 323 bool ProcessMessagesUntilIdle() {
324 rtc::Thread* thread = rtc::Thread::Current(); 324 rtc::Thread* thread = rtc::Thread::Current();
325 while (!thread->empty()) { 325 while (!thread->empty()) {
326 rtc::Message msg; 326 rtc::Message msg;
327 if (thread->Get(&msg, rtc::Thread::kForever)) { 327 if (thread->Get(&msg, rtc::Thread::kForever)) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Channel 1 is gone now. 537 // Channel 1 is gone now.
538 538
539 // Create a new channel 1. 539 // Create a new channel 1.
540 AddStream(1); 540 AddStream(1);
541 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); 541 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result));
542 EXPECT_EQ(cricket::SDR_SUCCESS, result); 542 EXPECT_EQ(cricket::SDR_SUCCESS, result);
543 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); 543 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000);
544 channel1()->RemoveSendStream(1); 544 channel1()->RemoveSendStream(1);
545 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); 545 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000);
546 } 546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698