Chromium Code Reviews| Index: webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc |
| diff --git a/webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc b/webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc |
| index 1190f7aaa31d5892c6eb6eea59d7f1eb9426ff88..5edd761f760986756c60df7afcba07297e8875be 100644 |
| --- a/webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc |
| +++ b/webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc |
| @@ -183,28 +183,35 @@ class CopyOrMoveFileValidatorTestHelper { |
| class TestCopyOrMoveFileValidatorFactory |
| : public CopyOrMoveFileValidatorFactory { |
| public: |
| + enum Validity { |
| + VALID, |
| + INVALID, |
| + POST_WRITE_INVALID |
| + }; |
| + |
| // A factory that creates validators that accept everything or nothing. |
| - explicit TestCopyOrMoveFileValidatorFactory(bool all_valid, |
| - bool all_valid_write) |
| - : all_valid_(all_valid), |
| - all_valid_write_(all_valid_write) {} |
| + // TODO(gbillock): switch args to enum or something |
| + explicit TestCopyOrMoveFileValidatorFactory(Validity validity) |
| + : validity_(validity) {} |
| virtual ~TestCopyOrMoveFileValidatorFactory() {} |
| virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator( |
| const FileSystemURL& /*src_url*/, |
| const base::FilePath& /*platform_path*/) OVERRIDE { |
| - return new TestCopyOrMoveFileValidator(all_valid_, all_valid_write_); |
| + return new TestCopyOrMoveFileValidator(validity_); |
| } |
| private: |
| class TestCopyOrMoveFileValidator : public CopyOrMoveFileValidator { |
| public: |
| - explicit TestCopyOrMoveFileValidator(bool pre_copy_valid, |
| - bool post_copy_valid) |
| - : result_(pre_copy_valid ? base::PLATFORM_FILE_OK |
| - : base::PLATFORM_FILE_ERROR_SECURITY), |
| - write_result_(post_copy_valid ? base::PLATFORM_FILE_OK |
| - : base::PLATFORM_FILE_ERROR_SECURITY) { |
| + explicit TestCopyOrMoveFileValidator( |
| + TestCopyOrMoveFileValidatorFactory::Validity validity) |
| + : result_(validity == VALID || validity == POST_WRITE_INVALID |
| + ? base::PLATFORM_FILE_OK |
| + : base::PLATFORM_FILE_ERROR_SECURITY), |
| + write_result_(validity == VALID |
|
vandebo (ex-Chrome)
2013/07/31 20:27:57
nit: I think write_result_ should be OK when valid
Greg Billock
2013/07/31 21:57:58
Done. I think that makes the other names better, s
|
| + ? base::PLATFORM_FILE_OK |
| + : base::PLATFORM_FILE_ERROR_SECURITY) { |
| } |
| virtual ~TestCopyOrMoveFileValidator() {} |
| @@ -230,8 +237,7 @@ class TestCopyOrMoveFileValidatorFactory |
| DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidator); |
| }; |
| - bool all_valid_; |
| - bool all_valid_write_; |
| + Validity validity_; |
| DISALLOW_COPY_AND_ASSIGN(TestCopyOrMoveFileValidatorFactory); |
| }; |
| @@ -266,7 +272,8 @@ TEST(CopyOrMoveFileValidatorTest, AcceptAll) { |
| kWithValidatorType); |
| helper.SetUp(); |
| scoped_ptr<CopyOrMoveFileValidatorFactory> factory( |
| - new TestCopyOrMoveFileValidatorFactory(true, true /*accept_all*/)); |
| + new TestCopyOrMoveFileValidatorFactory( |
| + TestCopyOrMoveFileValidatorFactory::VALID)); |
| helper.SetMediaCopyOrMoveFileValidatorFactory(factory.Pass()); |
| helper.CopyTest(base::PLATFORM_FILE_OK); |
| @@ -279,7 +286,8 @@ TEST(CopyOrMoveFileValidatorTest, AcceptNone) { |
| kWithValidatorType); |
| helper.SetUp(); |
| scoped_ptr<CopyOrMoveFileValidatorFactory> factory( |
| - new TestCopyOrMoveFileValidatorFactory(false, false /*accept_all*/)); |
| + new TestCopyOrMoveFileValidatorFactory( |
| + TestCopyOrMoveFileValidatorFactory::INVALID)); |
| helper.SetMediaCopyOrMoveFileValidatorFactory(factory.Pass()); |
| helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |
| @@ -293,11 +301,13 @@ TEST(CopyOrMoveFileValidatorTest, OverrideValidator) { |
| kWithValidatorType); |
| helper.SetUp(); |
| scoped_ptr<CopyOrMoveFileValidatorFactory> reject_factory( |
| - new TestCopyOrMoveFileValidatorFactory(false, false /*accept_all*/)); |
| + new TestCopyOrMoveFileValidatorFactory( |
| + TestCopyOrMoveFileValidatorFactory::INVALID)); |
| helper.SetMediaCopyOrMoveFileValidatorFactory(reject_factory.Pass()); |
| scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( |
| - new TestCopyOrMoveFileValidatorFactory(true, true /*accept_all*/)); |
| + new TestCopyOrMoveFileValidatorFactory( |
| + TestCopyOrMoveFileValidatorFactory::VALID)); |
| helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); |
| helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |
| @@ -310,8 +320,8 @@ TEST(CopyOrMoveFileValidatorTest, RejectPostWrite) { |
| kWithValidatorType); |
| helper.SetUp(); |
| scoped_ptr<CopyOrMoveFileValidatorFactory> factory( |
| - // accept pre-copy, reject post-copy |
| - new TestCopyOrMoveFileValidatorFactory(true, false)); |
| + new TestCopyOrMoveFileValidatorFactory( |
| + TestCopyOrMoveFileValidatorFactory::POST_WRITE_INVALID)); |
| helper.SetMediaCopyOrMoveFileValidatorFactory(factory.Pass()); |
| helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |