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

Side by Side Diff: webrtc/api/test/fakedatachannelprovider.h

Issue 2622413005: Replace use of ASSERT in test code. (Closed)
Patch Set: Fixed another signed/unsigned comparison. Created 3 years, 11 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 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 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
11 #ifndef WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_ 11 #ifndef WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
12 #define WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_ 12 #define WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
13 13
14 #include "webrtc/api/datachannel.h" 14 #include "webrtc/api/datachannel.h"
15 #include "webrtc/base/checks.h"
15 16
16 class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { 17 class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
17 public: 18 public:
18 FakeDataChannelProvider() 19 FakeDataChannelProvider()
19 : send_blocked_(false), 20 : send_blocked_(false),
20 transport_available_(false), 21 transport_available_(false),
21 ready_to_send_(false), 22 ready_to_send_(false),
22 transport_error_(false) {} 23 transport_error_(false) {}
23 virtual ~FakeDataChannelProvider() {} 24 virtual ~FakeDataChannelProvider() {}
24 25
25 bool SendData(const cricket::SendDataParams& params, 26 bool SendData(const cricket::SendDataParams& params,
26 const rtc::CopyOnWriteBuffer& payload, 27 const rtc::CopyOnWriteBuffer& payload,
27 cricket::SendDataResult* result) override { 28 cricket::SendDataResult* result) override {
28 ASSERT(ready_to_send_ && transport_available_); 29 RTC_CHECK(ready_to_send_ && transport_available_);
29 if (send_blocked_) { 30 if (send_blocked_) {
30 *result = cricket::SDR_BLOCK; 31 *result = cricket::SDR_BLOCK;
31 return false; 32 return false;
32 } 33 }
33 34
34 if (transport_error_ || payload.size() == 0) { 35 if (transport_error_ || payload.size() == 0) {
35 *result = cricket::SDR_ERROR; 36 *result = cricket::SDR_ERROR;
36 return false; 37 return false;
37 } 38 }
38 39
39 last_send_data_params_ = params; 40 last_send_data_params_ = params;
40 return true; 41 return true;
41 } 42 }
42 43
43 bool ConnectDataChannel(webrtc::DataChannel* data_channel) override { 44 bool ConnectDataChannel(webrtc::DataChannel* data_channel) override {
44 ASSERT(connected_channels_.find(data_channel) == connected_channels_.end()); 45 RTC_CHECK(connected_channels_.find(data_channel) ==
46 connected_channels_.end());
45 if (!transport_available_) { 47 if (!transport_available_) {
46 return false; 48 return false;
47 } 49 }
48 LOG(LS_INFO) << "DataChannel connected " << data_channel; 50 LOG(LS_INFO) << "DataChannel connected " << data_channel;
49 connected_channels_.insert(data_channel); 51 connected_channels_.insert(data_channel);
50 return true; 52 return true;
51 } 53 }
52 54
53 void DisconnectDataChannel(webrtc::DataChannel* data_channel) override { 55 void DisconnectDataChannel(webrtc::DataChannel* data_channel) override {
54 ASSERT(connected_channels_.find(data_channel) != connected_channels_.end()); 56 RTC_CHECK(connected_channels_.find(data_channel) !=
57 connected_channels_.end());
55 LOG(LS_INFO) << "DataChannel disconnected " << data_channel; 58 LOG(LS_INFO) << "DataChannel disconnected " << data_channel;
56 connected_channels_.erase(data_channel); 59 connected_channels_.erase(data_channel);
57 } 60 }
58 61
59 void AddSctpDataStream(int sid) override { 62 void AddSctpDataStream(int sid) override {
60 ASSERT(sid >= 0); 63 RTC_CHECK(sid >= 0);
61 if (!transport_available_) { 64 if (!transport_available_) {
62 return; 65 return;
63 } 66 }
64 send_ssrcs_.insert(sid); 67 send_ssrcs_.insert(sid);
65 recv_ssrcs_.insert(sid); 68 recv_ssrcs_.insert(sid);
66 } 69 }
67 70
68 void RemoveSctpDataStream(int sid) override { 71 void RemoveSctpDataStream(int sid) override {
69 ASSERT(sid >= 0); 72 RTC_CHECK(sid >= 0);
70 send_ssrcs_.erase(sid); 73 send_ssrcs_.erase(sid);
71 recv_ssrcs_.erase(sid); 74 recv_ssrcs_.erase(sid);
72 } 75 }
73 76
74 bool ReadyToSendData() const override { return ready_to_send_; } 77 bool ReadyToSendData() const override { return ready_to_send_; }
75 78
76 // Set true to emulate the SCTP stream being blocked by congestion control. 79 // Set true to emulate the SCTP stream being blocked by congestion control.
77 void set_send_blocked(bool blocked) { 80 void set_send_blocked(bool blocked) {
78 send_blocked_ = blocked; 81 send_blocked_ = blocked;
79 if (!blocked) { 82 if (!blocked) {
(...skipping 12 matching lines...) Expand all
92 95
93 // Set true to emulate the transport channel creation, e.g. after 96 // Set true to emulate the transport channel creation, e.g. after
94 // setLocalDescription/setRemoteDescription called with data content. 97 // setLocalDescription/setRemoteDescription called with data content.
95 void set_transport_available(bool available) { 98 void set_transport_available(bool available) {
96 transport_available_ = available; 99 transport_available_ = available;
97 } 100 }
98 101
99 // Set true to emulate the transport ReadyToSendData signal when the transport 102 // Set true to emulate the transport ReadyToSendData signal when the transport
100 // becomes writable for the first time. 103 // becomes writable for the first time.
101 void set_ready_to_send(bool ready) { 104 void set_ready_to_send(bool ready) {
102 ASSERT(transport_available_); 105 RTC_CHECK(transport_available_);
103 ready_to_send_ = ready; 106 ready_to_send_ = ready;
104 if (ready) { 107 if (ready) {
105 std::set<webrtc::DataChannel*>::iterator it; 108 std::set<webrtc::DataChannel*>::iterator it;
106 for (it = connected_channels_.begin(); 109 for (it = connected_channels_.begin();
107 it != connected_channels_.end(); 110 it != connected_channels_.end();
108 ++it) { 111 ++it) {
109 (*it)->OnChannelReady(true); 112 (*it)->OnChannelReady(true);
110 } 113 }
111 } 114 }
112 } 115 }
(...skipping 22 matching lines...) Expand all
135 cricket::SendDataParams last_send_data_params_; 138 cricket::SendDataParams last_send_data_params_;
136 bool send_blocked_; 139 bool send_blocked_;
137 bool transport_available_; 140 bool transport_available_;
138 bool ready_to_send_; 141 bool ready_to_send_;
139 bool transport_error_; 142 bool transport_error_;
140 std::set<webrtc::DataChannel*> connected_channels_; 143 std::set<webrtc::DataChannel*> connected_channels_;
141 std::set<uint32_t> send_ssrcs_; 144 std::set<uint32_t> send_ssrcs_;
142 std::set<uint32_t> recv_ssrcs_; 145 std::set<uint32_t> recv_ssrcs_;
143 }; 146 };
144 #endif // WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_ 147 #endif // WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
OLDNEW
« no previous file with comments | « webrtc/api/test/fakeaudiocapturemodule.cc ('k') | webrtc/api/test/mockpeerconnectionobservers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698