| 1 |
/* |
| 2 |
* Copyright 2023 Google LLC |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef RasterTestData_DEFINED |
| 9 |
#define RasterTestData_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkString.h" |
| 12 |
#include "modules/jsonreader/SkJSONReader.h" |
| 13 |
|
| 14 |
#include <regex> |
| 15 |
#include <string> |
| 16 |
|
| 17 |
// Iterates over test data from the font tests CIPD, allows filtering for fonts and test samples |
| 18 |
// languages using C++ regular expressions. |
| 19 |
class TestFontDataProvider { |
| 20 |
public: |
| 21 |
struct LangSample { |
| 22 |
SkString langTag; |
| 23 |
SkString sampleShort; |
| 24 |
SkString sampleLong; |
| 25 |
}; |
| 26 |
|
| 27 |
struct TestSet { |
| 28 |
SkString fontName; |
| 29 |
SkString fontFilename; |
| 30 |
std::vector<LangSample> langSamples; |
| 31 |
}; |
| 32 |
|
| 33 |
TestFontDataProvider(const std::string& fontFilterRegexp, const std::string& langFilterRegexp); |
| 34 |
|
| 35 |
bool next(TestSet* testSet); |
| 36 |
|
| 37 |
void rewind(); |
| 38 |
|
| 39 |
private: |
| 40 |
std::vector<LangSample> getLanguageSamples(const skjson::ArrayValue* languages); |
| 41 |
std::regex fFontFilter; |
| 42 |
std::regex fLangFilter; |
| 43 |
size_t fFontsIndex = 0; |
| 44 |
std::unique_ptr<skjson::DOM> fJsonDom; |
| 45 |
const skjson::ArrayValue* fFonts = nullptr; |
| 46 |
const skjson::ObjectValue* fSamples = nullptr; |
| 47 |
}; |
| 48 |
|
| 49 |
namespace skiatest { |
| 50 |
|
| 51 |
/** |
| 52 |
* Set font test data directory. Overrides the location of the extracted googlefonts_testdata CIPD |
| 53 |
* archive. |
| 54 |
*/ |
| 55 |
void SetFontTestDataDirectory(); |
| 56 |
|
| 57 |
} // namespace skiatest |
| 58 |
|
| 59 |
#endif |