| Index: net/url_request/url_request_unittest.cc
 | 
| ===================================================================
 | 
| --- net/url_request/url_request_unittest.cc	(revision 7499)
 | 
| +++ net/url_request/url_request_unittest.cc	(working copy)
 | 
| @@ -83,11 +83,12 @@
 | 
|  };
 | 
|  
 | 
|  TEST_F(URLRequestTest, GetTest_NoCache) {
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage(""), &d);
 | 
| +    TestURLRequest r(server->TestServerPage(""), &d);
 | 
|  
 | 
|      r.Start();
 | 
|      EXPECT_TRUE(r.is_pending());
 | 
| @@ -104,11 +105,12 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, GetTest) {
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage(""), &d);
 | 
| +    TestURLRequest r(server->TestServerPage(""), &d);
 | 
|  
 | 
|      r.Start();
 | 
|      EXPECT_TRUE(r.is_pending());
 | 
| @@ -127,7 +129,7 @@
 | 
|  class HTTPSRequestTest : public testing::Test {
 | 
|   protected:
 | 
|     HTTPSRequestTest() : util_() {};
 | 
| - 
 | 
| +
 | 
|     SSLTestUtil util_;
 | 
|  };
 | 
|  
 | 
| @@ -143,14 +145,15 @@
 | 
|    // a working document root to server the pages / and /hello.html,
 | 
|    // so this test doesn't really need to specify a document root.
 | 
|    // But if it did, a good one would be net/data/ssl.
 | 
| -  HTTPSTestServer https_server(util_.kHostName, util_.kOKHTTPSPort,
 | 
| -                               L"net/data/ssl",
 | 
| -                               util_.GetOKCertPath().ToWStringHack());
 | 
| +  scoped_refptr<HTTPSTestServer> server =
 | 
| +      HTTPSTestServer::CreateServer(util_.kHostName, util_.kOKHTTPSPort,
 | 
| +      L"net/data/ssl", util_.GetOKCertPath().ToWStringHack());
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|  
 | 
|    EXPECT_TRUE(util_.CheckCATrusted());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(https_server.TestServerPage(""), &d);
 | 
| +    TestURLRequest r(server->TestServerPage(""), &d);
 | 
|  
 | 
|      r.Start();
 | 
|      EXPECT_TRUE(r.is_pending());
 | 
| @@ -190,11 +193,16 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, CancelTest2) {
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +
 | 
| +  // error C2446: '!=' : no conversion from 'HTTPTestServer *const '
 | 
| +  // to 'const int'
 | 
| +
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage(""), &d);
 | 
| +    TestURLRequest r(server->TestServerPage(""), &d);
 | 
|  
 | 
|      d.set_cancel_in_response_started(true);
 | 
|  
 | 
| @@ -214,11 +222,12 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, CancelTest3) {
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage(""), &d);
 | 
| +    TestURLRequest r(server->TestServerPage(""), &d);
 | 
|  
 | 
|      d.set_cancel_in_received_data(true);
 | 
|  
 | 
| @@ -241,11 +250,12 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, CancelTest4) {
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage(""), &d);
 | 
| +    TestURLRequest r(server->TestServerPage(""), &d);
 | 
|  
 | 
|      r.Start();
 | 
|      EXPECT_TRUE(r.is_pending());
 | 
