Chromium Code Reviews| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 328 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 329 } | 329 } |
| 330 | 330 |
| 331 TEST_F(FileSystemURLRequestJobTest, NoSuchFile) { | 331 TEST_F(FileSystemURLRequestJobTest, NoSuchFile) { |
| 332 TestRequest(CreateFileSystemURL("somefile")); | 332 TestRequest(CreateFileSystemURL("somefile")); |
| 333 ASSERT_FALSE(request_->is_pending()); | 333 ASSERT_FALSE(request_->is_pending()); |
| 334 EXPECT_TRUE(delegate_->request_failed()); | 334 EXPECT_TRUE(delegate_->request_failed()); |
| 335 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); | 335 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 class QuitNowTask : public Task { | |
| 339 public: | |
| 340 virtual void Run() { | |
| 341 MessageLoop::current()->QuitNow(); | |
| 342 } | |
| 343 }; | |
| 344 | |
| 345 TEST_F(FileSystemURLRequestJobTest, Cancel) { | 338 TEST_F(FileSystemURLRequestJobTest, Cancel) { |
| 346 WriteFile("file1.dat", kTestFileData, arraysize(kTestFileData) - 1); | 339 WriteFile("file1.dat", kTestFileData, arraysize(kTestFileData) - 1); |
| 347 TestRequestNoRun(CreateFileSystemURL("file1.dat")); | 340 TestRequestNoRun(CreateFileSystemURL("file1.dat")); |
| 348 | 341 |
| 349 // Run StartAsync() and only StartAsync(). | 342 // Run StartAsync() and only StartAsync(). |
| 350 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); | 343 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
|
awong
2011/12/20 23:51:47
Same comment as previous file.
James Hawkins
2011/12/21 00:43:08
Done.
| |
| 351 MessageLoop::current()->Run(); | 344 MessageLoop::current()->Run(); |
| 352 | 345 |
| 353 request_.reset(); | 346 request_.reset(); |
| 354 MessageLoop::current()->RunAllPending(); | 347 MessageLoop::current()->RunAllPending(); |
| 355 // If we get here, success! we didn't crash! | 348 // If we get here, success! we didn't crash! |
| 356 } | 349 } |
| 357 | 350 |
| 358 TEST_F(FileSystemURLRequestJobTest, GetMimeType) { | 351 TEST_F(FileSystemURLRequestJobTest, GetMimeType) { |
| 359 const char kFilename[] = "hoge.html"; | 352 const char kFilename[] = "hoge.html"; |
| 360 | 353 |
| 361 std::string mime_type_direct; | 354 std::string mime_type_direct; |
| 362 FilePath::StringType extension = | 355 FilePath::StringType extension = |
| 363 FilePath().AppendASCII(kFilename).Extension(); | 356 FilePath().AppendASCII(kFilename).Extension(); |
| 364 if (!extension.empty()) | 357 if (!extension.empty()) |
| 365 extension = extension.substr(1); | 358 extension = extension.substr(1); |
| 366 EXPECT_TRUE(net::GetWellKnownMimeTypeFromExtension( | 359 EXPECT_TRUE(net::GetWellKnownMimeTypeFromExtension( |
| 367 extension, &mime_type_direct)); | 360 extension, &mime_type_direct)); |
| 368 | 361 |
| 369 TestRequest(CreateFileSystemURL(kFilename)); | 362 TestRequest(CreateFileSystemURL(kFilename)); |
| 370 | 363 |
| 371 std::string mime_type_from_job; | 364 std::string mime_type_from_job; |
| 372 request_->GetMimeType(&mime_type_from_job); | 365 request_->GetMimeType(&mime_type_from_job); |
| 373 EXPECT_EQ(mime_type_direct, mime_type_from_job); | 366 EXPECT_EQ(mime_type_direct, mime_type_from_job); |
| 374 } | 367 } |
| 375 | 368 |
| 376 } // namespace (anonymous) | 369 } // namespace (anonymous) |
| 377 } // namespace fileapi | 370 } // namespace fileapi |
| OLD | NEW |