// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_FILE_IO_TEST_H_ #define MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_FILE_IO_TEST_H_ #include <stddef.h> #include <stdint.h> #include <list> #include <memory> #include <string> #include <vector> #include "base/compiler_specific.h" #include "base/containers/stack.h" #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "media/cdm/api/content_decryption_module.h" namespace media { CompletionCB; CreateFileIOCB; // A customizable test class that tests cdm::FileIO implementation. // - To create a test, call AddTestStep() to add a test step. A test step can be // either an action to make (use ACTION_* types), or a result to verify (use // RESULT_* types). // - To run the test, simply call Run() with a completion callback. The result // will be reported in the completion callback when the test is finished. // // The following rules apply to the test steps: // - Test steps are ordered (with the exception that results in a result group // is not ordered). // - Consecutive action steps form an "action group". Consecutively result // steps form a "result group". An action group is followed by a result // group and vice versa. // - A test must start with an action group. // - To process an action group, the test runner runs (and clears) all steps // in the group in the order they were added. Then it waits for test // results. // - When a cdm::FileIOClient method is called, the test runner compares the // result with all results in the current result group. If no result in that // group matches the test result, the test fails. Otherwise, the matching // result is cleared from the group. If the group is empty, the test runner // starts to process the next action group. Otherwise, the test runner keeps // waiting for the next test result. // - After all steps are cleared, the test passes. class FileIOTest : public cdm::FileIOClient { … }; // Tests cdm::FileIO implementation. class FileIOTestRunner { … }; } // namespace media #endif // MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_FILE_IO_TEST_H_