| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/drive_url_request_job.h" | 5 #include "chrome/browser/chromeos/drive/drive_url_request_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
| 10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class DriveURLRequestJobTest : public testing::Test { | 27 class DriveURLRequestJobTest : public testing::Test { |
| 28 protected: | 28 protected: |
| 29 DriveURLRequestJobTest() | 29 DriveURLRequestJobTest() |
| 30 : io_thread_(content::BrowserThread::IO, &message_loop_) { | 30 : io_thread_(content::BrowserThread::IO, &message_loop_) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual void SetUp() OVERRIDE { | 33 virtual void SetUp() OVERRIDE { |
| 34 url_request_context_.reset(new net::TestURLRequestContext); | 34 url_request_context_.reset(new net::TestURLRequestContext); |
| 35 delegate_.reset(new net::TestDelegate); | 35 delegate_.reset(new net::TestDelegate); |
| 36 network_delegate_.reset(new net::TestNetworkDelegate); | 36 network_delegate_.reset(new net::TestNetworkDelegate); |
| 37 |
| 38 // TODO(tedv): Using the NetworkDelegate with the URLRequestContext |
| 39 // with set_network_delegate() instead of a NULL delegate causes |
| 40 // unit test failures, which should be fixed. This occurs because |
| 41 // the TestNetworkDelegate generates a failure if an failed request |
| 42 // is generated before the OnBeforeURLRequest() method is called, |
| 43 // and DriveURLRequestJob::Start() does not call OnBeforeURLRequest(). |
| 44 // There is further discussion of this at: |
| 45 // https://codereview.chromium.org/13079008/ |
| 46 //url_request_context_.set_network_delegate(network_delegate_.get()); |
| 37 } | 47 } |
| 38 | 48 |
| 39 MessageLoopForIO message_loop_; | 49 MessageLoopForIO message_loop_; |
| 40 content::TestBrowserThread io_thread_; | 50 content::TestBrowserThread io_thread_; |
| 41 | 51 |
| 42 scoped_ptr<net::TestURLRequestContext> url_request_context_; | 52 scoped_ptr<net::TestURLRequestContext> url_request_context_; |
| 43 scoped_ptr<net::TestDelegate> delegate_; | 53 scoped_ptr<net::TestDelegate> delegate_; |
| 44 scoped_ptr<net::TestNetworkDelegate> network_delegate_; | 54 scoped_ptr<net::TestNetworkDelegate> network_delegate_; |
| 45 }; | 55 }; |
| 46 | 56 |
| 47 TEST_F(DriveURLRequestJobTest, NonGetMethod) { | 57 TEST_F(DriveURLRequestJobTest, NonGetMethod) { |
| 48 net::TestURLRequest request( | 58 net::TestURLRequest request( |
| 49 util::FilePathToDriveURL(base::FilePath::FromUTF8Unsafe("file")), | 59 util::FilePathToDriveURL(base::FilePath::FromUTF8Unsafe("file")), |
| 50 delegate_.get(), url_request_context_.get()); | 60 delegate_.get(), url_request_context_.get(), NULL); |
| 51 request.set_method("POST"); // Set non "GET" method. | 61 request.set_method("POST"); // Set non "GET" method. |
| 52 | 62 |
| 53 scoped_refptr<DriveURLRequestJob> job( | 63 scoped_refptr<DriveURLRequestJob> job( |
| 54 new DriveURLRequestJob( | 64 new DriveURLRequestJob( |
| 55 base::Bind(&GetNullDriveFileSystem), | 65 base::Bind(&GetNullDriveFileSystem), |
| 56 &request, network_delegate_.get())); | 66 &request, network_delegate_.get())); |
| 57 job->Start(); | 67 job->Start(); |
| 58 MessageLoop::current()->RunUntilIdle(); | 68 MessageLoop::current()->RunUntilIdle(); |
| 59 | 69 |
| 60 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); | 70 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); |
| 61 EXPECT_EQ(net::ERR_METHOD_NOT_SUPPORTED, request.status().error()); | 71 EXPECT_EQ(net::ERR_METHOD_NOT_SUPPORTED, request.status().error()); |
| 62 } | 72 } |
| 63 | 73 |
| 64 } // namespace drive | 74 } // namespace drive |
| OLD | NEW |