OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_TEST_DATA_UTIL_H_ | 5 #ifndef MEDIA_BASE_TEST_DATA_UTIL_H_ |
6 #define MEDIA_BASE_TEST_DATA_UTIL_H_ | 6 #define MEDIA_BASE_TEST_DATA_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 class DecoderBuffer; | 18 class DecoderBuffer; |
19 | 19 |
20 // Returns a file path for a file in the media/test/data directory. | 20 // Returns a file path for a file in the media/test/data directory. |
21 base::FilePath GetTestDataFilePath(const std::string& name); | 21 base::FilePath GetTestDataFilePath(const std::string& name); |
22 | 22 |
23 // Returns relative path for test data folder: media/test/data. | 23 // Returns relative path for test data folder: media/test/data. |
24 base::FilePath GetTestDataPath(); | 24 base::FilePath GetTestDataPath(); |
25 | 25 |
| 26 // Returns a file path for a file in what name specified or media/test/data |
| 27 // directory. If the original file path is existed, returns it first. |
| 28 base::FilePath GetOriginalOrTestDataFilePath(const std::string& name); |
| 29 |
26 // Returns a string containing key value query params in the form of: | 30 // Returns a string containing key value query params in the form of: |
27 // "key_1=value_1&key_2=value2" | 31 // "key_1=value_1&key_2=value2" |
28 std::string GetURLQueryString(const base::StringPairs& query_params); | 32 std::string GetURLQueryString(const base::StringPairs& query_params); |
29 | 33 |
30 // Reads a test file from media/test/data directory and stores it in | 34 // Reads a test file from media/test/data directory and stores it in |
31 // a DecoderBuffer. Use DecoderBuffer vs DataBuffer to ensure no matter | 35 // a DecoderBuffer. Use DecoderBuffer vs DataBuffer to ensure no matter |
32 // what a test does, it's safe to use FFmpeg methods. | 36 // what a test does, it's safe to use FFmpeg methods. |
33 // | 37 // |
34 // |name| - The name of the file. | 38 // |name| - The name of the file. |
35 // |buffer| - The contents of the file. | 39 // |buffer| - The contents of the file. |
36 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name); | 40 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name); |
37 | 41 |
38 // If the provided |key_id| is that of a test key, returns true and fills the | 42 // If the provided |key_id| is that of a test key, returns true and fills the |
39 // |key|, otherwise returns false. If |allowRotation| is true, then other valid | 43 // |key|, otherwise returns false. If |allowRotation| is true, then other valid |
40 // values are obtained by rotating the original key_id and key. Two overloads | 44 // values are obtained by rotating the original key_id and key. Two overloads |
41 // are provided, one using vectors and one using strings. | 45 // are provided, one using vectors and one using strings. |
42 bool LookupTestKeyVector(const std::vector<uint8_t>& key_id, | 46 bool LookupTestKeyVector(const std::vector<uint8_t>& key_id, |
43 bool allowRotation, | 47 bool allowRotation, |
44 std::vector<uint8_t>* key); | 48 std::vector<uint8_t>* key); |
45 | 49 |
46 bool LookupTestKeyString(const std::string& key_id, | 50 bool LookupTestKeyString(const std::string& key_id, |
47 bool allowRotation, | 51 bool allowRotation, |
48 std::string* key); | 52 std::string* key); |
49 | 53 |
50 } // namespace media | 54 } // namespace media |
51 | 55 |
52 #endif // MEDIA_BASE_TEST_DATA_UTIL_H_ | 56 #endif // MEDIA_BASE_TEST_DATA_UTIL_H_ |
OLD | NEW |