• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
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 
12 namespace pp {
13 class FileIO;
14 class FileSystem;
15 }  // namespace pp
16 
17 class TestFileIO : public TestCase {
18  public:
TestFileIO(TestingInstance * instance)19   explicit TestFileIO(TestingInstance* instance) : TestCase(instance) {}
20 
21   // TestCase implementation.
22   virtual bool Init();
23   virtual void RunTests(const std::string& filter);
24 
25  private:
26   enum OpenExpectation {
27     CREATE_IF_DOESNT_EXIST = 1 << 0,
28     DONT_CREATE_IF_DOESNT_EXIST = 1 << 1,
29     OPEN_IF_EXISTS = 1 << 2,
30     DONT_OPEN_IF_EXISTS = 1 << 3,
31     TRUNCATE_IF_EXISTS = 1 << 4,
32     DONT_TRUNCATE_IF_EXISTS = 1 << 5,
33     // All values above are defined in pairs: <some_expectation> and
34     // DONT_<some_expectation>.
35     END_OF_OPEN_EXPECATION_PAIRS = DONT_TRUNCATE_IF_EXISTS,
36 
37     INVALID_FLAG_COMBINATION = 1 << 6,
38   };
39 
40   std::string TestOpen();
41   std::string TestOpenDirectory();
42   std::string TestReadWriteSetLength();
43   std::string TestReadToArrayWriteSetLength();
44   std::string TestTouchQuery();
45   std::string TestAbortCalls();
46   std::string TestParallelReads();
47   std::string TestParallelWrites();
48   std::string TestNotAllowMixedReadWrite();
49   std::string TestRequestOSFileHandle();
50   std::string TestRequestOSFileHandleWithOpenExclusive();
51   std::string TestMmap();
52 
53   // Helper method used by TestOpen().
54   // |expectations| is a combination of OpenExpectation values. The followings
55   // are considered as valid input:
56   // 1) INVALID_FLAG_COMBINATION
57   // 2) (DONT_)?CREATE_IF_DOESNT_EXIST | (DONT_)?OPEN_IF_EXISTS |
58   //    (DONT_)?TRUNCATE_IF_EXISTS
59   std::string MatchOpenExpectations(pp::FileSystem* file_system,
60                                     size_t open_flags,
61                                     size_t expectations);
62 };
63 
64 #endif  // PAPPI_TESTS_TEST_FILE_IO_H_
65