| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 operation_runner()->Cancel(id, base::Bind(&GetCancelStatus, | 110 operation_runner()->Cancel(id, base::Bind(&GetCancelStatus, |
| 111 &done, &cancel_done, | 111 &done, &cancel_done, |
| 112 &cancel_status)); | 112 &cancel_status)); |
| 113 | 113 |
| 114 ASSERT_FALSE(done); | 114 ASSERT_FALSE(done); |
| 115 ASSERT_FALSE(cancel_done); | 115 ASSERT_FALSE(cancel_done); |
| 116 base::MessageLoop::current()->RunUntilIdle(); | 116 base::MessageLoop::current()->RunUntilIdle(); |
| 117 | 117 |
| 118 ASSERT_TRUE(done); | 118 ASSERT_TRUE(done); |
| 119 ASSERT_TRUE(cancel_done); | 119 ASSERT_TRUE(cancel_done); |
| 120 ASSERT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status); | 120 ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status); |
| 121 ASSERT_EQ(base::PLATFORM_FILE_OK, cancel_status); | 121 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, cancel_status); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST_F(FileSystemOperationRunnerTest, InvalidURLErrorAndCancel) { | 124 TEST_F(FileSystemOperationRunnerTest, InvalidURLErrorAndCancel) { |
| 125 bool done = false; | 125 bool done = false; |
| 126 bool cancel_done = false; | 126 bool cancel_done = false; |
| 127 base::PlatformFileError status = base::PLATFORM_FILE_ERROR_FAILED; | 127 base::PlatformFileError status = base::PLATFORM_FILE_ERROR_FAILED; |
| 128 base::PlatformFileError cancel_status = base::PLATFORM_FILE_ERROR_FAILED; | 128 base::PlatformFileError cancel_status = base::PLATFORM_FILE_ERROR_FAILED; |
| 129 | 129 |
| 130 // Call Truncate with invalid URL, and try to cancel it immediately | 130 // Call Truncate with invalid URL, and try to cancel it immediately |
| 131 // after that (before its callback is fired). | 131 // after that (before its callback is fired). |
| 132 FileSystemOperationRunner::OperationID id = | 132 FileSystemOperationRunner::OperationID id = |
| 133 operation_runner()->Truncate(FileSystemURL(), 0, | 133 operation_runner()->Truncate(FileSystemURL(), 0, |
| 134 base::Bind(&GetStatus, &done, &status)); | 134 base::Bind(&GetStatus, &done, &status)); |
| 135 operation_runner()->Cancel(id, base::Bind(&GetCancelStatus, | 135 operation_runner()->Cancel(id, base::Bind(&GetCancelStatus, |
| 136 &done, &cancel_done, | 136 &done, &cancel_done, |
| 137 &cancel_status)); | 137 &cancel_status)); |
| 138 | 138 |
| 139 ASSERT_FALSE(done); | 139 ASSERT_FALSE(done); |
| 140 ASSERT_FALSE(cancel_done); | 140 ASSERT_FALSE(cancel_done); |
| 141 base::MessageLoop::current()->RunUntilIdle(); | 141 base::MessageLoop::current()->RunUntilIdle(); |
| 142 | 142 |
| 143 ASSERT_TRUE(done); | 143 ASSERT_TRUE(done); |
| 144 ASSERT_TRUE(cancel_done); | 144 ASSERT_TRUE(cancel_done); |
| 145 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_URL, status); | 145 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_URL, status); |
| 146 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, cancel_status); | 146 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, cancel_status); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace fileapi | 149 } // namespace fileapi |
| OLD | NEW |