Skip to content

Commit

Permalink
Add test actions for C++ theme detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh committed Sep 7, 2024
1 parent 8dc05a7 commit fff2f58
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,26 @@ jobs:
- name: Checking our Python imports.
run: |
scripts/theme.sh
theme-cpp:
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # TODO: Restore macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Checking our Python imports.
shell: bash
run: |
mkdir -p dist
cd dist
if [[ "${RUNNER_OS}" == "Windows" ]]; then
cl ../scripts/test_theme.cpp /std:c++17 /EHsc /link Advapi32.lib OleAut32.lib
./test_theme
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
clang++ ../scripts/test_theme.cpp -o test_theme -std=c++17
./test_theme
else
g++ ../scripts/test_theme.cpp -o test_theme -std=c++17
./test_theme
fi
2 changes: 1 addition & 1 deletion .github/workflows/ui.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Ui

on: [push]
on: [workflow_dispatch]

jobs:
ui:
Expand Down
2 changes: 1 addition & 1 deletion example/breeze_theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* This code has been minimally tested but should be useful on most platforms.
* This makes extensive use of C++17 features. On Windows, this requires adding
* `OleAut32.lib` to the linker.
* `OleAut32.lib` and `Advapi32.lib` to the linker.
*
* This currently supports:
* - Windows
Expand Down
2 changes: 2 additions & 0 deletions scripts/headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ for script in example/*.py; do
done

# now we need to run our tests
# NOTE: We run each test separately just because it simplifies the logic.
# Some tests don't work in headless mode so we skip them.
widgets=$(${PYTHON} -c "import os; os.chdir('test'); import ui; print(' '.join([i[5:] for i in dir(ui) if i.startswith('test_')]))")
for widget in ${widgets[@]}; do
for framework in "${frameworks[@]}"; do
Expand Down
15 changes: 15 additions & 0 deletions scripts/test_theme.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Example to test our theme detection works at the C++ level.
*/

#include <iostream>
#include "../example/breeze_theme.hpp"

int main()
{
std::cout << "Theme: " << static_cast<int>(breeze_stylesheets::get_theme()) << std::endl;
std::cout << "Is Dark: " << breeze_stylesheets::is_dark() << std::endl;
std::cout << "Is Light: " << breeze_stylesheets::is_light() << std::endl;

return 0;
}

0 comments on commit fff2f58

Please sign in to comment.