| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) | 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) |
| 6 // rather than as part of test_shell_tests because they rely on being able | 6 // rather than as part of test_shell_tests because they rely on being able |
| 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses | 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses |
| 8 // TYPE_UI, which URLRequest doesn't allow. | 8 // TYPE_UI, which URLRequest doesn't allow. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 274 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 275 } | 275 } |
| 276 | 276 |
| 277 TEST_F(FileSystemDirURLRequestJobTest, NoSuchDirectory) { | 277 TEST_F(FileSystemDirURLRequestJobTest, NoSuchDirectory) { |
| 278 TestRequest(CreateFileSystemURL("somedir/")); | 278 TestRequest(CreateFileSystemURL("somedir/")); |
| 279 ASSERT_FALSE(request_->is_pending()); | 279 ASSERT_FALSE(request_->is_pending()); |
| 280 ASSERT_FALSE(request_->status().is_success()); | 280 ASSERT_FALSE(request_->status().is_success()); |
| 281 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 281 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 class QuitNowTask : public Task { | |
| 285 public: | |
| 286 virtual void Run() { | |
| 287 MessageLoop::current()->QuitNow(); | |
| 288 } | |
| 289 }; | |
| 290 | |
| 291 TEST_F(FileSystemDirURLRequestJobTest, Cancel) { | 284 TEST_F(FileSystemDirURLRequestJobTest, Cancel) { |
| 292 CreateDirectory("foo"); | 285 CreateDirectory("foo"); |
| 293 TestRequestNoRun(CreateFileSystemURL("foo/")); | 286 TestRequestNoRun(CreateFileSystemURL("foo/")); |
| 294 // Run StartAsync() and only StartAsync(). | 287 // Run StartAsync() and only StartAsync(). |
| 295 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); | 288 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); |
| 296 MessageLoop::current()->Run(); | |
| 297 | |
| 298 request_.reset(); | |
| 299 MessageLoop::current()->RunAllPending(); | 289 MessageLoop::current()->RunAllPending(); |
| 300 // If we get here, success! we didn't crash! | 290 // If we get here, success! we didn't crash! |
| 301 } | 291 } |
| 302 | 292 |
| 303 } // namespace (anonymous) | 293 } // namespace (anonymous) |
| 304 } // namespace fileapi | 294 } // namespace fileapi |
| OLD | NEW |