Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mocking to tests & test X11 struts #2115

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Caellian
Copy link
Collaborator

@Caellian Caellian commented Dec 9, 2024

This PR adds some very basic mocking capabilities to tests.

The goal of this PR is to test values set by set_struts.

Mocking was forced on me because set_struts calls XChangeProperty which obviously wouldn't work without X11 initialization code.

Mocking works by linking mocked methods before conky_core.

I added a basic system to allow retrieving mutations that mocked functions perform (e.g. defining atoms, XChangeProperty information, etc.).

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@Caellian Caellian marked this pull request as draft December 9, 2024 05:59
@github-actions github-actions bot added sources PR modifies project sources tests related to project tests build system related to build system (CMake) and/or building process/assumptions labels Dec 9, 2024
Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for conkyweb ready!

Name Link
🔨 Latest commit 992e67c
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/675fbd9a86b45a000858657a
😎 Deploy Preview https://deploy-preview-2115--conkyweb.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Caellian Caellian force-pushed the dev/test-x11-struts branch 5 times, most recently from 513dc98 to 2f41bf3 Compare December 9, 2024 08:48
- Fix compile issues.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@Caellian Caellian force-pushed the dev/test-x11-struts branch 4 times, most recently from ad5a655 to 14193db Compare December 9, 2024 18:20
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@Caellian Caellian force-pushed the dev/test-x11-struts branch from 14193db to 384822e Compare December 9, 2024 18:21
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@Caellian Caellian force-pushed the dev/test-x11-struts branch from f23ca06 to 1784a59 Compare December 10, 2024 03:31
@github-actions github-actions bot added the display: x11 related to X11 backend label Dec 10, 2024
void set_struts(int);
void set_struts(alignment);
Copy link
Collaborator Author

@Caellian Caellian Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I kept this line like this for a reason, it previously caused compilation to fail because alignment wasn't available to some file (wayland?) that uses it. Note to self to check before merge.

Sorry, something went wrong.

- Split apart some of existing X11 functions so they can be unit tested.
- Improvements of testing code.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
@Caellian
Copy link
Collaborator Author

Caellian commented Mar 3, 2025

While mocking would be great, I'm putting this off for now because Lua options are very difficult to mock the way they currently work. Constructor was the issue and a more data-oriented approach would greatly help.

However, the testing I did manage to run didn't indicate any issues so far and would only serve for regression testing.

The issues (#1917, #1961, #2112) likely come from how different WMs handle struts as there are some differences. To deal with that, conky would need to detect WM and use correct implementation at runtime.

New set struts documentation
/// Reserve window manager space
///
/// Both `_NET_WM_STRUT` and `_NET_WM_STRUT_PARTIAL` work in coordinates
/// relative to root window (or sometimes Xinerama/Screen).
///
/// Values tell the WM which regions of the screen are invalidated. So, a
/// `bottom` value of `30` means that the window reserves bottom 30px of the
/// screen.
///
/// Because struts aren't handled the best by all WMs when multiple screens are
/// used, horizontal struts (top, bottom) should be preferred because that
/// works well for most multi-screen (horizontal monitor stacking) setups.
/// See: https://gitlab.gnome.org/GNOME/mutter/-/issues/452
///
/// Different WMs handle this differently, some adhere to the spec, some don't.
/// Spec compliant (relative to root window edges):
/// - mutter, metacity, openbox, marco, xfwm
/// Non-compliant (relative to edges of xinerama/single monitor):
/// - compiz, kwin, i3, fluxbox
///
/// Article why KWin doesn't follow the spec:
/// https://blog.martin-graesslin.com/blog/2016/08/panels-on-shared-screen-edges/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system related to build system (CMake) and/or building process/assumptions display: x11 related to X11 backend sources PR modifies project sources tests related to project tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant