summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 09:14:24 +0000
committertyoshino@chromium.org <tyoshino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 09:14:24 +0000
commit0b4e575a9749594defb699b866a236f11d9a5e0f (patch)
tree50c1a5745070c0f63926285e0f090de1bae8963c
parent013552fb96899b2d07d4221590196606b9798b67 (diff)
downloadchromium_src-0b4e575a9749594defb699b866a236f11d9a5e0f.zip
chromium_src-0b4e575a9749594defb699b866a236f11d9a5e0f.tar.gz
chromium_src-0b4e575a9749594defb699b866a236f11d9a5e0f.tar.bz2
Test that SocketStream is closed correctly on resolve failure.
Review URL: https://chromiumcodereview.appspot.com/16424003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204777 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/socket_stream/socket_stream_unittest.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/net/socket_stream/socket_stream_unittest.cc b/net/socket_stream/socket_stream_unittest.cc
index aed80f2..7f3c5f1 100644
--- a/net/socket_stream/socket_stream_unittest.cc
+++ b/net/socket_stream/socket_stream_unittest.cc
@@ -416,6 +416,41 @@ TEST_F(SocketStreamTest, CloseFlushPendingWrite) {
EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[6].event_type);
}
+TEST_F(SocketStreamTest, ResolveFailure) {
+ TestCompletionCallback test_callback;
+
+ scoped_ptr<SocketStreamEventRecorder> delegate(
+ new SocketStreamEventRecorder(test_callback.callback()));
+
+ scoped_refptr<SocketStream> socket_stream(
+ new SocketStream(GURL("ws://example.com/demo"), delegate.get()));
+
+ // Make resolver fail.
+ TestURLRequestContext context;
+ scoped_ptr<MockHostResolver> mock_host_resolver(
+ new MockHostResolver());
+ mock_host_resolver->rules()->AddSimulatedFailure("example.com");
+ context.set_host_resolver(mock_host_resolver.get());
+ socket_stream->set_context(&context);
+
+ // No read/write on socket is expected.
+ StaticSocketDataProvider data_provider(NULL, 0, NULL, 0);
+ MockClientSocketFactory* mock_socket_factory =
+ GetMockClientSocketFactory();
+ mock_socket_factory->AddSocketDataProvider(&data_provider);
+ socket_stream->SetClientSocketFactory(mock_socket_factory);
+
+ socket_stream->Connect();
+
+ test_callback.WaitForResult();
+
+ const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents();
+ ASSERT_EQ(2U, events.size());
+
+ EXPECT_EQ(SocketStreamEvent::EVENT_ERROR, events[0].event_type);
+ EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[1].event_type);
+}
+
TEST_F(SocketStreamTest, ExceedMaxPendingSendAllowed) {
TestCompletionCallback test_callback;