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

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: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… 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
« no previous file with comments | « talk/media/sctp/sctpdataengine.cc ('k') | talk/media/webrtc/fakewebrtcvideoengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 bool writable_; 162 bool writable_;
163 }; 163 };
164 164
165 class SignalChannelClosedObserver : public sigslot::has_slots<> { 165 class SignalChannelClosedObserver : public sigslot::has_slots<> {
166 public: 166 public:
167 SignalChannelClosedObserver() {} 167 SignalChannelClosedObserver() {}
168 void BindSelf(cricket::SctpDataMediaChannel* channel) { 168 void BindSelf(cricket::SctpDataMediaChannel* channel) {
169 channel->SignalStreamClosedRemotely.connect( 169 channel->SignalStreamClosedRemotely.connect(
170 this, &SignalChannelClosedObserver::OnStreamClosed); 170 this, &SignalChannelClosedObserver::OnStreamClosed);
171 } 171 }
172 void OnStreamClosed(uint32 stream) { 172 void OnStreamClosed(uint32_t stream) { streams_.push_back(stream); }
173 streams_.push_back(stream);
174 }
175 173
176 int StreamCloseCount(uint32 stream) { 174 int StreamCloseCount(uint32_t stream) {
177 return std::count(streams_.begin(), streams_.end(), stream); 175 return std::count(streams_.begin(), streams_.end(), stream);
178 } 176 }
179 177
180 bool WasStreamClosed(uint32 stream) { 178 bool WasStreamClosed(uint32_t stream) {
181 return std::find(streams_.begin(), streams_.end(), stream) 179 return std::find(streams_.begin(), streams_.end(), stream)
182 != streams_.end(); 180 != streams_.end();
183 } 181 }
184 182
185 private: 183 private:
186 std::vector<uint32> streams_; 184 std::vector<uint32_t> streams_;
187 }; 185 };
188 186
189 class SignalChannelClosedReopener : public sigslot::has_slots<> { 187 class SignalChannelClosedReopener : public sigslot::has_slots<> {
190 public: 188 public:
191 SignalChannelClosedReopener(cricket::SctpDataMediaChannel* channel, 189 SignalChannelClosedReopener(cricket::SctpDataMediaChannel* channel,
192 cricket::SctpDataMediaChannel* peer) 190 cricket::SctpDataMediaChannel* peer)
193 : channel_(channel), peer_(peer) {} 191 : channel_(channel), peer_(peer) {}
194 192
195 void OnStreamClosed(int stream) { 193 void OnStreamClosed(int stream) {
196 cricket::StreamParams p(cricket::StreamParams::CreateLegacy(stream)); 194 cricket::StreamParams p(cricket::StreamParams::CreateLegacy(stream));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 cricket::SctpDataMediaChannel* channel = 283 cricket::SctpDataMediaChannel* channel =
286 static_cast<cricket::SctpDataMediaChannel*>(engine_->CreateChannel( 284 static_cast<cricket::SctpDataMediaChannel*>(engine_->CreateChannel(
287 cricket::DCT_SCTP)); 285 cricket::DCT_SCTP));
288 channel->SetInterface(net); 286 channel->SetInterface(net);
289 // When data is received, pass it to the SctpFakeDataReceiver. 287 // When data is received, pass it to the SctpFakeDataReceiver.
290 channel->SignalDataReceived.connect( 288 channel->SignalDataReceived.connect(
291 recv, &SctpFakeDataReceiver::OnDataReceived); 289 recv, &SctpFakeDataReceiver::OnDataReceived);
292 return channel; 290 return channel;
293 } 291 }
294 292
295 bool SendData(cricket::SctpDataMediaChannel* chan, uint32 ssrc, 293 bool SendData(cricket::SctpDataMediaChannel* chan,
294 uint32_t ssrc,
296 const std::string& msg, 295 const std::string& msg,
297 cricket::SendDataResult* result) { 296 cricket::SendDataResult* result) {
298 cricket::SendDataParams params; 297 cricket::SendDataParams params;
299 params.ssrc = ssrc; 298 params.ssrc = ssrc;
300 299
301 return chan->SendData(params, rtc::Buffer( 300 return chan->SendData(params, rtc::Buffer(
302 &msg[0], msg.length()), result); 301 &msg[0], msg.length()), result);
303 } 302 }
304 303
305 bool ReceivedData(const SctpFakeDataReceiver* recv, uint32 ssrc, 304 bool ReceivedData(const SctpFakeDataReceiver* recv,
306 const std::string& msg ) { 305 uint32_t ssrc,
306 const std::string& msg) {
307 return (recv->received() && 307 return (recv->received() &&
308 recv->last_params().ssrc == ssrc && 308 recv->last_params().ssrc == ssrc &&
309 recv->last_data() == msg); 309 recv->last_data() == msg);
310 } 310 }
311 311
312 bool ProcessMessagesUntilIdle() { 312 bool ProcessMessagesUntilIdle() {
313 rtc::Thread* thread = rtc::Thread::Current(); 313 rtc::Thread* thread = rtc::Thread::Current();
314 while (!thread->empty()) { 314 while (!thread->empty()) {
315 rtc::Message msg; 315 rtc::Message msg;
316 if (thread->Get(&msg, rtc::Thread::kForever)) { 316 if (thread->Get(&msg, rtc::Thread::kForever)) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // Channel 1 is gone now. 526 // Channel 1 is gone now.
527 527
528 // Create a new channel 1. 528 // Create a new channel 1.
529 AddStream(1); 529 AddStream(1);
530 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); 530 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result));
531 EXPECT_EQ(cricket::SDR_SUCCESS, result); 531 EXPECT_EQ(cricket::SDR_SUCCESS, result);
532 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); 532 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000);
533 channel1()->RemoveSendStream(1); 533 channel1()->RemoveSendStream(1);
534 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); 534 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000);
535 } 535 }
OLDNEW
« no previous file with comments | « talk/media/sctp/sctpdataengine.cc ('k') | talk/media/webrtc/fakewebrtcvideoengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698