"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gio/tests/power-profile-monitor-portal.py.in" between
glib-2.69.2.tar.xz and glib-2.69.3.tar.xz

About: GLib is a low-level core C library used by GTK+ and GNOME. Development version.

power-profile-monitor-portal.py.in  (glib-2.69.2.tar.xz):power-profile-monitor-portal.py.in  (glib-2.69.3.tar.xz)
skipping to change at line 31 skipping to change at line 31
import taptestrunner import taptestrunner
try: try:
# Do all non-standard imports here so we can skip the tests if any # Do all non-standard imports here so we can skip the tests if any
# needed packages are not available. # needed packages are not available.
import dbus import dbus
import dbus.mainloop.glib import dbus.mainloop.glib
import dbusmock import dbusmock
from gi.repository import GLib from gi.repository import GLib
from gi.repository import Gio from gi.repository import Gio
from gi.repository import GObject
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
# XDG_DESKTOP_PORTAL_PATH = os.path.expanduser("~/.cache/jhbuild/build/xdg-d esktop-portal/xdg-desktop-portal") # XDG_DESKTOP_PORTAL_PATH = os.path.expanduser("~/.cache/jhbuild/build/xdg-d esktop-portal/xdg-desktop-portal")
XDG_DESKTOP_PORTAL_PATH = "@libexecdir@/xdg-desktop-portal" XDG_DESKTOP_PORTAL_PATH = "@libexecdir@/xdg-desktop-portal"
class TestPowerProfileMonitorPortal(dbusmock.DBusTestCase): class TestPowerProfileMonitorPortal(dbusmock.DBusTestCase):
'''Test GPowerProfileMonitorPortal''' '''Test GPowerProfileMonitorPortal'''
@classmethod @classmethod
skipping to change at line 68 skipping to change at line 69
raise unittest.SkipTest("power-profiles-daemon dbusmock template not " raise unittest.SkipTest("power-profiles-daemon dbusmock template not "
"found. Requires dbusmock > 0.23.1.") "found. Requires dbusmock > 0.23.1.")
# set log to nonblocking # set log to nonblocking
flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL) flags = fcntl.fcntl(self.p_mock.stdout, fcntl.F_GETFL)
fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK ) fcntl.fcntl(self.p_mock.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK )
self.power_saver_enabled = False self.power_saver_enabled = False
self.dbus_props = dbus.Interface(self.obj_ppd, dbus.PROPERTIES_IFACE ) self.dbus_props = dbus.Interface(self.obj_ppd, dbus.PROPERTIES_IFACE )
try: try:
self.xdp = subprocess.Popen([XDG_DESKTOP_PORTAL_PATH]) self.xdp = subprocess.Popen([XDG_DESKTOP_PORTAL_PATH])
except FileNotFoundError: except FileNotFoundError:
self.p_mock.terminate()
self.p_mock.wait()
raise unittest.SkipTest("xdg-desktop-portal not available") raise unittest.SkipTest("xdg-desktop-portal not available")
try: try:
self.wait_for_bus_object('org.freedesktop.portal.Desktop', self.wait_for_bus_object('org.freedesktop.portal.Desktop',
'/org/freedesktop/portal/desktop') '/org/freedesktop/portal/desktop')
except: except:
self.p_mock.terminate()
self.p_mock.wait()
raise raise
# subprocess.Popen(['gdbus', 'monitor', '--session', '--dest', 'org. freedesktop.portal.Desktop']) # subprocess.Popen(['gdbus', 'monitor', '--session', '--dest', 'org. freedesktop.portal.Desktop'])
os.environ['GTK_USE_PORTAL'] = "1" os.environ['GTK_USE_PORTAL'] = "1"
self.power_profile_monitor = Gio.PowerProfileMonitor.dup_default() self.power_profile_monitor = Gio.PowerProfileMonitor.dup_default()
assert("GPowerProfileMonitorPortal" in str(self.power_profile_monito r)) assert("GPowerProfileMonitorPortal" in str(self.power_profile_monito r))
self.power_profile_monitor.connect("notify::power-saver-enabled", se lf.power_saver_enabled_cb) self.power_profile_monitor.connect("notify::power-saver-enabled", se lf.power_saver_enabled_cb)
self.mainloop = GLib.MainLoop() self.mainloop = GLib.MainLoop()
self.main_context = self.mainloop.get_context() self.main_context = self.mainloop.get_context()
skipping to change at line 119 skipping to change at line 124
def test_power_profile_power_saver_enabled_portal(self): def test_power_profile_power_saver_enabled_portal(self):
'''power-saver-enabled property''' '''power-saver-enabled property'''
self.assertEqual(self.power_profile_monitor.get_power_saver_enabled( ), False) self.assertEqual(self.power_profile_monitor.get_power_saver_enabled( ), False)
self.dbus_props.Set('net.hadess.PowerProfiles', 'ActiveProfile', dbu s.String('power-saver', variant_level=1)) self.dbus_props.Set('net.hadess.PowerProfiles', 'ActiveProfile', dbu s.String('power-saver', variant_level=1))
self.assertEventually(lambda: self.power_saver_enabled == True, "pow er-saver didn't become enabled", 10) self.assertEventually(lambda: self.power_saver_enabled == True, "pow er-saver didn't become enabled", 10)
self.dbus_props.Set('net.hadess.PowerProfiles', 'ActiveProfile', dbu s.String('balanced', variant_level=1)) self.dbus_props.Set('net.hadess.PowerProfiles', 'ActiveProfile', dbu s.String('balanced', variant_level=1))
self.assertEventually(lambda: self.power_saver_enabled == False, "po wer-saver didn't become disabled", 10) self.assertEventually(lambda: self.power_saver_enabled == False, "po wer-saver didn't become disabled", 10)
def test_power_profile_power_saver_enabled_portal_default(self):
'''power-saver-enabled property default value'''
self.dbus_props.Set('net.hadess.PowerProfiles', 'ActiveProfile', dbu
s.String('power-saver', variant_level=1))
# Create a new power profile monitor and check its property value is
# correct by default.
new_power_profile_monitor = GObject.new(GObject.type_from_name('GPow
erProfileMonitorPortal'))
new_power_profile_monitor.init()
self.assertTrue(new_power_profile_monitor.get_power_saver_enabled())
except ImportError as e: except ImportError as e:
@unittest.skip("Cannot import %s" % e.name) @unittest.skip("Cannot import %s" % e.name)
class TestPowerProfileMonitorPortal(unittest.TestCase): class TestPowerProfileMonitorPortal(unittest.TestCase):
def test_power_profile_power_saver_enabled_portal(self): def test_power_profile_power_saver_enabled_portal(self):
pass pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(testRunner=taptestrunner.TAPTestRunner()) unittest.main(testRunner=taptestrunner.TAPTestRunner())
 End of changes. 4 change blocks. 
0 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)