| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "net/base/mock_host_resolver.h" | 8 #include "net/base/mock_host_resolver.h" |
| 9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
| 10 #include "net/socket/socket_test_util.h" | 10 #include "net/socket/socket_test_util.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 MockWrite data_writes1[] = { | 151 MockWrite data_writes1[] = { |
| 152 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" | 152 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" |
| 153 "Host: example.com\r\n" | 153 "Host: example.com\r\n" |
| 154 "Proxy-Connection: keep-alive\r\n\r\n"), | 154 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 155 }; | 155 }; |
| 156 MockRead data_reads1[] = { | 156 MockRead data_reads1[] = { |
| 157 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 157 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 158 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 158 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 159 MockRead("\r\n"), | 159 MockRead("\r\n"), |
| 160 }; | 160 }; |
| 161 StaticMockSocket data1(data_reads1, data_writes1); | 161 StaticSocketDataProvider data1(data_reads1, data_writes1); |
| 162 mock_socket_factory.AddMockSocket(&data1); | 162 mock_socket_factory.AddSocketDataProvider(&data1); |
| 163 | 163 |
| 164 MockWrite data_writes2[] = { | 164 MockWrite data_writes2[] = { |
| 165 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" | 165 MockWrite("CONNECT example.com:80 HTTP/1.1\r\n" |
| 166 "Host: example.com\r\n" | 166 "Host: example.com\r\n" |
| 167 "Proxy-Connection: keep-alive\r\n" | 167 "Proxy-Connection: keep-alive\r\n" |
| 168 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 168 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
| 169 }; | 169 }; |
| 170 MockRead data_reads2[] = { | 170 MockRead data_reads2[] = { |
| 171 MockRead("HTTP/1.1 200 Connection Established\r\n"), | 171 MockRead("HTTP/1.1 200 Connection Established\r\n"), |
| 172 MockRead("Proxy-agent: Apache/2.2.8\r\n"), | 172 MockRead("Proxy-agent: Apache/2.2.8\r\n"), |
| 173 MockRead("\r\n"), | 173 MockRead("\r\n"), |
| 174 }; | 174 }; |
| 175 StaticMockSocket data2(data_reads2, data_writes2); | 175 StaticSocketDataProvider data2(data_reads2, data_writes2); |
| 176 mock_socket_factory.AddMockSocket(&data2); | 176 mock_socket_factory.AddSocketDataProvider(&data2); |
| 177 | 177 |
| 178 TestCompletionCallback callback; | 178 TestCompletionCallback callback; |
| 179 | 179 |
| 180 scoped_ptr<SocketStreamEventRecorder> delegate( | 180 scoped_ptr<SocketStreamEventRecorder> delegate( |
| 181 new SocketStreamEventRecorder(&callback)); | 181 new SocketStreamEventRecorder(&callback)); |
| 182 delegate->SetOnConnected(NewCallback(delegate.get(), | 182 delegate->SetOnConnected(NewCallback(delegate.get(), |
| 183 &SocketStreamEventRecorder::DoClose)); | 183 &SocketStreamEventRecorder::DoClose)); |
| 184 const std::wstring kUsername = L"foo"; | 184 const std::wstring kUsername = L"foo"; |
| 185 const std::wstring kPassword = L"bar"; | 185 const std::wstring kPassword = L"bar"; |
| 186 delegate->SetAuthInfo(kUsername, kPassword); | 186 delegate->SetAuthInfo(kUsername, kPassword); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 201 | 201 |
| 202 const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents(); | 202 const std::vector<SocketStreamEvent>& events = delegate->GetSeenEvents(); |
| 203 EXPECT_EQ(3U, events.size()); | 203 EXPECT_EQ(3U, events.size()); |
| 204 | 204 |
| 205 EXPECT_EQ(SocketStreamEvent::EVENT_AUTH_REQUIRED, events[0].event_type); | 205 EXPECT_EQ(SocketStreamEvent::EVENT_AUTH_REQUIRED, events[0].event_type); |
| 206 EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type); | 206 EXPECT_EQ(SocketStreamEvent::EVENT_CONNECTED, events[1].event_type); |
| 207 EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type); | 207 EXPECT_EQ(SocketStreamEvent::EVENT_CLOSE, events[2].event_type); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace net | 210 } // namespace net |
| OLD | NEW |