Skip to content

Commit 7688bd7

Browse files
committed
Add two missing case for standard path type
1 parent a907561 commit 7688bd7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/lib/fcitx-utils/standardpaths_p.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class StandardPathsPrivate {
5252
return pkgdataDirs_;
5353
case StandardPathsType::Addon:
5454
return addonDirs_;
55+
case StandardPathsType::Cache:
56+
return cacheDir_;
57+
case StandardPathsType::Runtime:
58+
return runtimeDir_;
5559
default:
5660
return constEmptyPaths;
5761
}

test/teststandardpaths_unix.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ void test_basic() {
2626
"/TEST/PATH1/:/TEST/PATH2:/TEST/PATH2/:/TEST/PATH1");
2727
setEnvironment("XDG_DATA_HOME", "/TEST//PATH");
2828
setEnvironment("XDG_DATA_DIRS", TEST_ADDON_DIR);
29+
setEnvironment("XDG_CACHE_HOME", "/CACHE/PATH");
30+
setEnvironment("XDG_RUNTIME_DIR", "/RUNTIME/PATH");
2931
StandardPaths standardPaths("fcitx5", {},
3032
StandardPathsOption::SkipBuiltInPath);
3133

3234
FCITX_ASSERT(standardPaths.userDirectory(StandardPathsType::Config) ==
3335
"/TEST/PATH");
36+
FCITX_ASSERT(standardPaths.userDirectory(StandardPathsType::Runtime) ==
37+
"/RUNTIME/PATH");
38+
FCITX_ASSERT(standardPaths.userDirectory(StandardPathsType::Cache) ==
39+
"/CACHE/PATH");
3440
// The order to the path should be kept for their first appearance.
3541
FCITX_ASSERT(
3642
std::ranges::equal(standardPaths.directories(StandardPathsType::Config),
@@ -108,10 +114,15 @@ void test_nouser() {
108114
setEnvironment("XDG_CONFIG_DIRS", "/TEST/PATH1:/TEST/PATH2");
109115
setEnvironment("XDG_DATA_HOME", "/TEST//PATH");
110116
setEnvironment("XDG_DATA_DIRS", TEST_ADDON_DIR);
117+
setEnvironment("XDG_CACHE_HOME", "/CACHE/PATH");
118+
setEnvironment("XDG_RUNTIME_DIR", "/RUNTIME/PATH");
111119
StandardPaths standardPaths(
112120
"fcitx5", {},
113121
StandardPathsOptions{StandardPathsOption::SkipUserPath,
114122
StandardPathsOption::SkipBuiltInPath});
123+
FCITX_ASSERT(
124+
standardPaths.userDirectory(StandardPathsType::Runtime).empty());
125+
FCITX_ASSERT(standardPaths.userDirectory(StandardPathsType::Cache).empty());
115126

116127
std::filesystem::path path;
117128
auto file =

0 commit comments

Comments
 (0)