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/platform_file.h" | 8 #include "base/platform_file.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/public/test/test_file_system_context.h" | 10 #include "content/public/test/test_file_system_context.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "webkit/browser/fileapi/file_system_context.h" | 12 #include "webkit/browser/fileapi/file_system_context.h" |
13 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 13 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
14 | 14 |
15 namespace fileapi { | 15 using fileapi::FileSystemContext; |
| 16 using fileapi::FileSystemOperationRunner; |
| 17 using fileapi::FileSystemType; |
| 18 using fileapi::FileSystemURL; |
| 19 |
| 20 namespace content { |
16 | 21 |
17 void GetStatus(bool* done, | 22 void GetStatus(bool* done, |
18 base::PlatformFileError *status_out, | 23 base::PlatformFileError *status_out, |
19 base::PlatformFileError status) { | 24 base::PlatformFileError status) { |
20 ASSERT_FALSE(*done); | 25 ASSERT_FALSE(*done); |
21 *done = true; | 26 *done = true; |
22 *status_out = status; | 27 *status_out = status; |
23 } | 28 } |
24 | 29 |
25 void GetCancelStatus(bool* operation_done, | 30 void GetCancelStatus(bool* operation_done, |
(...skipping 19 matching lines...) Expand all Loading... |
45 CreateFileSystemContextForTesting(NULL, base_dir); | 50 CreateFileSystemContextForTesting(NULL, base_dir); |
46 } | 51 } |
47 | 52 |
48 virtual void TearDown() OVERRIDE { | 53 virtual void TearDown() OVERRIDE { |
49 file_system_context_ = NULL; | 54 file_system_context_ = NULL; |
50 base::RunLoop().RunUntilIdle(); | 55 base::RunLoop().RunUntilIdle(); |
51 } | 56 } |
52 | 57 |
53 FileSystemURL URL(const std::string& path) { | 58 FileSystemURL URL(const std::string& path) { |
54 return file_system_context_->CreateCrackedFileSystemURL( | 59 return file_system_context_->CreateCrackedFileSystemURL( |
55 GURL("http://example.com"), kFileSystemTypeTemporary, | 60 GURL("http://example.com"), fileapi::kFileSystemTypeTemporary, |
56 base::FilePath::FromUTF8Unsafe(path)); | 61 base::FilePath::FromUTF8Unsafe(path)); |
57 } | 62 } |
58 | 63 |
59 FileSystemOperationRunner* operation_runner() { | 64 FileSystemOperationRunner* operation_runner() { |
60 return file_system_context_->operation_runner(); | 65 return file_system_context_->operation_runner(); |
61 } | 66 } |
62 | 67 |
63 private: | 68 private: |
64 base::ScopedTempDir base_; | 69 base::ScopedTempDir base_; |
65 base::MessageLoop message_loop_; | 70 base::MessageLoop message_loop_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 bool cancel_done = false; | 157 bool cancel_done = false; |
153 base::PlatformFileError cancel_status = base::PLATFORM_FILE_ERROR_FAILED; | 158 base::PlatformFileError cancel_status = base::PLATFORM_FILE_ERROR_FAILED; |
154 operation_runner()->Cancel(kInvalidId, base::Bind(&GetCancelStatus, | 159 operation_runner()->Cancel(kInvalidId, base::Bind(&GetCancelStatus, |
155 &done, &cancel_done, | 160 &done, &cancel_done, |
156 &cancel_status)); | 161 &cancel_status)); |
157 | 162 |
158 ASSERT_TRUE(cancel_done); | 163 ASSERT_TRUE(cancel_done); |
159 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, cancel_status); | 164 ASSERT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, cancel_status); |
160 } | 165 } |
161 | 166 |
162 } // namespace fileapi | 167 } // namespace content |
OLD | NEW |