summaryrefslogtreecommitdiffstats
path: root/net/ftp
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-23 19:38:55 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-23 19:38:55 +0000
commita6e6d3f773898d4ed2f949a873362c3dfaee5a09 (patch)
treeba578863ee246306af433417b6772a4849f435a9 /net/ftp
parentb2216523c76507845fc82274e4481ad710d3dea6 (diff)
downloadchromium_src-a6e6d3f773898d4ed2f949a873362c3dfaee5a09.zip
chromium_src-a6e6d3f773898d4ed2f949a873362c3dfaee5a09.tar.gz
chromium_src-a6e6d3f773898d4ed2f949a873362c3dfaee5a09.tar.bz2
Fix one source of flakiness of FTP tests.
It turns out that similarly to RETR case, we can get two responses for LIST command, if the transfer finishes quickly enough. TEST=net_unittests BUG=25045 Review URL: http://codereview.chromium.org/436002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32823 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r--net/ftp/ftp_network_transaction.cc3
-rw-r--r--net/ftp/ftp_network_transaction_unittest.cc30
2 files changed, 33 insertions, 0 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index bfb526e..1dfc99b 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -282,6 +282,9 @@ int FtpNetworkTransaction::ProcessCtrlResponse() {
case COMMAND_RETR:
rv = ProcessResponseRETR(response);
break;
+ case COMMAND_LIST:
+ rv = ProcessResponseLIST(response);
+ break;
default:
// Multiple responses for other commands are invalid.
return Stop(ERR_INVALID_RESPONSE);
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc
index 95c4e46..9745763 100644
--- a/net/ftp/ftp_network_transaction_unittest.cc
+++ b/net/ftp/ftp_network_transaction_unittest.cc
@@ -401,6 +401,31 @@ class FtpSocketDataProviderFileDownloadTransferStarting
DISALLOW_COPY_AND_ASSIGN(FtpSocketDataProviderFileDownloadTransferStarting);
};
+class FtpSocketDataProviderDirectoryListingTransferStarting
+ : public FtpSocketDataProviderDirectoryListing {
+ public:
+ FtpSocketDataProviderDirectoryListingTransferStarting() {
+ }
+
+ virtual MockWriteResult OnWrite(const std::string& data) {
+ if (InjectFault())
+ return MockWriteResult(true, data.length());
+ switch (state()) {
+ case PRE_LIST:
+ return Verify("LIST\r\n", data, PRE_QUIT,
+ "125-Data connection already open.\r\n"
+ "125 Transfer starting.\r\n"
+ "226 Transfer complete.\r\n");
+ default:
+ return FtpSocketDataProviderDirectoryListing::OnWrite(data);
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(
+ FtpSocketDataProviderDirectoryListingTransferStarting);
+};
+
class FtpSocketDataProviderFileDownloadInvalidResponse
: public FtpSocketDataProviderFileDownload {
public:
@@ -641,6 +666,11 @@ TEST_F(FtpNetworkTransactionTest, DirectoryTransactionVMSRootDirectory) {
ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
}
+TEST_F(FtpNetworkTransactionTest, DirectoryTransactionTransferStarting) {
+ FtpSocketDataProviderDirectoryListingTransferStarting ctrl_socket;
+ ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
+}
+
TEST_F(FtpNetworkTransactionTest, DownloadTransaction) {
FtpSocketDataProviderFileDownload ctrl_socket;
ExecuteTransaction(&ctrl_socket, "ftp://host/file", OK);