Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc

Issue 15959006: Deprecate FileSystemMountPointProvider::GetFileSystemRootPathOnFileThread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/browser/fileapi/async_file_test_helper.h" 11 #include "webkit/browser/fileapi/async_file_test_helper.h"
12 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" 12 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
13 #include "webkit/browser/fileapi/external_mount_points.h" 13 #include "webkit/browser/fileapi/external_mount_points.h"
14 #include "webkit/browser/fileapi/file_system_context.h" 14 #include "webkit/browser/fileapi/file_system_context.h"
15 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" 15 #include "webkit/browser/fileapi/file_system_mount_point_provider.h"
16 #include "webkit/browser/fileapi/file_system_url.h" 16 #include "webkit/browser/fileapi/file_system_url.h"
17 #include "webkit/browser/fileapi/isolated_context.h" 17 #include "webkit/browser/fileapi/isolated_context.h"
18 #include "webkit/browser/fileapi/mock_file_system_context.h" 18 #include "webkit/browser/fileapi/mock_file_system_context.h"
19 #include "webkit/browser/fileapi/test_mount_point_provider.h" 19 #include "webkit/browser/fileapi/test_mount_point_provider.h"
20 #include "webkit/common/fileapi/file_system_util.h" 20 #include "webkit/common/fileapi/file_system_util.h"
21 #include "webkit/quota/mock_special_storage_policy.h" 21 #include "webkit/quota/mock_special_storage_policy.h"
22 22
23 namespace fileapi { 23 namespace fileapi {
24 24
25 namespace { 25 namespace {
26 26
27 const FileSystemType kNoValidatorType = kFileSystemTypeTemporary; 27 const FileSystemType kNoValidatorType = kFileSystemTypeTemporary;
28 const FileSystemType kWithValidatorType = kFileSystemTypeTest; 28 const FileSystemType kWithValidatorType = kFileSystemTypeTest;
29 29
30 void ExpectOk(base::PlatformFileError error) {
31 ASSERT_EQ(base::PLATFORM_FILE_OK, error);
32 }
33
30 class CopyOrMoveFileValidatorTestHelper { 34 class CopyOrMoveFileValidatorTestHelper {
31 public: 35 public:
32 CopyOrMoveFileValidatorTestHelper( 36 CopyOrMoveFileValidatorTestHelper(
33 const GURL& origin, 37 const GURL& origin,
34 FileSystemType src_type, 38 FileSystemType src_type,
35 FileSystemType dest_type) 39 FileSystemType dest_type)
36 : origin_(origin), 40 : origin_(origin),
37 src_type_(src_type), 41 src_type_(src_type),
38 dest_type_(dest_type) {} 42 dest_type_(dest_type) {}
39 43
(...skipping 10 matching lines...) Expand all
50 54
51 // Set up TestMountPointProvider to require CopyOrMoveFileValidator. 55 // Set up TestMountPointProvider to require CopyOrMoveFileValidator.
52 FileSystemMountPointProvider* test_mount_point_provider = 56 FileSystemMountPointProvider* test_mount_point_provider =
53 file_system_context_->GetMountPointProvider(kWithValidatorType); 57 file_system_context_->GetMountPointProvider(kWithValidatorType);
54 static_cast<TestMountPointProvider*>(test_mount_point_provider)-> 58 static_cast<TestMountPointProvider*>(test_mount_point_provider)->
55 set_require_copy_or_move_validator(true); 59 set_require_copy_or_move_validator(true);
56 60
57 // Sets up source. 61 // Sets up source.
58 FileSystemMountPointProvider* src_mount_point_provider = 62 FileSystemMountPointProvider* src_mount_point_provider =
59 file_system_context_->GetMountPointProvider(src_type_); 63 file_system_context_->GetMountPointProvider(src_type_);
60 src_mount_point_provider->GetFileSystemRootPathOnFileThread( 64 src_mount_point_provider->ValidateFileSystemRoot(
61 SourceURL(std::string()), true /* create */); 65 origin_, src_type_, true /* create */, base::Bind(&ExpectOk));
66 base::MessageLoop::current()->RunUntilIdle();
62 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(SourceURL(""))); 67 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(SourceURL("")));
63 68
64 // Sets up dest. 69 // Sets up dest.
65 DCHECK_EQ(kWithValidatorType, dest_type_); 70 DCHECK_EQ(kWithValidatorType, dest_type_);
66 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(DestURL(""))); 71 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(DestURL("")));
67 72
68 copy_src_ = SourceURL("copy_src.jpg"); 73 copy_src_ = SourceURL("copy_src.jpg");
69 move_src_ = SourceURL("move_src.jpg"); 74 move_src_ = SourceURL("move_src.jpg");
70 copy_dest_ = DestURL("copy_dest.jpg"); 75 copy_dest_ = DestURL("copy_dest.jpg");
71 move_dest_ = DestURL("move_dest.jpg"); 76 move_dest_ = DestURL("move_dest.jpg");
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 276
272 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( 277 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory(
273 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); 278 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/));
274 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); 279 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass());
275 280
276 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); 281 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY);
277 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); 282 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY);
278 } 283 }
279 284
280 } // namespace fileapi 285 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698