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

Side by Side Diff: net/ftp/ftp_network_transaction_unittest.cc

Issue 6488010: Propagate the remote socket address to URLRequest and to ViewHostMsg_FrameNavigate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address eroman's comments Created 9 years, 10 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "net/base/host_port_pair.h"
12 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
13 #include "net/base/mock_host_resolver.h" 14 #include "net/base/mock_host_resolver.h"
14 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
15 #include "net/base/sys_addrinfo.h" 16 #include "net/base/sys_addrinfo.h"
16 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
17 #include "net/ftp/ftp_network_session.h" 18 #include "net/ftp/ftp_network_session.h"
18 #include "net/ftp/ftp_request_info.h" 19 #include "net/ftp/ftp_request_info.h"
19 #include "net/socket/socket_test_util.h" 20 #include "net/socket/socket_test_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "testing/platform_test.h" 22 #include "testing/platform_test.h"
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 FtpSocketDataProvider::PRE_QUIT); 825 FtpSocketDataProvider::PRE_QUIT);
825 ExecuteTransaction(&ctrl_socket, "ftp://[::1]/file", ERR_INVALID_RESPONSE); 826 ExecuteTransaction(&ctrl_socket, "ftp://[::1]/file", ERR_INVALID_RESPONSE);
826 } 827 }
827 828
828 TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) { 829 TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) {
829 FtpSocketDataProviderDirectoryListing ctrl_socket; 830 FtpSocketDataProviderDirectoryListing ctrl_socket;
830 ExecuteTransaction(&ctrl_socket, "ftp://host", OK); 831 ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
831 832
832 EXPECT_TRUE(transaction_.GetResponseInfo()->is_directory_listing); 833 EXPECT_TRUE(transaction_.GetResponseInfo()->is_directory_listing);
833 EXPECT_EQ(-1, transaction_.GetResponseInfo()->expected_content_size); 834 EXPECT_EQ(-1, transaction_.GetResponseInfo()->expected_content_size);
835 EXPECT_EQ("192.0.2.33",
836 transaction_.GetResponseInfo()->socket_address.host());
837 EXPECT_EQ(0, transaction_.GetResponseInfo()->socket_address.port());
834 } 838 }
835 839
836 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionWithPasvFallback) { 840 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionWithPasvFallback) {
837 FtpSocketDataProviderDirectoryListingWithPasvFallback ctrl_socket; 841 FtpSocketDataProviderDirectoryListingWithPasvFallback ctrl_socket;
838 ExecuteTransaction(&ctrl_socket, "ftp://host", OK); 842 ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
839 843
840 EXPECT_TRUE(transaction_.GetResponseInfo()->is_directory_listing); 844 EXPECT_TRUE(transaction_.GetResponseInfo()->is_directory_listing);
841 EXPECT_EQ(-1, transaction_.GetResponseInfo()->expected_content_size); 845 EXPECT_EQ(-1, transaction_.GetResponseInfo()->expected_content_size);
842 } 846 }
843 847
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 FtpSocketDataProviderDirectoryListingTransferStarting ctrl_socket; 901 FtpSocketDataProviderDirectoryListingTransferStarting ctrl_socket;
898 ExecuteTransaction(&ctrl_socket, "ftp://host", OK); 902 ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
899 } 903 }
900 904
901 TEST_F(FtpNetworkTransactionTest, DownloadTransaction) { 905 TEST_F(FtpNetworkTransactionTest, DownloadTransaction) {
902 FtpSocketDataProviderFileDownload ctrl_socket; 906 FtpSocketDataProviderFileDownload ctrl_socket;
903 ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK); 907 ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK);
904 908
905 // We pass an artificial value of 18 as a response to the SIZE command. 909 // We pass an artificial value of 18 as a response to the SIZE command.
906 EXPECT_EQ(18, transaction_.GetResponseInfo()->expected_content_size); 910 EXPECT_EQ(18, transaction_.GetResponseInfo()->expected_content_size);
911 EXPECT_EQ("192.0.2.33",
912 transaction_.GetResponseInfo()->socket_address.host());
913 EXPECT_EQ(0, transaction_.GetResponseInfo()->socket_address.port());
907 } 914 }
908 915
909 TEST_F(FtpNetworkTransactionTest, DownloadTransactionWithPasvFallback) { 916 TEST_F(FtpNetworkTransactionTest, DownloadTransactionWithPasvFallback) {
910 FtpSocketDataProviderFileDownloadWithPasvFallback ctrl_socket; 917 FtpSocketDataProviderFileDownloadWithPasvFallback ctrl_socket;
911 ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK); 918 ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK);
912 919
913 // We pass an artificial value of 18 as a response to the SIZE command. 920 // We pass an artificial value of 18 as a response to the SIZE command.
914 EXPECT_EQ(18, transaction_.GetResponseInfo()->expected_content_size); 921 EXPECT_EQ(18, transaction_.GetResponseInfo()->expected_content_size);
915 } 922 }
916 923
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 FtpSocketDataProviderFileDownload ctrl_socket; 1431 FtpSocketDataProviderFileDownload ctrl_socket;
1425 TransactionFailHelper(&ctrl_socket, 1432 TransactionFailHelper(&ctrl_socket,
1426 "ftp://host/file", 1433 "ftp://host/file",
1427 FtpSocketDataProvider::PRE_PWD, 1434 FtpSocketDataProvider::PRE_PWD,
1428 FtpSocketDataProvider::PRE_TYPE, 1435 FtpSocketDataProvider::PRE_TYPE,
1429 "257 \"\"\r\n", 1436 "257 \"\"\r\n",
1430 OK); 1437 OK);
1431 } 1438 }
1432 1439
1433 } // namespace net 1440 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698