| @@ -266,14 +276,15 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, CancelTest5) {
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext();
 | 
|  
 | 
|    // populate cache
 | 
|    {
 | 
|      TestDelegate d;
 | 
| -    URLRequest r(server.TestServerPage("cachetime"), &d);
 | 
| +    URLRequest r(server->TestServerPage("cachetime"), &d);
 | 
|      r.set_context(context);
 | 
|      r.Start();
 | 
|      MessageLoop::current()->Run();
 | 
| @@ -283,7 +294,7 @@
 | 
|    // cancel read from cache (see bug 990242)
 | 
|    {
 | 
|      TestDelegate d;
 | 
| -    URLRequest r(server.TestServerPage("cachetime"), &d);
 | 
| +    URLRequest r(server->TestServerPage("cachetime"), &d);
 | 
|      r.set_context(context);
 | 
|      r.Start();
 | 
|      r.Cancel();
 | 
| @@ -301,9 +312,9 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, PostTest) {
 | 
| -  TestServer server(L"net/data");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| -
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    const int kMsgSize = 20000;  // multiple of 10
 | 
|    const int kIterations = 50;
 | 
|    char *uploadBytes = new char[kMsgSize+1];
 | 
| @@ -327,7 +338,7 @@
 | 
|  
 | 
|    for (int i = 0; i < kIterations; ++i) {
 | 
|      TestDelegate d;
 | 
| -    URLRequest r(server.TestServerPage("echo"), &d);
 | 
| +    URLRequest r(server->TestServerPage("echo"), &d);
 | 
|      r.set_context(context);
 | 
|      r.set_method("POST");
 | 
|  
 | 
| @@ -353,11 +364,12 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, PostEmptyTest) {
 | 
| -  TestServer server(L"net/data");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage("echo"), &d);
 | 
| +    TestURLRequest r(server->TestServerPage("echo"), &d);
 | 
|      r.set_method("POST");
 | 
|  
 | 
|      r.Start();
 | 
| @@ -377,11 +389,12 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, PostFileTest) {
 | 
| -  TestServer server(L"net/data");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
| -    TestURLRequest r(server.TestServerPage("echo"), &d);
 | 
| +    TestURLRequest r(server->TestServerPage("echo"), &d);
 | 
|      r.set_method("POST");
 | 
|  
 | 
|      std::wstring dir;
 | 
| @@ -409,7 +422,8 @@
 | 
|      int size = static_cast<int>(longsize);
 | 
|      scoped_array<char> buf(new char[size]);
 | 
|  
 | 
| -    int size_read = static_cast<int>(file_util::ReadFile(path, buf.get(), size));
 | 
| +    int size_read = static_cast<int>(file_util::ReadFile(path,
 | 
| +        buf.get(), size));
 | 
|      ASSERT_EQ(size, size_read);
 | 
|  
 | 
|      ASSERT_EQ(1, d.response_started_count()) << "request failed: " <<
 | 
| @@ -506,10 +520,11 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, ResponseHeadersTest) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
| -  TestURLRequest req(server.TestServerPage("files/with-headers.html"), &d);
 | 
| +  TestURLRequest req(server->TestServerPage("files/with-headers.html"), &d);
 | 
|    req.Start();
 | 
|    MessageLoop::current()->Run();
 | 
|  
 | 
| @@ -530,13 +545,14 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, BZip2ContentTest) {
 | 
| -  TestServer server(L"net/data/filter_unittests");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/filter_unittests");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|  
 | 
|    // for localhost domain, we also should support bzip2 encoding
 | 
|    // first, get the original file
 | 
|    TestDelegate d1;
 | 
| -  TestURLRequest req1(server.TestServerPage("realfiles/google.txt"), &d1);
 | 
| +  TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1);
 | 
|    req1.Start();
 | 
|    MessageLoop::current()->Run();
 | 
|  
 | 
| @@ -544,7 +560,7 @@
 | 
|  
 | 
|    // second, get bzip2 content
 | 
|    TestDelegate d2;
 | 
| -  TestURLRequest req2(server.TestServerPage("realbz2files/google.txt"), &d2);
 | 
| +  TestURLRequest req2(server->TestServerPage("realbz2files/google.txt"), &d2);
 | 
|    req2.Start();
 | 
|    MessageLoop::current()->Run();
 | 
|  
 | 
| @@ -555,13 +571,14 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, BZip2ContentTest_IncrementalHeader) {
 | 
| -  TestServer server(L"net/data/filter_unittests");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/filter_unittests");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|  
 | 
|    // for localhost domain, we also should support bzip2 encoding
 | 
|    // first, get the original file
 | 
|    TestDelegate d1;
 | 
| -  TestURLRequest req1(server.TestServerPage("realfiles/google.txt"), &d1);
 | 
| +  TestURLRequest req1(server->TestServerPage("realfiles/google.txt"), &d1);
 | 
|    req1.Start();
 | 
|    MessageLoop::current()->Run();
 | 
|  
 | 
| @@ -570,7 +587,8 @@
 | 
|    // second, get bzip2 content.  ask the testserver to send the BZ2 header in
 | 
|    // two chunks with a delay between them.  this tests our fix for bug 867161.
 | 
|    TestDelegate d2;
 | 
| -  TestURLRequest req2(server.TestServerPage("realbz2files/google.txt?incremental-header"), &d2);
 | 
| +  TestURLRequest req2(server->TestServerPage(
 | 
| +      "realbz2files/google.txt?incremental-header"), &d2);
 | 
|    req2.Start();
 | 
|    MessageLoop::current()->Run();
 | 
|  
 | 
| @@ -654,10 +672,12 @@
 | 
|  #endif  // defined(OS_WIN)
 | 
|  
 | 
|  TEST_F(URLRequestTest, ContentTypeNormalizationTest) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +
 | 
|    TestDelegate d;
 | 
| -  TestURLRequest req(server.TestServerPage(
 | 
| +  TestURLRequest req(server->TestServerPage(
 | 
|        "files/content-type-normalization.html"), &d);
 | 
|    req.Start();
 | 
|    MessageLoop::current()->Run();
 | 
| @@ -701,10 +721,12 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, RestrictRedirects) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +
 | 
|    TestDelegate d;
 | 
| -  TestURLRequest req(server.TestServerPage(
 | 
| +  TestURLRequest req(server->TestServerPage(
 | 
|        "files/redirect-to-file.html"), &d);
 | 
|    req.Start();
 | 
|    MessageLoop::current()->Run();
 | 
| @@ -714,10 +736,11 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, NoUserPassInReferrer) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
| -  TestURLRequest req(server.TestServerPage(
 | 
| +  TestURLRequest req(server->TestServerPage(
 | 
|        "echoheader?Referer"), &d);
 | 
|    req.set_referrer("http://user:pass@foo.com/");
 | 
|    req.Start();
 | 
| @@ -727,12 +750,13 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, CancelRedirect) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
|    {
 | 
|      d.set_cancel_in_received_redirect(true);
 | 
| -    TestURLRequest req(server.TestServerPage(
 | 
| +    TestURLRequest req(server->TestServerPage(
 | 
|          "files/redirect-test.html"), &d);
 | 
|      req.Start();
 | 
|      MessageLoop::current()->Run();
 | 
| @@ -745,8 +769,9 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, VaryHeader) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|  
 | 
|    scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext();
 | 
|  
 | 
| @@ -755,7 +780,7 @@
 | 
|    // populate the cache
 | 
|    {
 | 
|      TestDelegate d;
 | 
| -    URLRequest req(server.TestServerPage("echoheader?foo"), &d);
 | 
| +    URLRequest req(server->TestServerPage("echoheader?foo"), &d);
 | 
|      req.set_context(context);
 | 
|      req.SetExtraRequestHeaders("foo:1");
 | 
|      req.Start();
 | 
| @@ -771,7 +796,7 @@
 | 
|    // expect a cache hit
 | 
|    {
 | 
|      TestDelegate d;
 | 
| -    URLRequest req(server.TestServerPage("echoheader?foo"), &d);
 | 
| +    URLRequest req(server->TestServerPage("echoheader?foo"), &d);
 | 
|      req.set_context(context);
 | 
|      req.SetExtraRequestHeaders("foo:1");
 | 
|      req.Start();
 | 
| @@ -783,7 +808,7 @@
 | 
|    // expect a cache miss
 | 
|    {
 | 
|      TestDelegate d;
 | 
| -    URLRequest req(server.TestServerPage("echoheader?foo"), &d);
 | 
| +    URLRequest req(server->TestServerPage("echoheader?foo"), &d);
 | 
|      req.set_context(context);
 | 
|      req.SetExtraRequestHeaders("foo:2");
 | 
|      req.Start();
 | 
| @@ -795,8 +820,9 @@
 | 
|  
 | 
|  TEST_F(URLRequestTest, BasicAuth) {
 | 
|    scoped_refptr<URLRequestContext> context = new URLRequestHttpCacheContext();
 | 
| -  TestServer server(L"");
 | 
| -  ASSERT_TRUE(server.init_successful());
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|  
 | 
|    Time response_time;
 | 
|  
 | 
| @@ -806,7 +832,7 @@
 | 
|      d.set_username(L"user");
 | 
|      d.set_password(L"secret");
 | 
|  
 | 
| -    URLRequest r(server.TestServerPage("auth-basic"), &d);
 | 
| +    URLRequest r(server->TestServerPage("auth-basic"), &d);
 | 
|      r.set_context(context);
 | 
|      r.Start();
 | 
|  
 | 
| @@ -829,7 +855,7 @@
 | 
|      d.set_username(L"user");
 | 
|      d.set_password(L"secret");
 | 
|  
 | 
| -    URLRequest r(server.TestServerPage("auth-basic"), &d);
 | 
| +    URLRequest r(server->TestServerPage("auth-basic"), &d);
 | 
|      r.set_context(context);
 | 
|      r.set_load_flags(net::LOAD_VALIDATE_CACHE);
 | 
|      r.Start();
 | 
| @@ -849,16 +875,20 @@
 | 
|  // Content-Type header.
 | 
|  // http://code.google.com/p/chromium/issues/detail?id=843
 | 
|  TEST_F(URLRequestTest, Post302RedirectGet) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
| -  TestURLRequest req(server.TestServerPage("files/redirect-to-echoall"), &d);
 | 
| +  TestURLRequest req(server->TestServerPage("files/redirect-to-echoall"), &d);
 | 
|    req.set_method("POST");
 | 
|  
 | 
|    // Set headers (some of which are specific to the POST).
 | 
|    // ("Content-Length: 10" is just a junk value to make sure it gets stripped).
 | 
|    req.SetExtraRequestHeaders(
 | 
| -    "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAADeAA+NAAWMAAwZ\r\n"
 | 
| -    "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n"
 | 
| +    "Content-Type: multipart/form-data; "
 | 
| +    "boundary=----WebKitFormBoundaryAADeAA+NAAWMAAwZ\r\n"
 | 
| +    "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,"
 | 
| +    "text/plain;q=0.8,image/png,*/*;q=0.5\r\n"
 | 
|      "Accept-Language: en-US,en\r\n"
 | 
|      "Accept-Charset: ISO-8859-1,*,utf-8\r\n"
 | 
|      "Content-Length: 10\r\n"
 | 
| @@ -885,11 +915,126 @@
 | 
|  }
 | 
|  
 | 
|  TEST_F(URLRequestTest, Post307RedirectPost) {
 | 
| -  TestServer server(L"net/data/url_request_unittest");
 | 
| +  scoped_refptr<HTTPTestServer> server =
 | 
| +      HTTPTestServer::CreateServer(L"net/data/url_request_unittest");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
|    TestDelegate d;
 | 
| -  TestURLRequest req(server.TestServerPage("files/redirect307-to-echoall"), &d);
 | 
| +  TestURLRequest req(server->TestServerPage("files/redirect307-to-echoall"),
 | 
| +      &d);
 | 
|    req.set_method("POST");
 | 
|    req.Start();
 | 
|    MessageLoop::current()->Run();
 | 
|    EXPECT_EQ(req.method(), "POST");
 | 
|  }
 | 
| +
 | 
| +#if !defined(OS_WIN)
 | 
| +  #define MAYBE_FTPGetTestAnonymous   DISABLED_FTPGetTestAnonymous
 | 
| +  #define MAYBE_FTPCheckWrongPassword DISABLED_FTPCheckWrongPassword
 | 
| +  #define MAYBE_FTPCheckWrongUser     DISABLED_FTPCheckWrongUser
 | 
| +  #define MAYBE_FTPGetTest            DISABLED_FTPGetTest
 | 
| +#else
 | 
| +  #define MAYBE_FTPGetTestAnonymous   FTPGetTestAnonymous
 | 
| +  #define MAYBE_FTPCheckWrongPassword FTPCheckWrongPassword
 | 
| +  #define MAYBE_FTPCheckWrongUser     FTPCheckWrongUser
 | 
| +  #define MAYBE_FTPGetTest            FTPGetTest
 | 
| +#endif
 | 
| +
 | 
| +TEST_F(URLRequestTest, MAYBE_FTPGetTestAnonymous) {
 | 
| +  scoped_refptr<FTPTestServer> server = FTPTestServer::CreateServer(L"");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +  std::wstring app_path;
 | 
| +  PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
 | 
| +  app_path.append(L"\\LICENSE");
 | 
| +  TestDelegate d;
 | 
| +  {
 | 
| +    TestURLRequest r(server->TestServerPage("/LICENSE"), &d);
 | 
| +    r.Start();
 | 
| +    EXPECT_TRUE(r.is_pending());
 | 
| +
 | 
| +    MessageLoop::current()->Run();
 | 
| +
 | 
| +    int64 file_size = 0;
 | 
| +    file_util::GetFileSize(app_path, &file_size);
 | 
| +
 | 
| +    EXPECT_TRUE(!r.is_pending());
 | 
| +    EXPECT_EQ(1, d.response_started_count());
 | 
| +    EXPECT_FALSE(d.received_data_before_response());
 | 
| +    EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
 | 
| +  }
 | 
| +}
 | 
| +
 | 
| +TEST_F(URLRequestTest, MAYBE_FTPGetTest) {
 | 
| +  scoped_refptr<FTPTestServer> server =
 | 
| +      FTPTestServer::CreateServer(L"", "chrome", "chrome");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +  std::wstring app_path;
 | 
| +  PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
 | 
| +  app_path.append(L"\\LICENSE");
 | 
| +  TestDelegate d;
 | 
| +  {
 | 
| +    TestURLRequest r(server->TestServerPage("/LICENSE"), &d);
 | 
| +    r.Start();
 | 
| +    EXPECT_TRUE(r.is_pending());
 | 
| +
 | 
| +    MessageLoop::current()->Run();
 | 
| +
 | 
| +    int64 file_size = 0;
 | 
| +    file_util::GetFileSize(app_path, &file_size);
 | 
| +
 | 
| +    EXPECT_TRUE(!r.is_pending());
 | 
| +    EXPECT_EQ(1, d.response_started_count());
 | 
| +    EXPECT_FALSE(d.received_data_before_response());
 | 
| +    EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
 | 
| +  }
 | 
| +}
 | 
| +
 | 
| +TEST_F(URLRequestTest, MAYBE_FTPCheckWrongPassword) {
 | 
| +  scoped_refptr<FTPTestServer> server =
 | 
| +      FTPTestServer::CreateServer(L"", "chrome", "wrong_password");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +  std::wstring app_path;
 | 
| +  PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
 | 
| +  app_path.append(L"\\LICENSE");
 | 
| +  TestDelegate d;
 | 
| +  {
 | 
| +    TestURLRequest r(server->TestServerPage("/LICENSE"), &d);
 | 
| +    r.Start();
 | 
| +    EXPECT_TRUE(r.is_pending());
 | 
| +
 | 
| +    MessageLoop::current()->Run();
 | 
| +
 | 
| +    int64 file_size = 0;
 | 
| +    file_util::GetFileSize(app_path, &file_size);
 | 
| +
 | 
| +    EXPECT_TRUE(!r.is_pending());
 | 
| +    EXPECT_EQ(1, d.response_started_count());
 | 
| +    EXPECT_FALSE(d.received_data_before_response());
 | 
| +    EXPECT_EQ(d.bytes_received(), 0);
 | 
| +  }
 | 
| +}
 | 
| +
 | 
| +TEST_F(URLRequestTest, MAYBE_FTPCheckWrongUser) {
 | 
| +  scoped_refptr<FTPTestServer> server =
 | 
| +      FTPTestServer::CreateServer(L"", "wrong_user", "chrome");
 | 
| +  ASSERT_TRUE(NULL != server.get());
 | 
| +  std::wstring app_path;
 | 
| +  PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
 | 
| +  app_path.append(L"\\LICENSE");
 | 
| +  TestDelegate d;
 | 
| +  {
 | 
| +    TestURLRequest r(server->TestServerPage("/LICENSE"), &d);
 | 
| +    r.Start();
 | 
| +    EXPECT_TRUE(r.is_pending());
 | 
| +
 | 
| +    MessageLoop::current()->Run();
 | 
| +
 | 
| +    int64 file_size = 0;
 | 
| +    file_util::GetFileSize(app_path, &file_size);
 | 
| +
 | 
| +    EXPECT_TRUE(!r.is_pending());
 | 
| +    EXPECT_EQ(1, d.response_started_count());
 | 
| +    EXPECT_FALSE(d.received_data_before_response());
 | 
| +    EXPECT_EQ(d.bytes_received(), 0);
 | 
| +  }
 | 
| +}
 | 
| +
 | 
| 
 |