tests: Add HP WMI test

This commit is contained in:
Bastien Nocera 2021-03-17 11:37:06 +01:00
parent 2095f03c8c
commit 4c86f30cda

View file

@ -519,6 +519,32 @@ class Tests(dbusmock.DBusTestCase):
self.stop_daemon()
def test_hp_wmi(self):
# Uses cool instead of low-power
acpi_dir = os.path.join(self.testbed.get_root_dir(), "sys/firmware/acpi/")
os.makedirs(acpi_dir)
with open(os.path.join(acpi_dir, "platform_profile") ,'w') as profile:
profile.write("cool\n")
with open(os.path.join(acpi_dir, "platform_profile_choices") ,'w') as choices:
choices.write("cool balanced performance\n")
self.start_daemon()
profiles = self.get_dbus_property('Profiles')
self.assertEqual(len(profiles), 3)
self.assertEqual(profiles[0]['Driver'], 'platform_profile')
self.assertEqual(profiles[0]['Profile'], 'power-saver')
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'power-saver')
self.assertEqual(self.read_file (os.path.join(self.testbed.get_root_dir(), "sys/firmware/acpi/platform_profile")), b'cool\n')
# Check that we can set the power-saver/cool profile again
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('balanced'))
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('power-saver'))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'power-saver')
self.assertEqual(self.read_file (os.path.join(self.testbed.get_root_dir(), "sys/firmware/acpi/platform_profile")), b'cool')
self.stop_daemon()
#
# Helper methods
#