Skip to content

Commit 7936cb3

Browse files
test: add screenshots (#86)
Co-authored-by: Thomas Van Laere <4990509+thomvanl@users.noreply.github.com>
1 parent 7ce2adc commit 7936cb3

13 files changed

Lines changed: 1391 additions & 103 deletions

.github/copilot-instructions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
On Windows we use msys2 and ucrt64 to compile.
2+
You need to prefix commands with `C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 -c`.
3+
4+
Prefix build directories with `cmake-build-`.
5+
6+
The test executable is named `test_tray` and will be located inside the `tests` directory within
7+
the build directory.
8+
9+
The project uses gtest as a test framework.
10+
11+
Always follow the style guidelines defined in .clang-format for c/c++ code.

.github/workflows/ci.yml

Lines changed: 95 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ jobs:
2929
shell: "bash"
3030
- os: ubuntu-latest
3131
appindicator: "libayatana-appindicator3-dev"
32+
appindicator_type: "ayatana"
3233
shell: "bash"
3334
- os: ubuntu-latest
3435
appindicator: "libappindicator3-dev"
36+
appindicator_type: "legacy"
3537
shell: "bash"
3638
- os: windows-latest
3739
shell: "msys2 {0}"
@@ -49,11 +51,19 @@ jobs:
4951
build-essential \
5052
cmake \
5153
${{ matrix.appindicator }} \
54+
imagemagick \
5255
libglib2.0-dev \
5356
libnotify-dev \
5457
ninja-build \
5558
xvfb
5659
60+
- name: Setup virtual desktop
61+
if: runner.os == 'Linux'
62+
uses: LizardByte/actions/actions/virtual_desktop@70bb8d394d1c92f6113aeec6ae9cc959a5763d15 # v2026.227.200013
63+
with:
64+
appindicator-version: ${{ matrix.appindicator_type }}
65+
environment: mate
66+
5767
- name: Setup Dependencies macOS
5868
if: runner.os == 'macOS'
5969
run: |
@@ -62,9 +72,45 @@ jobs:
6272
cmake \
6373
doxygen \
6474
graphviz \
75+
imagemagick \
6576
ninja \
6677
node
6778
79+
- name: Fix macOS screen recording permissions
80+
if: runner.os == 'macOS'
81+
run: |
82+
set -euo pipefail
83+
84+
configure_system_tccdb() {
85+
local values=$1
86+
local dbPath="/Library/Application Support/com.apple.TCC/TCC.db"
87+
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
88+
sudo sqlite3 "$dbPath" "$sqlQuery"
89+
}
90+
91+
configure_user_tccdb() {
92+
local values=$1
93+
local dbPath="$HOME/Library/Application Support/com.apple.TCC/TCC.db"
94+
local sqlQuery="INSERT OR IGNORE INTO access VALUES($values);"
95+
sqlite3 "$dbPath" "$sqlQuery"
96+
}
97+
98+
systemValuesArray=(
99+
"'kTCCServiceScreenCapture','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1599831148"
100+
)
101+
for values in "${systemValuesArray[@]}"; do
102+
configure_system_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
103+
done
104+
105+
userValuesArray=(
106+
"'kTCCServiceScreenCapture','/bin/bash',1,2,0,1,NULL,NULL,NULL,'UNUSED',NULL,0,1583997993"
107+
)
108+
for values in "${userValuesArray[@]}"; do
109+
configure_user_tccdb "$values,NULL,NULL,'UNUSED',${values##*,}"
110+
done
111+
112+
echo "macOS TCC permissions configured."
113+
68114
- name: Setup Dependencies Windows
69115
if: runner.os == 'Windows'
70116
uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0
@@ -76,6 +122,7 @@ jobs:
76122
mingw-w64-ucrt-x86_64-binutils
77123
mingw-w64-ucrt-x86_64-cmake
78124
mingw-w64-ucrt-x86_64-graphviz
125+
mingw-w64-ucrt-x86_64-imagemagick
79126
mingw-w64-ucrt-x86_64-ninja
80127
mingw-w64-ucrt-x86_64-nodejs
81128
mingw-w64-ucrt-x86_64-toolchain
@@ -98,7 +145,7 @@ jobs:
98145
99146
# step output
100147
echo "python-path=${python_path}"
101-
echo "python-path=${python_path}" >> $GITHUB_OUTPUT
148+
echo "python-path=${python_path}" >> "${GITHUB_OUTPUT}"
102149
103150
- name: Build
104151
run: |
@@ -119,18 +166,57 @@ jobs:
119166
-S .
120167
ninja -C build
121168
169+
- name: Init tray icon (Windows)
170+
if: runner.os == 'Windows'
171+
working-directory: build/tests
172+
run: ./test_tray --gtest_color=yes --gtest_filter=TrayTest.TestTrayInit
173+
174+
- name: Configure Windows
175+
if: runner.os == 'Windows'
176+
shell: pwsh
177+
run: |
178+
echo "::group::Enable all tray icons"
179+
Invoke-WebRequest `
180+
-Uri "https://raw.githubusercontent.com/paulmann/windows-show-all-tray-icons/main/Enable-AllTrayIcons.ps1" `
181+
-OutFile "Enable-AllTrayIcons.ps1"
182+
.\Enable-AllTrayIcons.ps1 -Action Enable -Force # Enable with comprehensive method (resets ALL icon settings)
183+
echo "::endgroup::"
184+
185+
echo "::group::Disable Do Not Disturb"
186+
Add-Type -AssemblyName System.Windows.Forms
187+
Start-Process "ms-settings:notifications"
188+
Start-Sleep -Seconds 2
189+
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
190+
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
191+
[System.Windows.Forms.SendKeys]::SendWait(" ")
192+
echo "::endgroup::"
193+
194+
echo "::group::Minimize all windows"
195+
$shell = New-Object -ComObject Shell.Application
196+
$shell.MinimizeAll()
197+
echo "::endgroup::"
198+
199+
echo "::group::Set Date - Hack for Quiet Time"
200+
$newDate = (Get-Date).AddHours(2)
201+
Set-Date -Date $newDate
202+
echo "::endgroup::"
203+
122204
- name: Run tests
123205
id: test
124206
# TODO: tests randomly hang on Linux, https://github.com/LizardByte/tray/issues/45
125-
timeout-minutes: 1
207+
timeout-minutes: 3
126208
working-directory: build/tests
127-
run: |
128-
if [ "${{ runner.os }}" = "Linux" ]; then
129-
export DISPLAY=:1
130-
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
131-
fi
209+
run: ./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml
132210

133-
./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml
211+
- name: Upload screenshots
212+
if: >-
213+
always() &&
214+
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
215+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
216+
with:
217+
name: tray-screenshots-${{ runner.os }}${{ matrix.appindicator && format('-{0}', matrix.appindicator) || '' }}
218+
path: build/tests/screenshots
219+
if-no-files-found: error
134220

135221
- name: Generate gcov report
136222
id: test_report
@@ -159,7 +245,7 @@ jobs:
159245
if [ -n "${{ matrix.appindicator }}" ]; then
160246
flags="${flags},${{ matrix.appindicator }}"
161247
fi
162-
echo "flags=${flags}" >> $GITHUB_OUTPUT
248+
echo "flags=${flags}" >> "${GITHUB_OUTPUT}"
163249
164250
- name: Upload coverage
165251
# any except canceled or skipped

0 commit comments

Comments
 (0)