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/bind.h" | 6 #include "base/bind.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/public/test/async_file_test_helper.h" | 10 #include "content/public/test/async_file_test_helper.h" |
11 #include "content/public/test/mock_special_storage_policy.h" | 11 #include "content/public/test/mock_special_storage_policy.h" |
12 #include "content/public/test/test_file_system_backend.h" | 12 #include "content/public/test/test_file_system_backend.h" |
13 #include "content/public/test/test_file_system_context.h" | 13 #include "content/public/test/test_file_system_context.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 15 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
16 #include "webkit/browser/fileapi/external_mount_points.h" | 16 #include "webkit/browser/fileapi/external_mount_points.h" |
17 #include "webkit/browser/fileapi/file_system_backend.h" | 17 #include "webkit/browser/fileapi/file_system_backend.h" |
18 #include "webkit/browser/fileapi/file_system_context.h" | 18 #include "webkit/browser/fileapi/file_system_context.h" |
19 #include "webkit/browser/fileapi/file_system_url.h" | 19 #include "webkit/browser/fileapi/file_system_url.h" |
20 #include "webkit/browser/fileapi/isolated_context.h" | 20 #include "webkit/browser/fileapi/isolated_context.h" |
21 #include "webkit/common/blob/shareable_file_reference.h" | 21 #include "webkit/common/blob/shareable_file_reference.h" |
22 #include "webkit/common/fileapi/file_system_util.h" | 22 #include "webkit/common/fileapi/file_system_util.h" |
23 | 23 |
24 using content::AsyncFileTestHelper; | 24 using content::AsyncFileTestHelper; |
25 using fileapi::CopyOrMoveFileValidator; | 25 using fileapi::CopyOrMoveFileValidator; |
26 using fileapi::CopyOrMoveFileValidatorFactory; | 26 using fileapi::CopyOrMoveFileValidatorFactory; |
27 using fileapi::FileSystemType; | |
28 using fileapi::FileSystemURL; | 27 using fileapi::FileSystemURL; |
29 | 28 |
30 namespace content { | 29 namespace content { |
31 | 30 |
32 namespace { | 31 namespace { |
33 | 32 |
34 const FileSystemType kNoValidatorType = fileapi::kFileSystemTypeTemporary; | 33 const fileapi::FileSystemType kNoValidatorType = |
35 const FileSystemType kWithValidatorType = fileapi::kFileSystemTypeTest; | 34 fileapi::kFileSystemTypeTemporary; |
| 35 const fileapi::FileSystemType kWithValidatorType = fileapi::kFileSystemTypeTest; |
36 | 36 |
37 void ExpectOk(const GURL& origin_url, | 37 void ExpectOk(const GURL& origin_url, |
38 const std::string& name, | 38 const std::string& name, |
39 base::File::Error error) { | 39 base::File::Error error) { |
40 ASSERT_EQ(base::File::FILE_OK, error); | 40 ASSERT_EQ(base::File::FILE_OK, error); |
41 } | 41 } |
42 | 42 |
43 class CopyOrMoveFileValidatorTestHelper { | 43 class CopyOrMoveFileValidatorTestHelper { |
44 public: | 44 public: |
45 CopyOrMoveFileValidatorTestHelper( | 45 CopyOrMoveFileValidatorTestHelper(const GURL& origin, |
46 const GURL& origin, | 46 fileapi::FileSystemType src_type, |
47 FileSystemType src_type, | 47 fileapi::FileSystemType dest_type) |
48 FileSystemType dest_type) | 48 : origin_(origin), src_type_(src_type), dest_type_(dest_type) {} |
49 : origin_(origin), | |
50 src_type_(src_type), | |
51 dest_type_(dest_type) {} | |
52 | 49 |
53 ~CopyOrMoveFileValidatorTestHelper() { | 50 ~CopyOrMoveFileValidatorTestHelper() { |
54 file_system_context_ = NULL; | 51 file_system_context_ = NULL; |
55 base::RunLoop().RunUntilIdle(); | 52 base::RunLoop().RunUntilIdle(); |
56 } | 53 } |
57 | 54 |
58 void SetUp() { | 55 void SetUp() { |
59 ASSERT_TRUE(base_.CreateUniqueTempDir()); | 56 ASSERT_TRUE(base_.CreateUniqueTempDir()); |
60 base::FilePath base_dir = base_.path(); | 57 base::FilePath base_dir = base_.path(); |
61 | 58 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 160 |
164 bool FileExists(const FileSystemURL& url, int64 expected_size) { | 161 bool FileExists(const FileSystemURL& url, int64 expected_size) { |
165 return AsyncFileTestHelper::FileExists( | 162 return AsyncFileTestHelper::FileExists( |
166 file_system_context_.get(), url, expected_size); | 163 file_system_context_.get(), url, expected_size); |
167 } | 164 } |
168 | 165 |
169 base::ScopedTempDir base_; | 166 base::ScopedTempDir base_; |
170 | 167 |
171 const GURL origin_; | 168 const GURL origin_; |
172 | 169 |
173 const FileSystemType src_type_; | 170 const fileapi::FileSystemType src_type_; |
174 const FileSystemType dest_type_; | 171 const fileapi::FileSystemType dest_type_; |
175 std::string src_fsid_; | 172 std::string src_fsid_; |
176 std::string dest_fsid_; | 173 std::string dest_fsid_; |
177 | 174 |
178 base::MessageLoop message_loop_; | 175 base::MessageLoop message_loop_; |
179 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 176 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
180 | 177 |
181 FileSystemURL copy_src_; | 178 FileSystemURL copy_src_; |
182 FileSystemURL copy_dest_; | 179 FileSystemURL copy_dest_; |
183 FileSystemURL move_src_; | 180 FileSystemURL move_src_; |
184 FileSystemURL move_dest_; | 181 FileSystemURL move_dest_; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 helper.SetUp(); | 320 helper.SetUp(); |
324 scoped_ptr<CopyOrMoveFileValidatorFactory> factory( | 321 scoped_ptr<CopyOrMoveFileValidatorFactory> factory( |
325 new TestCopyOrMoveFileValidatorFactory(POST_WRITE_INVALID)); | 322 new TestCopyOrMoveFileValidatorFactory(POST_WRITE_INVALID)); |
326 helper.SetMediaCopyOrMoveFileValidatorFactory(factory.Pass()); | 323 helper.SetMediaCopyOrMoveFileValidatorFactory(factory.Pass()); |
327 | 324 |
328 helper.CopyTest(base::File::FILE_ERROR_SECURITY); | 325 helper.CopyTest(base::File::FILE_ERROR_SECURITY); |
329 helper.MoveTest(base::File::FILE_ERROR_SECURITY); | 326 helper.MoveTest(base::File::FILE_ERROR_SECURITY); |
330 } | 327 } |
331 | 328 |
332 } // namespace content | 329 } // namespace content |
OLD | NEW |