blob: b971105a9fca7a14dbaa8e3422735ff3f9f40256 [file] [log] [blame]
[email protected]39c99eaf2011-01-11 21:58:091// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]1758e882010-11-01 16:16:502// 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]b2f2308d2011-05-23 22:00:0412namespace pp {
[email protected]cc0eb0e2011-07-15 19:07:3913class FileSystem;
[email protected]b2f2308d2011-05-23 22:00:0414} // namespace pp
15
[email protected]1758e882010-11-01 16:16:5016class TestFileIO : public TestCase {
17 public:
18 explicit TestFileIO(TestingInstance* instance) : TestCase(instance) {}
19
20 // TestCase implementation.
21 virtual bool Init();
[email protected]2622d6b2011-11-16 04:28:0222 virtual void RunTests(const std::string& filter);
[email protected]1758e882010-11-01 16:16:5023
24 private:
[email protected]b2f2308d2011-05-23 22:00:0425 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]1758e882010-11-01 16:16:5039 std::string TestOpen();
40 std::string TestReadWriteSetLength();
41 std::string TestTouchQuery();
[email protected]39c99eaf2011-01-11 21:58:0942 std::string TestAbortCalls();
[email protected]dbb6fde12011-07-13 06:38:1543 std::string TestParallelReads();
44 std::string TestParallelWrites();
45 std::string TestNotAllowMixedReadWrite();
[email protected]858e77542011-08-01 11:46:4146 std::string TestWillWriteWillSetLength();
[email protected]b2f2308d2011-05-23 22:00:0447
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]cc0eb0e2011-07-15 19:07:3954 std::string MatchOpenExpectations(pp::FileSystem* file_system,
[email protected]b2f2308d2011-05-23 22:00:0455 size_t open_flags,
56 size_t expectations);
[email protected]1758e882010-11-01 16:16:5057};
58
59#endif // PAPPI_TESTS_TEST_FILE_IO_H_