Add test for DBus exporting of the following sysfs attributes:
1. capacity_level
2. voltage_min_design
3. voltage_max_design
Related: #301
Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Updates the "test_battery_ac" test case with the changes introduced by
the addition of the "state_all_discharging" field.
Namely, we now assert that the "OnBattery" property is False while
still checking that the correct "WarningLevel" property is set.
Add a scenario for connecting a low-power charger.
1. The AC is online.
2. The battery is discharging.
3. The percentage drops to 2.5%.
4. The warning level will become UP_DEVICE_LEVEL_CRITICAL.
Signed-off-by: Kate Hsuan <hpa@redhat.com>
We ship the proposed patch already since Oct 2024 in Alpine Linux and is
working for us correctly and fixes the test.
Closes https://gitlab.freedesktop.org/upower/upower/-/issues/228
Co-Authored-By: Bastien Nocera <hadess@hadess.net>
Some slow systems take more than 5 seconds to stop the daemon. The
waiting time was extended to 10 seconds to ensure the daemon
shutdowns properly.
Resolves: #290
Signed-off-by: Kate Hsuan <hpa@redhat.com>
This reverts commit 07565ef6a1.
In the current systemd stable release 255 org.freedesktop.login1 does
not emit a LidisClosed event, this has added in systemd `main` and will
be availble in the next release.
As GNOME control panel still uses UPower's `LidIsclosed` property and
many other DE's such as Xfce/LXQt/Deepin as well revert this until the
systemd changes are available in all Distributions.
https://github.com/systemd/systemd/pull/30706
Resolve: https://gitlab.freedesktop.org/upower/upower/-/issues/260
dbusmock 0.30.1 changed the BlueZ template to set the default "Class"
property to `MOCK_PHONE_CLASS` right away instead of in PairDevice() [1].
test_bluetooth_le_device() relied on the previous implicit default of a
"0" Class value. Set this explicitly to expect a "generic" device. This
makes the test work with old and current dbusmock versions.
https://bugs.debian.org/1059467
[1] https://github.com/martinpitt/python-dbusmock/pull/192
Some vendor kernel (most notably Android devices) expose various types
of BMS (battery management system) as power supplies. This is something
UPower has never designed to deal with, and thus UPower should not
represent or consider it to be a battery.
Fortunately, most of the time the actual "battery" power supply has the
correct type, so we can safely ignore those devices which have unknown
type. Also, the code that assumes power supply of unknown type seems
pretty dated and probably doesn't make sense anymore. So, let's remove
this assumption altogether.
up_device_battery_estimate_power() expects a charge/discharge rate of
0.5W to be significant, but the existing code yielded a rate of
-0.000240W.
Fix the units so that the amount of change in energy_now is at least
1W/s converted to µWh.
Now that device loop is fixed, we also need to fix the D-Bus object
path for the devices themselves to match what UPower generates so
we can get its properties.
As we iterate over the expected array, the elements are the basenames
of those object paths. Reconstruct the full object paths by prepending
/org/freedesktop/UPower/devices/
The test uses a generator to get the list of basenames for the devices:
names = (n.split('/')[-1] for n in devs)
Unfortunately, using that "names" varible will consume the generator,
and our array will be lost.
When passing a device dictionary, this code:
print(sorted(names))
print(sorted(names))
will yield:
['battery_hidpp_battery_0']
[]
Save the sorted array, and use that to test for properties equality.
Commit 1550d50f ("linux: Remove "usb" subsystem match") broke detection of
some idevices, since it left just the "usbmisc" subsystem match while some
idevice / kernel combinations (at least an iPhone 11 on a 6.0 kernel) don't
present any such udev usbmisc devices.
However, they do present "usb" subsystem ones, so add this match back.
Leave idevice detection also for the "usbmisc" match since that's what the
original (known working) code before aforementioned commit did - it is
possible that it is required for some kernel / idevice combinations.