Index: webrtc/api/datachannel_unittest.cc |
diff --git a/webrtc/api/datachannel_unittest.cc b/webrtc/api/datachannel_unittest.cc |
index 773e7523e6c7e8be85c6abd81f9c3a95df052a7b..a8c8361cb1e1295d8aaa4905059d365a15dfa2e2 100644 |
--- a/webrtc/api/datachannel_unittest.cc |
+++ b/webrtc/api/datachannel_unittest.cc |
@@ -94,6 +94,24 @@ class SctpDataChannelTest : public testing::Test { |
rtc::scoped_refptr<DataChannel> webrtc_data_channel_; |
}; |
+class StateSignalsListener : public sigslot::has_slots<> { |
+ public: |
+ int opened_count() const { return opened_count_; } |
+ int closed_count() const { return closed_count_; } |
+ |
+ void OnSignalOpened(DataChannel* data_channel) { |
+ ++opened_count_; |
+ } |
+ |
+ void OnSignalClosed(DataChannel* data_channel) { |
+ ++closed_count_; |
+ } |
+ |
+ private: |
+ int opened_count_ = 0; |
+ int closed_count_ = 0; |
+}; |
+ |
// Verifies that the data channel is connected to the transport after creation. |
TEST_F(SctpDataChannelTest, ConnectedToTransportOnCreated) { |
provider_->set_transport_available(true); |
@@ -122,14 +140,25 @@ TEST_F(SctpDataChannelTest, ConnectedAfterTransportBecomesAvailable) { |
// Tests the state of the data channel. |
TEST_F(SctpDataChannelTest, StateTransition) { |
+ StateSignalsListener state_signals_listener; |
+ webrtc_data_channel_->SignalOpened.connect( |
+ &state_signals_listener, &StateSignalsListener::OnSignalOpened); |
+ webrtc_data_channel_->SignalClosed.connect( |
+ &state_signals_listener, &StateSignalsListener::OnSignalClosed); |
EXPECT_EQ(webrtc::DataChannelInterface::kConnecting, |
webrtc_data_channel_->state()); |
+ EXPECT_EQ(state_signals_listener.opened_count(), 0); |
+ EXPECT_EQ(state_signals_listener.closed_count(), 0); |
SetChannelReady(); |
EXPECT_EQ(webrtc::DataChannelInterface::kOpen, webrtc_data_channel_->state()); |
+ EXPECT_EQ(state_signals_listener.opened_count(), 1); |
+ EXPECT_EQ(state_signals_listener.closed_count(), 0); |
webrtc_data_channel_->Close(); |
EXPECT_EQ(webrtc::DataChannelInterface::kClosed, |
webrtc_data_channel_->state()); |
+ EXPECT_EQ(state_signals_listener.opened_count(), 1); |
+ EXPECT_EQ(state_signals_listener.closed_count(), 1); |
// Verifies that it's disconnected from the transport. |
EXPECT_FALSE(provider_->IsConnected(webrtc_data_channel_.get())); |
} |