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

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

Issue 15729007: Cleanup: Remove fileapi::FileSystemMountPointProvider::InitializeCopyOrMoveFileValidatorFactory() a… (Closed) Base URL: svn://chrome-svn/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"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateFile(move_src_, 10)); 74 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateFile(move_src_, 10));
75 75
76 ASSERT_TRUE(FileExists(copy_src_, 10)); 76 ASSERT_TRUE(FileExists(copy_src_, 10));
77 ASSERT_TRUE(FileExists(move_src_, 10)); 77 ASSERT_TRUE(FileExists(move_src_, 10));
78 ASSERT_FALSE(FileExists(copy_dest_, 10)); 78 ASSERT_FALSE(FileExists(copy_dest_, 10));
79 ASSERT_FALSE(FileExists(move_dest_, 10)); 79 ASSERT_FALSE(FileExists(move_dest_, 10));
80 } 80 }
81 81
82 void SetMediaCopyOrMoveFileValidatorFactory( 82 void SetMediaCopyOrMoveFileValidatorFactory(
83 scoped_ptr<CopyOrMoveFileValidatorFactory> factory) { 83 scoped_ptr<CopyOrMoveFileValidatorFactory> factory) {
84 FileSystemMountPointProvider* mount_point_provider = 84 TestMountPointProvider* provider = static_cast<TestMountPointProvider*>(
85 file_system_context_->GetMountPointProvider(kWithValidatorType); 85 file_system_context_->GetMountPointProvider(kWithValidatorType));
86 mount_point_provider->InitializeCopyOrMoveFileValidatorFactory( 86 provider->InitializeCopyOrMoveFileValidatorFactory(factory.Pass());
87 kWithValidatorType, factory.Pass());
88 } 87 }
89 88
90 void CopyTest(base::PlatformFileError expected) { 89 void CopyTest(base::PlatformFileError expected) {
91 ASSERT_TRUE(FileExists(copy_src_, 10)); 90 ASSERT_TRUE(FileExists(copy_src_, 10));
92 ASSERT_FALSE(FileExists(copy_dest_, 10)); 91 ASSERT_FALSE(FileExists(copy_dest_, 10));
93 92
94 EXPECT_EQ(expected, 93 EXPECT_EQ(expected,
95 AsyncFileTestHelper::Copy(file_system_context_, copy_src_, 94 AsyncFileTestHelper::Copy(file_system_context_, copy_src_,
96 copy_dest_)); 95 copy_dest_));
97 96
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 FileSystemURL move_src_; 165 FileSystemURL move_src_;
167 FileSystemURL move_dest_; 166 FileSystemURL move_dest_;
168 167
169 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveFileValidatorTestHelper); 168 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveFileValidatorTestHelper);
170 }; 169 };
171 170
172 class TestCopyOrMoveFileValidatorFactory 171 class TestCopyOrMoveFileValidatorFactory
173 : public CopyOrMoveFileValidatorFactory { 172 : public CopyOrMoveFileValidatorFactory {
174 public: 173 public:
175 // A factory that creates validators that accept everything or nothing. 174 // A factory that creates validators that accept everything or nothing.
176 TestCopyOrMoveFileValidatorFactory(bool all_valid) : all_valid_(all_valid) {} 175 explicit TestCopyOrMoveFileValidatorFactory(bool all_valid)
176 : all_valid_(all_valid) {}
177 virtual ~TestCopyOrMoveFileValidatorFactory() {} 177 virtual ~TestCopyOrMoveFileValidatorFactory() {}
178 178
179 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator( 179 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
180 const FileSystemURL& /*src_url*/, 180 const FileSystemURL& /*src_url*/,
181 const base::FilePath& /*platform_path*/) OVERRIDE { 181 const base::FilePath& /*platform_path*/) OVERRIDE {
182 return new TestCopyOrMoveFileValidator(all_valid_); 182 return new TestCopyOrMoveFileValidator(all_valid_);
183 } 183 }
184 184
185 private: 185 private:
186 class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator { 186 class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator {
187 public: 187 public:
188 TestCopyOrMoveFileValidator(bool all_valid) 188 explicit TestCopyOrMoveFileValidator(bool all_valid)
189 : result_(all_valid ? base::PLATFORM_FILE_OK 189 : result_(all_valid ? base::PLATFORM_FILE_OK
190 : base::PLATFORM_FILE_ERROR_SECURITY) { 190 : base::PLATFORM_FILE_ERROR_SECURITY) {
191 } 191 }
192 virtual ~TestCopyOrMoveFileValidator() {} 192 virtual ~TestCopyOrMoveFileValidator() {}
193 193
194 virtual void StartValidation( 194 virtual void StartValidation(
195 const ResultCallback& result_callback) OVERRIDE { 195 const ResultCallback& result_callback) OVERRIDE {
196 // Post the result since a real validator must do work asynchronously. 196 // Post the result since a real validator must do work asynchronously.
197 base::MessageLoop::current()->PostTask( 197 base::MessageLoop::current()->PostTask(
198 FROM_HERE, base::Bind(result_callback, result_)); 198 FROM_HERE, base::Bind(result_callback, result_));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 271
272 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( 272 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory(
273 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); 273 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/));
274 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); 274 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass());
275 275
276 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); 276 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY);
277 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); 277 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY);
278 } 278 }
279 279
280 } // namespace fileapi 280 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698