| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_CDM_PPAPI_CDM_FILE_IO_TEST_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CDM_FILE_IO_TEST_H_ |
| 6 #define MEDIA_CDM_PPAPI_CDM_FILE_IO_TEST_H_ | 6 #define MEDIA_CDM_PPAPI_CDM_FILE_IO_TEST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <list> | 10 #include <list> |
| 9 #include <stack> | 11 #include <stack> |
| 10 #include <string> | 12 #include <string> |
| 11 #include <vector> | 13 #include <vector> |
| 12 | 14 |
| 13 #include "base/callback.h" | 15 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 15 #include "media/cdm/api/content_decryption_module.h" | 17 #include "media/cdm/api/content_decryption_module.h" |
| 16 | 18 |
| 17 namespace media { | 19 namespace media { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ACTION_CLOSE // If ACTION_CLOSE is not specified, FileIO::Close() will be | 61 ACTION_CLOSE // If ACTION_CLOSE is not specified, FileIO::Close() will be |
| 60 // automatically called at the end of the test. | 62 // automatically called at the end of the test. |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 FileIOTest(const CreateFileIOCB& create_file_io_cb, | 65 FileIOTest(const CreateFileIOCB& create_file_io_cb, |
| 64 const std::string& test_name); | 66 const std::string& test_name); |
| 65 ~FileIOTest() override; | 67 ~FileIOTest() override; |
| 66 | 68 |
| 67 // Adds a test step in this test. |this| object doesn't take the ownership of | 69 // Adds a test step in this test. |this| object doesn't take the ownership of |
| 68 // |data|, which should be valid throughout the lifetime of |this| object. | 70 // |data|, which should be valid throughout the lifetime of |this| object. |
| 69 void AddTestStep( | 71 void AddTestStep(StepType type, |
| 70 StepType type, Status status, const uint8* data, uint32 data_size); | 72 Status status, |
| 73 const uint8_t* data, |
| 74 uint32_t data_size); |
| 71 | 75 |
| 72 // Runs this test case and returns the test result through |completion_cb|. | 76 // Runs this test case and returns the test result through |completion_cb|. |
| 73 void Run(const CompletionCB& completion_cb); | 77 void Run(const CompletionCB& completion_cb); |
| 74 | 78 |
| 75 private: | 79 private: |
| 76 struct TestStep { | 80 struct TestStep { |
| 77 // |this| object doesn't take the ownership of |data|, which should be valid | 81 // |this| object doesn't take the ownership of |data|, which should be valid |
| 78 // throughout the lifetime of |this| object. | 82 // throughout the lifetime of |this| object. |
| 79 TestStep(StepType type, Status status, const uint8* data, uint32 data_size) | 83 TestStep(StepType type, |
| 84 Status status, |
| 85 const uint8_t* data, |
| 86 uint32_t data_size) |
| 80 : type(type), status(status), data(data), data_size(data_size) {} | 87 : type(type), status(status), data(data), data_size(data_size) {} |
| 81 | 88 |
| 82 StepType type; | 89 StepType type; |
| 83 | 90 |
| 84 // Expected status for RESULT* steps. | 91 // Expected status for RESULT* steps. |
| 85 Status status; | 92 Status status; |
| 86 | 93 |
| 87 // Data to write in ACTION_WRITE, or read data in RESULT_READ. | 94 // Data to write in ACTION_WRITE, or read data in RESULT_READ. |
| 88 const uint8* data; | 95 const uint8_t* data; |
| 89 uint32 data_size; | 96 uint32_t data_size; |
| 90 }; | 97 }; |
| 91 | 98 |
| 92 // Returns whether |test_step| is a RESULT_* step. | 99 // Returns whether |test_step| is a RESULT_* step. |
| 93 static bool IsResult(const TestStep& test_step); | 100 static bool IsResult(const TestStep& test_step); |
| 94 | 101 |
| 95 // Returns whether two results match. | 102 // Returns whether two results match. |
| 96 static bool MatchesResult(const TestStep& a, const TestStep& b); | 103 static bool MatchesResult(const TestStep& a, const TestStep& b); |
| 97 | 104 |
| 98 // cdm::FileIOClient implementation. | 105 // cdm::FileIOClient implementation. |
| 99 void OnOpenComplete(Status status) override; | 106 void OnOpenComplete(Status status) override; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // |completion_cb|. | 145 // |completion_cb|. |
| 139 void RunAllTests(const CompletionCB& completion_cb); | 146 void RunAllTests(const CompletionCB& completion_cb); |
| 140 | 147 |
| 141 private: | 148 private: |
| 142 void OnTestComplete(bool success); | 149 void OnTestComplete(bool success); |
| 143 void RunNextTest(); | 150 void RunNextTest(); |
| 144 | 151 |
| 145 CreateFileIOCB create_file_io_cb_; | 152 CreateFileIOCB create_file_io_cb_; |
| 146 CompletionCB completion_cb_; | 153 CompletionCB completion_cb_; |
| 147 std::list<FileIOTest> remaining_tests_; | 154 std::list<FileIOTest> remaining_tests_; |
| 148 std::vector<uint8> large_data_; | 155 std::vector<uint8_t> large_data_; |
| 149 size_t total_num_tests_; // Total number of tests. | 156 size_t total_num_tests_; // Total number of tests. |
| 150 size_t num_passed_tests_; // Number of passed tests. | 157 size_t num_passed_tests_; // Number of passed tests. |
| 151 | 158 |
| 152 DISALLOW_COPY_AND_ASSIGN (FileIOTestRunner); | 159 DISALLOW_COPY_AND_ASSIGN (FileIOTestRunner); |
| 153 }; | 160 }; |
| 154 | 161 |
| 155 } // namespace media | 162 } // namespace media |
| 156 | 163 |
| 157 #endif // MEDIA_CDM_PPAPI_CDM_FILE_IO_TEST_H_ | 164 #endif // MEDIA_CDM_PPAPI_CDM_FILE_IO_TEST_H_ |
| OLD | NEW |