OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Native Client 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 #ifndef NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_COMMON_H_ |
| 5 #define NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_COMMON_H_ |
| 6 |
| 7 #include <deque> |
| 8 |
| 9 #include "native_client/src/third_party/ppapi/c/pp_file_info.h" |
| 10 #include "native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h" |
| 11 #include "native_client/tests/ppapi_test_lib/test_interface.h" |
| 12 |
| 13 namespace common { |
| 14 |
| 15 extern const char* kTestData; |
| 16 |
| 17 // Open file for subsequent tests. |
| 18 class OpenFileForTest : public TestSequenceElement { |
| 19 public: |
| 20 OpenFileForTest() |
| 21 : TestSequenceElement("OpenFileForTest") {} |
| 22 |
| 23 private: |
| 24 virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction( |
| 25 TestCallbackData* callback_data); |
| 26 }; |
| 27 |
| 28 // Initializes the member data of given file info to either known values, (e.g. |
| 29 // file system type), or dummy values (e.g. last modified time). |
| 30 void InitFileInfo(PP_FileSystemType system_type, PP_FileInfo* file_info); |
| 31 |
| 32 // TODO(sanga): Move this to file_io_tester.h |
| 33 // FileIOTester is the test runner. Used to accrue a sequence of test elements |
| 34 // in a specific order and run the sequence. |
| 35 class FileIOTester { |
| 36 public: |
| 37 explicit FileIOTester(const PP_FileInfo& file_info) |
| 38 : file_info_(file_info) {} |
| 39 ~FileIOTester() {} |
| 40 |
| 41 void AddSequenceElement(TestSequenceElement* element); // sink |
| 42 void Run(); |
| 43 |
| 44 private: |
| 45 // Callbacks for setting up before executing the test sequence. |
| 46 static void FlushFileForSetupCallback(void* data, int32_t result); |
| 47 static void OpenFileForSetupCallback(void* data, int32_t result); |
| 48 static void OpenFileSystemForSetupCallback(void* data, int32_t result); |
| 49 static void StartTestSequence(TestCallbackData* callback_data); |
| 50 static void TouchFileForSetupCallback(void* data, int32_t result); |
| 51 static void WriteFileForSetupCallback(void* data, int32_t result); |
| 52 |
| 53 const PP_FileInfo file_info_; |
| 54 std::deque<TestSequenceElement*> test_sequence_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(FileIOTester); |
| 57 }; |
| 58 |
| 59 } // namespace common |
| 60 |
| 61 #endif // NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_COMMON_H_ |
OLD | NEW |