Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: net/http/http_network_layer_unittest.cc

Issue 384024: There was confusion in the mock socket classes due to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/base/mock_host_resolver.h" 5 #include "net/base/mock_host_resolver.h"
6 #include "net/base/ssl_config_service_defaults.h" 6 #include "net/base/ssl_config_service_defaults.h"
7 #include "net/http/http_network_layer.h" 7 #include "net/http/http_network_layer.h"
8 #include "net/http/http_transaction_unittest.h" 8 #include "net/http/http_transaction_unittest.h"
9 #include "net/proxy/proxy_service.h" 9 #include "net/proxy/proxy_service.h"
10 #include "net/socket/socket_test_util.h" 10 #include "net/socket/socket_test_util.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 net::MockRead("HTTP/1.0 200 OK\r\n\r\n"), 55 net::MockRead("HTTP/1.0 200 OK\r\n\r\n"),
56 net::MockRead("hello world"), 56 net::MockRead("hello world"),
57 net::MockRead(false, net::OK), 57 net::MockRead(false, net::OK),
58 }; 58 };
59 net::MockWrite data_writes[] = { 59 net::MockWrite data_writes[] = {
60 net::MockWrite("GET / HTTP/1.1\r\n" 60 net::MockWrite("GET / HTTP/1.1\r\n"
61 "Host: www.google.com\r\n" 61 "Host: www.google.com\r\n"
62 "Connection: keep-alive\r\n" 62 "Connection: keep-alive\r\n"
63 "User-Agent: Foo/1.0\r\n\r\n"), 63 "User-Agent: Foo/1.0\r\n\r\n"),
64 }; 64 };
65 net::StaticMockSocket data(data_reads, data_writes); 65 net::StaticSocketDataProvider data(data_reads, data_writes);
66 mock_socket_factory.AddMockSocket(&data); 66 mock_socket_factory.AddSocketDataProvider(&data);
67 67
68 net::HttpNetworkLayer factory(&mock_socket_factory, new net::MockHostResolver, 68 net::HttpNetworkLayer factory(&mock_socket_factory, new net::MockHostResolver,
69 net::ProxyService::CreateNull(), 69 net::ProxyService::CreateNull(),
70 new net::SSLConfigServiceDefaults); 70 new net::SSLConfigServiceDefaults);
71 71
72 TestCompletionCallback callback; 72 TestCompletionCallback callback;
73 73
74 scoped_ptr<net::HttpTransaction> trans; 74 scoped_ptr<net::HttpTransaction> trans;
75 int rv = factory.CreateTransaction(&trans); 75 int rv = factory.CreateTransaction(&trans);
76 EXPECT_EQ(net::OK, rv); 76 EXPECT_EQ(net::OK, rv);
77 77
78 net::HttpRequestInfo request_info; 78 net::HttpRequestInfo request_info;
79 request_info.url = GURL("http://www.google.com/"); 79 request_info.url = GURL("http://www.google.com/");
80 request_info.method = "GET"; 80 request_info.method = "GET";
81 request_info.user_agent = "Foo/1.0"; 81 request_info.user_agent = "Foo/1.0";
82 request_info.load_flags = net::LOAD_NORMAL; 82 request_info.load_flags = net::LOAD_NORMAL;
83 83
84 rv = trans->Start(&request_info, &callback, NULL); 84 rv = trans->Start(&request_info, &callback, NULL);
85 if (rv == net::ERR_IO_PENDING) 85 if (rv == net::ERR_IO_PENDING)
86 rv = callback.WaitForResult(); 86 rv = callback.WaitForResult();
87 ASSERT_EQ(net::OK, rv); 87 ASSERT_EQ(net::OK, rv);
88 88
89 std::string contents; 89 std::string contents;
90 rv = ReadTransaction(trans.get(), &contents); 90 rv = ReadTransaction(trans.get(), &contents);
91 EXPECT_EQ(net::OK, rv); 91 EXPECT_EQ(net::OK, rv);
92 EXPECT_EQ("hello world", contents); 92 EXPECT_EQ("hello world", contents);
93 } 93 }
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction_unittest.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698