| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 bool result() const { return result_; } | 67 bool result() const { return result_; } |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 bool called_; | 70 bool called_; |
| 71 bool result_; | 71 bool result_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class MockDataChannelObserver : public webrtc::DataChannelObserver { | 74 class MockDataChannelObserver : public webrtc::DataChannelObserver { |
| 75 public: | 75 public: |
| 76 explicit MockDataChannelObserver(webrtc::DataChannelInterface* channel) | 76 explicit MockDataChannelObserver(webrtc::DataChannelInterface* channel) |
| 77 : channel_(channel), received_message_count_(0) { | 77 : channel_(channel) { |
| 78 channel_->RegisterObserver(this); | 78 channel_->RegisterObserver(this); |
| 79 state_ = channel_->state(); | 79 state_ = channel_->state(); |
| 80 } | 80 } |
| 81 virtual ~MockDataChannelObserver() { | 81 virtual ~MockDataChannelObserver() { |
| 82 channel_->UnregisterObserver(); | 82 channel_->UnregisterObserver(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void OnBufferedAmountChange(uint64_t previous_amount) override {} | 85 void OnBufferedAmountChange(uint64_t previous_amount) override {} |
| 86 | 86 |
| 87 void OnStateChange() override { state_ = channel_->state(); } | 87 void OnStateChange() override { state_ = channel_->state(); } |
| 88 void OnMessage(const DataBuffer& buffer) override { | 88 void OnMessage(const DataBuffer& buffer) override { |
| 89 last_message_.assign(buffer.data.data<char>(), buffer.data.size()); | 89 messages_.push_back( |
| 90 ++received_message_count_; | 90 std::string(buffer.data.data<char>(), buffer.data.size())); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool IsOpen() const { return state_ == DataChannelInterface::kOpen; } | 93 bool IsOpen() const { return state_ == DataChannelInterface::kOpen; } |
| 94 const std::string& last_message() const { return last_message_; } | 94 std::vector<std::string> messages() const { return messages_; } |
| 95 size_t received_message_count() const { return received_message_count_; } | 95 std::string last_message() const { |
| 96 return messages_.empty() ? std::string() : messages_.back(); |
| 97 } |
| 98 size_t received_message_count() const { return messages_.size(); } |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 rtc::scoped_refptr<webrtc::DataChannelInterface> channel_; | 101 rtc::scoped_refptr<webrtc::DataChannelInterface> channel_; |
| 99 DataChannelInterface::DataState state_; | 102 DataChannelInterface::DataState state_; |
| 100 std::string last_message_; | 103 std::vector<std::string> messages_; |
| 101 size_t received_message_count_; | |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 class MockStatsObserver : public webrtc::StatsObserver { | 106 class MockStatsObserver : public webrtc::StatsObserver { |
| 105 public: | 107 public: |
| 106 MockStatsObserver() : called_(false), stats_() {} | 108 MockStatsObserver() : called_(false), stats_() {} |
| 107 virtual ~MockStatsObserver() {} | 109 virtual ~MockStatsObserver() {} |
| 108 | 110 |
| 109 virtual void OnComplete(const StatsReports& reports) { | 111 virtual void OnComplete(const StatsReports& reports) { |
| 110 ASSERT(!called_); | 112 ASSERT(!called_); |
| 111 called_ = true; | 113 called_ = true; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 int bytes_sent; | 220 int bytes_sent; |
| 219 int available_receive_bandwidth; | 221 int available_receive_bandwidth; |
| 220 std::string dtls_cipher; | 222 std::string dtls_cipher; |
| 221 std::string srtp_cipher; | 223 std::string srtp_cipher; |
| 222 } stats_; | 224 } stats_; |
| 223 }; | 225 }; |
| 224 | 226 |
| 225 } // namespace webrtc | 227 } // namespace webrtc |
| 226 | 228 |
| 227 #endif // WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ | 229 #endif // WEBRTC_API_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ |
| OLD | NEW |