| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 EXPECT_TRUE(std::getline(in, line)); | 258 EXPECT_TRUE(std::getline(in, line)); |
| 259 VerifyListingEntry(line, "hoge", "hoge", false, 10); | 259 VerifyListingEntry(line, "hoge", "hoge", false, 10); |
| 260 } | 260 } |
| 261 | 261 |
| 262 TEST_F(FileSystemDirURLRequestJobTest, InvalidURL) { | 262 TEST_F(FileSystemDirURLRequestJobTest, InvalidURL) { |
| 263 TestRequest(GURL("filesystem:/foo/bar/baz")); | 263 TestRequest(GURL("filesystem:/foo/bar/baz")); |
| 264 ASSERT_FALSE(request_->is_pending()); | 264 ASSERT_FALSE(request_->is_pending()); |
| 265 EXPECT_TRUE(delegate_->request_failed()); | 265 EXPECT_TRUE(delegate_->request_failed()); |
| 266 ASSERT_FALSE(request_->status().is_success()); | 266 ASSERT_FALSE(request_->status().is_success()); |
| 267 EXPECT_EQ(net::ERR_INVALID_URL, request_->status().os_error()); | 267 EXPECT_EQ(net::ERR_INVALID_URL, request_->status().error()); |
| 268 } | 268 } |
| 269 | 269 |
| 270 TEST_F(FileSystemDirURLRequestJobTest, NoSuchRoot) { | 270 TEST_F(FileSystemDirURLRequestJobTest, NoSuchRoot) { |
| 271 TestRequest(GURL("filesystem:http://remote/persistent/somedir/")); | 271 TestRequest(GURL("filesystem:http://remote/persistent/somedir/")); |
| 272 ASSERT_FALSE(request_->is_pending()); | 272 ASSERT_FALSE(request_->is_pending()); |
| 273 ASSERT_FALSE(request_->status().is_success()); | 273 ASSERT_FALSE(request_->status().is_success()); |
| 274 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().os_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().os_error()); | 281 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 class QuitNowTask : public Task { | 284 class QuitNowTask : public Task { |
| 285 public: | 285 public: |
| 286 virtual void Run() { | 286 virtual void Run() { |
| 287 MessageLoop::current()->QuitNow(); | 287 MessageLoop::current()->QuitNow(); |
| 288 } | 288 } |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 TEST_F(FileSystemDirURLRequestJobTest, Cancel) { | 291 TEST_F(FileSystemDirURLRequestJobTest, Cancel) { |
| 292 CreateDirectory("foo"); | 292 CreateDirectory("foo"); |
| 293 TestRequestNoRun(CreateFileSystemURL("foo/")); | 293 TestRequestNoRun(CreateFileSystemURL("foo/")); |
| 294 // Run StartAsync() and only StartAsync(). | 294 // Run StartAsync() and only StartAsync(). |
| 295 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); | 295 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); |
| 296 MessageLoop::current()->Run(); | 296 MessageLoop::current()->Run(); |
| 297 | 297 |
| 298 request_.reset(); | 298 request_.reset(); |
| 299 MessageLoop::current()->RunAllPending(); | 299 MessageLoop::current()->RunAllPending(); |
| 300 // If we get here, success! we didn't crash! | 300 // If we get here, success! we didn't crash! |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace (anonymous) | 303 } // namespace (anonymous) |
| 304 } // namespace fileapi | 304 } // namespace fileapi |
| OLD | NEW |