11 #include <unordered_map> 16 #include "standardpaths_p.h" 22 const std::vector<std::string> &addonDirs,
23 const std::vector<std::string> &dataDirs) {
24 std::vector<std::filesystem::path> addonDirsPath;
25 addonDirsPath.assign(addonDirs.begin(), addonDirs.end());
26 std::vector<std::filesystem::path> dataDirsPath;
27 dataDirsPath.assign(dataDirs.begin(), dataDirs.end());
28 setupTestingEnvironmentPath(std::filesystem::path(testBinaryDir),
29 addonDirsPath, dataDirsPath);
32 void setupTestingEnvironmentPath(
33 const std::filesystem::path &testBinaryDir,
34 const std::vector<std::filesystem::path> &addonDirs,
35 const std::vector<std::filesystem::path> &dataDirs) {
38 std::vector<std::filesystem::path> fullAddonDirs;
39 for (
const auto &addonDir : addonDirs) {
40 if (addonDir.empty()) {
43 if (addonDir.is_absolute()) {
44 fullAddonDirs.push_back(addonDir);
46 fullAddonDirs.push_back(testBinaryDir / addonDir);
53 std::vector<std::filesystem::path> fullDataDirs;
54 for (
const auto &dataDir : dataDirs) {
55 if (dataDir.empty()) {
58 if (dataDir.is_absolute()) {
59 fullDataDirs.push_back(dataDir);
61 fullDataDirs.push_back(testBinaryDir / dataDir);
69 setEnvironment(
"SKIP_FCITX_PATH",
"1");
70 setEnvironment(
"SKIP_FCITX_USER_PATH",
"1");
75 std::views::transform([](
const auto &path) {
81 setEnvironment(
"FCITX_DATA_HOME",
"/Invalid/Path");
83 setEnvironment(
"FCITX_CONFIG_HOME",
"/Invalid/Path");
87 std::views::transform([](
const auto &path) {
94 StandardPathsPrivate::setGlobal(std::make_unique<StandardPaths>(
96 std::unordered_map<std::string, std::vector<std::filesystem::path>>{
97 {
"pkgdatadir", fullDataDirs},
98 {
"addondir", fullAddonDirs},
101 StandardPathsOption::SkipUserPath,
102 StandardPathsOption::SkipSystemPath,
New Utility classes to handle application specific path.
void setupTestingEnvironment(const std::string &testBinaryDir, const std::vector< std::string > &addonDirs, const std::vector< std::string > &dataDirs)
Set corresponding environment variable to make sure fcitx can be run properly for testing...
Utility functions for testing.
Class provides bit flag support for Enum.
static std::filesystem::path fcitxPath(const char *path, const std::filesystem::path &subPath={})
Return fcitx specific path defined at compile time.
std::string join(Iter start, Iter end, T &&delim)
Join a range of string with delim.