Fix assertion failure when closing data channel, and add a unit test.

BUG=4066
R=jiayl@webrtc.org, juberti@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/31109004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7816 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/app/webrtc/datachannel_unittest.cc b/talk/app/webrtc/datachannel_unittest.cc
index 84a6935..82f5dc9 100644
--- a/talk/app/webrtc/datachannel_unittest.cc
+++ b/talk/app/webrtc/datachannel_unittest.cc
@@ -423,3 +423,10 @@
   EXPECT_EQ(webrtc::DataChannelInterface::kOpen,
             webrtc_data_channel_->state());
 }
+
+// Tests that a channel can be closed without being opened or assigned an sid.
+TEST_F(SctpDataChannelTest, NeverOpened) {
+  provider_.set_transport_available(true);
+  webrtc_data_channel_->OnTransportChannelCreated();
+  webrtc_data_channel_->Close();
+}