aboutsummaryrefslogtreecommitdiffstats
path: root/test.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-21 14:53:18 +0200
committerMattias Andrée <maandree@kth.se>2022-07-21 14:53:18 +0200
commit3be28b4e8f75190d30e311f0e69da714cac62cc5 (patch)
tree95374a0ac30802f838e0fee1d7c686b66dd26b11 /test.py
parentRemove dist (diff)
downloadpylibgamma-17830332d43ae48c035c5f05c71301977ddfb717.tar.gz
pylibgamma-17830332d43ae48c035c5f05c71301977ddfb717.tar.bz2
pylibgamma-17830332d43ae48c035c5f05c71301977ddfb717.tar.xz
Change license to ISC, change style, improve makefile1.1.3
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py105
1 files changed, 105 insertions, 0 deletions
diff --git a/test.py b/test.py
new file mode 100755
index 0000000..5286c07
--- /dev/null
+++ b/test.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+# See LICENSE file for copyright and license details.
+import libgamma
+from time import sleep
+
+
+method = libgamma.list_methods(0)[0]
+assert libgamma.is_method_available(method) == True
+
+print('\033[1mMethod capabilities\033[m')
+print(libgamma.method_capabilities(method).__dict__)
+print()
+
+print('\033[1mMethod default site variable and default site\033[m')
+print(repr(libgamma.method_default_site_variable(method)))
+print(repr(libgamma.method_default_site(method)))
+print()
+
+print('\033[1mUnhexing b"0123456789ABCDEF" and b"0123456789abcdef"\033[m')
+print(repr(libgamma.unhex_edid('0123456789ABCDEF')))
+print(repr(libgamma.unhex_edid('0123456789abcdef')))
+print('\033[1mUnhexing and rehexing "0123456789abcdef"\033[m')
+print(repr(libgamma.behex_edid(libgamma.unhex_edid('0123456789abcdef'))))
+print(repr(libgamma.behex_edid_lowercase(libgamma.unhex_edid('0123456789abcdef'))))
+print(repr(libgamma.behex_edid_uppercase(libgamma.unhex_edid('0123456789abcdef'))))
+print()
+
+print('\033[1mPrinting required group ID, setting to 10, and reprinting\033[m')
+print(libgamma.group.gid)
+libgamma.group.gid = 10
+print(libgamma.group.gid)
+print()
+
+print('\033[1mPrinting required group name, setting to "group", and reprinting\033[m')
+print(repr(libgamma.group.name))
+libgamma.group.name = 'group'
+print(repr(libgamma.group.name))
+print()
+
+print('\033[1mPrint description for errors: 0, ERRNO_SET and NO_SUCH_ADJUSTMENT_METHOD\033[m')
+libgamma.perror('test', 0)
+libgamma.perror('test', libgamma.LIBGAMMA_ERRNO_SET)
+libgamma.perror('test', libgamma.LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD)
+print()
+
+print('\033[1mGetting name and value of error NO_SUCH_SITE\033[m')
+print(repr(libgamma.name_of_error(libgamma.LIBGAMMA_NO_SUCH_SITE)))
+print(repr(libgamma.value_of_error('LIBGAMMA_NO_SUCH_SITE')))
+print(libgamma.LIBGAMMA_NO_SUCH_SITE)
+print()
+
+print('\033[1mCreating errors: 1, 0, -1 and -2\033[m')
+print(libgamma.create_error(1))
+print(libgamma.create_error(0))
+print(libgamma.create_error(-1))
+print(libgamma.create_error(-2))
+print()
+
+print('\033[1mGetting partition count, crtc count for partition 0, and info for crtc 0.0\033[m')
+site = libgamma.Site(method)
+print(site.partitions_available)
+partition = libgamma.Partition(site, 0)
+print(partition.crtcs_available)
+crtc = libgamma.CRTC(partition, 0)
+info = crtc.information(~0)[0]
+print(info.__dict__)
+print()
+
+ramp_sizes = (info.red_gamma_size, info.green_gamma_size, info.blue_gamma_size)
+ramps = libgamma.GammaRamps(*ramp_sizes, depth = info.gamma_depth)
+crtc.get_gamma(ramps)
+print('\033[1mCurrent red gamma ramp\033[m')
+print(list(ramps.red))
+print()
+print('\033[1mCurrent green gamma ramp\033[m')
+print(list(ramps.green))
+print()
+print('\033[1mCurrent blue gamma ramp\033[m')
+print(list(ramps.blue))
+print()
+
+saved_red = list(ramps.red)
+saved_green = list(ramps.green)
+saved_blue = list(ramps.blue)
+
+ramps.red[:] = list(map(lambda x : x // 2, saved_red))
+ramps.green[:] = list(map(lambda x : x // 2, saved_green))
+ramps.blue[:] = list(map(lambda x : x // 2, saved_blue))
+
+crtc.set_gamma(ramps)
+
+sleep(1)
+
+ramps.red[:] = saved_red
+ramps.green[:] = saved_green
+ramps.blue[:] = saved_blue
+
+crtc.set_gamma(ramps)
+
+# If not done expressively, if in the root scope,
+# we sometimes get ignored errors on exit
+del site
+del partition
+del crtc
+del ramps