Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f49d663

Browse filesBrowse files
committed
Extend icon deployment tests with a PNG icon
test_appdir: check whether the added 16x16 PNG icon (an export from simple_icon.svg) is actually deployed to the 16x16 location (the non-SVG branch in AppDir wasn't covered with a test before). test_linuxdeploy: since this test doesn't involve looking into the actual icon dimensions, the same icon is deployed as 32x32 and 128x128, in order to test the majority of the icon selection algorithm.
1 parent 191de4b commit f49d663
Copy full SHA for f49d663

4 files changed

+20-8Lines changed: 20 additions & 8 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/core/CMakeLists.txt‎

Copy file name to clipboardExpand all lines: tests/core/CMakeLists.txt
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ target_compile_definitions(test_appdir PRIVATE
77
-DSIMPLE_LIBRARY_PATH="$<TARGET_FILE:simple_library>"
88
-DSIMPLE_EXECUTABLE_PATH="$<TARGET_FILE:simple_executable>"
99
-DSIMPLE_DESKTOP_ENTRY_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_app.desktop"
10-
-DSIMPLE_ICON_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_icon.svg"
10+
-DSIMPLE_PNG_ICON_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_icon.png"
11+
-DSIMPLE_SVG_ICON_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_icon.svg"
1112
-DSIMPLE_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_file.txt"
1213
)
1314

@@ -27,7 +28,7 @@ target_compile_definitions(test_linuxdeploy PRIVATE
2728
-DSIMPLE_LIBRARY_PATH="$<TARGET_FILE:simple_library>"
2829
-DSIMPLE_EXECUTABLE_PATH="$<TARGET_FILE:simple_executable>"
2930
-DSIMPLE_DESKTOP_ENTRY_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_app.desktop"
30-
-DSIMPLE_ICON_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_icon.svg"
31+
-DSIMPLE_ICON_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_icon.png"
3132
-DSIMPLE_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/../data/simple_file.txt"
3233
)
3334

Collapse file

‎tests/core/test_appdir.cpp‎

Copy file name to clipboardExpand all lines: tests/core/test_appdir.cpp
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ namespace AppDirTest {
100100

101101

102102
TEST_F(AppDirUnitTestsFixture, deployIcon) {
103-
appDir.deployIcon(SIMPLE_ICON_PATH);
103+
appDir.deployIcon(SIMPLE_PNG_ICON_PATH);
104+
appDir.deployIcon(SIMPLE_SVG_ICON_PATH);
104105
appDir.executeDeferredOperations();
105106

106-
ASSERT_TRUE(is_regular_file(tmpAppDir / "usr/share/icons/hicolor/scalable/apps" / path(SIMPLE_ICON_PATH).filename()));
107+
ASSERT_TRUE(is_regular_file(tmpAppDir / "usr/share/icons/hicolor/16x16/apps" / path(SIMPLE_PNG_ICON_PATH).filename()));
108+
ASSERT_TRUE(is_regular_file(tmpAppDir / "usr/share/icons/hicolor/scalable/apps" / path(SIMPLE_SVG_ICON_PATH).filename()));
107109
}
108110

109111
TEST_F(AppDirUnitTestsFixture, deployFileToDirectory) {
Collapse file

‎tests/core/test_linuxdeploy.cpp‎

Copy file name to clipboardExpand all lines: tests/core/test_linuxdeploy.cpp
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace LinuxDeployTest {
1717
bf::path target_desktop_path;
1818

1919
bf::path source_icon_path;
20-
bf::path target_icon_path;
20+
std::vector<bf::path> target_icon_paths;
2121

2222
bf::path source_apprun_path;
2323
bf::path target_apprun_path;
@@ -30,7 +30,13 @@ namespace LinuxDeployTest {
3030
source_desktop_path = SIMPLE_DESKTOP_ENTRY_PATH;
3131
target_desktop_path = tmpAppDir / "usr/share/applications" / source_desktop_path.filename();
3232
source_icon_path = SIMPLE_ICON_PATH;
33-
target_icon_path = tmpAppDir / "usr/share/icons/hicolor/scalable/apps" / source_icon_path.filename();
33+
if (source_icon_path.extension() == ".svg") {
34+
target_icon_paths.push_back(tmpAppDir / "usr/share/icons/hicolor/scalable/apps" / source_icon_path.filename());
35+
} else {
36+
target_icon_paths.push_back(tmpAppDir / "usr/share/icons/hicolor/32x32/apps" / source_icon_path.filename());
37+
target_icon_paths.push_back(tmpAppDir / "usr/share/icons/hicolor/128x128/apps" / source_icon_path.filename());
38+
target_icon_paths.push_back(tmpAppDir / "usr/share/pixmaps" / source_icon_path.filename());
39+
}
3440
source_apprun_path = SIMPLE_FILE_PATH;
3541
target_apprun_path = tmpAppDir / "AppRun";
3642

@@ -70,8 +76,11 @@ namespace LinuxDeployTest {
7076
}
7177

7278
void add_icon() const {
73-
create_directories(target_icon_path.parent_path());
74-
copy_file(source_icon_path, target_icon_path);
79+
for (const auto &target_icon_path : target_icon_paths) {
80+
create_directories(target_icon_path.parent_path());
81+
// NB: In case of PNG, the same icon is installed to all paths
82+
copy_file(source_icon_path, target_icon_path);
83+
}
7584
}
7685

7786
void add_apprun() const {
Collapse file

‎tests/data/simple_icon.png‎

Copy file name to clipboard
102 Bytes
  • Display the source diff
  • Display the rich diff
Loading

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.