[email protected] | 39c99eaf | 2011-01-11 21:58:09 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef PAPPI_TESTS_TEST_FILE_IO_H_ |
| 6 | #define PAPPI_TESTS_TEST_FILE_IO_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "ppapi/tests/test_case.h" |
| 11 | |
[email protected] | b2f2308d | 2011-05-23 22:00:04 | [diff] [blame] | 12 | namespace pp { |
[email protected] | cc0eb0e | 2011-07-15 19:07:39 | [diff] [blame] | 13 | class FileSystem; |
[email protected] | b2f2308d | 2011-05-23 22:00:04 | [diff] [blame] | 14 | } // namespace pp |
| 15 | |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 16 | class TestFileIO : public TestCase { |
| 17 | public: |
| 18 | explicit TestFileIO(TestingInstance* instance) : TestCase(instance) {} |
| 19 | |
| 20 | // TestCase implementation. |
| 21 | virtual bool Init(); |
[email protected] | 2622d6b | 2011-11-16 04:28:02 | [diff] [blame] | 22 | virtual void RunTests(const std::string& filter); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 23 | |
| 24 | private: |
[email protected] | b2f2308d | 2011-05-23 22:00:04 | [diff] [blame] | 25 | enum OpenExpectation { |
| 26 | CREATE_IF_DOESNT_EXIST = 1 << 0, |
| 27 | DONT_CREATE_IF_DOESNT_EXIST = 1 << 1, |
| 28 | OPEN_IF_EXISTS = 1 << 2, |
| 29 | DONT_OPEN_IF_EXISTS = 1 << 3, |
| 30 | TRUNCATE_IF_EXISTS = 1 << 4, |
| 31 | DONT_TRUNCATE_IF_EXISTS = 1 << 5, |
| 32 | // All values above are defined in pairs: <some_expectation> and |
| 33 | // DONT_<some_expectation>. |
| 34 | END_OF_OPEN_EXPECATION_PAIRS = DONT_TRUNCATE_IF_EXISTS, |
| 35 | |
| 36 | INVALID_FLAG_COMBINATION = 1 << 6, |
| 37 | }; |
| 38 | |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 39 | std::string TestOpen(); |
| 40 | std::string TestReadWriteSetLength(); |
| 41 | std::string TestTouchQuery(); |
[email protected] | 39c99eaf | 2011-01-11 21:58:09 | [diff] [blame] | 42 | std::string TestAbortCalls(); |
[email protected] | dbb6fde1 | 2011-07-13 06:38:15 | [diff] [blame] | 43 | std::string TestParallelReads(); |
| 44 | std::string TestParallelWrites(); |
| 45 | std::string TestNotAllowMixedReadWrite(); |
[email protected] | 858e7754 | 2011-08-01 11:46:41 | [diff] [blame] | 46 | std::string TestWillWriteWillSetLength(); |
[email protected] | b2f2308d | 2011-05-23 22:00:04 | [diff] [blame] | 47 | |
| 48 | // Helper method used by TestOpen(). |
| 49 | // |expectations| is a combination of OpenExpectation values. The followings |
| 50 | // are considered as valid input: |
| 51 | // 1) INVALID_FLAG_COMBINATION |
| 52 | // 2) (DONT_)?CREATE_IF_DOESNT_EXIST | (DONT_)?OPEN_IF_EXISTS | |
| 53 | // (DONT_)?TRUNCATE_IF_EXISTS |
[email protected] | cc0eb0e | 2011-07-15 19:07:39 | [diff] [blame] | 54 | std::string MatchOpenExpectations(pp::FileSystem* file_system, |
[email protected] | b2f2308d | 2011-05-23 22:00:04 | [diff] [blame] | 55 | size_t open_flags, |
| 56 | size_t expectations); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | #endif // PAPPI_TESTS_TEST_FILE_IO_H_ |