[gnome-mag/bonobo-less] Added a test from gnome-shell



commit bfb2ea434c1de05572eb9b1d5f8a35177d849078
Author: Fernando Herrera <fherrera onirica com>
Date:   Mon Jul 5 19:16:24 2010 +0200

    Added a test from gnome-shell

 test/dbus-mag-test.py |  202 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 202 insertions(+), 0 deletions(-)
---
diff --git a/test/dbus-mag-test.py b/test/dbus-mag-test.py
new file mode 100755
index 0000000..a554bcb
--- /dev/null
+++ b/test/dbus-mag-test.py
@@ -0,0 +1,202 @@
+#! /usr/bin/python
+#
+# testGSMagDBus -- Test GnomeShell Magnifier DBus interface
+#
+# Copyright (C) 2010 Adaptive Technology Resource Centre
+#  * Contributor: Joseph Scheuhammer <clown utoronto ca>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2.1 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+import dbus
+import time
+import sys
+bus = dbus.SessionBus()
+
+print "Getting magnifier dbus object..."
+#magProxy = bus.get_object('org.freedesktop.Magnifier', '/org/freedesktop/Magnifier')
+_magProxy = bus.get_object('org.gnome.Magnifier', '/org/gnome/Magnifier')
+magProxy =  dbus.Interface(_magProxy, "org.gnome.Magnifier")
+print magProxy;
+
+# Turn magnification on/off
+print "Turning magnification on..."
+magProxy.setActive(True);
+activeStr = "false";
+if magProxy.isActive() : activeStr = "true";
+print "Magnifier is ", activeStr;
+response = raw_input("Press return to continue ...");
+
+magProxy.setActive(False);
+print "... magnification should now be off"
+print "";
+
+# Turn showing/hiding system mouse
+print "Hiding the system mouse cursor."
+magProxy.hideCursor();
+response = raw_input("Press return to continue ...");
+
+magProxy.showCursor();
+print "... system mouse cursor should now be visible, again."
+print "";
+response = raw_input("Press return to continue ...");
+
+# Create a region
+roi = [10, 10, 300, 150];
+position = [300, 300, 300, 150];
+
+print "Creating a zoom region of ", roi, ", and at ", position
+zoomRegionPath = magProxy.createZoomRegion (4, 4, roi, position);
+print zoomRegionPath;
+
+print "Adding zoom region to magnifier ...";
+added = magProxy.addZoomRegion(zoomRegionPath);
+if added == 1:
+    print "ADDED";
+else:
+    print "FAILED TO ADD";
+print "";
+
+roi = [200, 100, 100, 100];
+position = [800, 800, 100, 100];
+print "Creating another zoom region of ", roi, " , and at ", position
+zoomRegionPath = magProxy.createZoomRegion (2.5, 2.5, roi, position);
+magProxy.addZoomRegion(zoomRegionPath);
+
+print "Turning on the magnifier (and the zoom regions?)";
+magProxy.setActive(True);
+response = raw_input("Press return to continue ...");
+
+print "Getting ZoomRegionInstance";
+#zoomRegionProxy = bus.get_object('org.freedesktop.Magnifier', zoomRegionPath);
+_zoomRegionProxy = bus.get_object('org.gnome.Magnifier', zoomRegionPath);
+zoomRegionProxy = dbus.Interface(_zoomRegionProxy, "org.gnome.Magnifier.ZoomRegion")
+print zoomRegionProxy;
+magFactor = zoomRegionProxy.getMagFactor();
+print "Mag factor of zoomRegionProxy is ", magFactor;
+print "";
+response = raw_input("Press return to continue ...");
+
+print "Getting first ZoomRegionInstance ...";
+zoomRegions = magProxy.getZoomRegions();
+print zoomRegions;
+print "";
+print "Getting the first ZoomRegionInstance (", zoomRegions[0], ")";
+#zoomRegionProxy = bus.get_object('org.freedesktop.Magnifier', zoomRegions[0]);
+_zoomRegionProxy = bus.get_object('org.gnome.Magnifier', zoomRegions[0]);
+zoomRegionProxy = dbus.Interface(_zoomRegionProxy, "org.gnome.Magnifier.ZoomRegion")
+print zoomRegionProxy;
+print "mag factor of first zoom region is: '", zoomRegionProxy.getMagFactor(), "'";
+response = raw_input("Press return to continue ...");
+
+print "Removing all ZoomRegions";
+magProxy.clearAllZoomRegions();
+print "";
+response = raw_input("Press return to continue ...");
+
+print "Creating a new ZoomRegion and adding it to the magnifier";
+zoomRegionPath = magProxy.createZoomRegion (4, 4, roi, position);
+print zoomRegionPath;
+added = magProxy.addZoomRegion(zoomRegionPath);
+if added == 1:
+    print "ADDED";
+else:
+    print "FAILED TO ADD";
+magProxy.setActive(True);
+time.sleep(2);
+print "";
+
+print "Resizing/moving new ZoomRegion";
+#zoomRegionProxy = bus.get_object('org.freedesktop.Magnifier', zoomRegionPath);
+_zoomRegionProxy = bus.get_object('org.gnome.Magnifier', zoomRegionPath);
+zoomRegionProxy = dbus.Interface(_zoomRegionProxy, "org.gnome.Magnifier.ZoomRegion")
+print zoomRegionProxy;
+
+position = [500, 200, 900, 650];
+zoomRegionProxy.moveResize(position);
+time.sleep(2);
+print "";
+
+magFactor = zoomRegionProxy.getMagFactor();
+print "Mag factor should be [4, 4], GOT: ", magFactor;
+zoomRegionProxy.setMagFactor(.75, .75);
+magFactor = zoomRegionProxy.getMagFactor();
+print "Mag factor should now be [.75, .75], GOT: ", magFactor;
+print "";
+
+roi = [0, 0, 200, 200];
+zoomRegionProxy.setRoi(roi);
+outRoi = zoomRegionProxy.getRoi();
+print "ROI should be ", roi, ", GOT: ", outRoi;
+print "";
+
+# Set roi via shiftContentsTo(x,y)
+response = raw_input("Press return to continue ...");
+print "Shifting contents to (300, 700)";
+zoomRegionProxy.setMagFactor(5, 5);
+zoomRegionProxy.shiftContentsTo(300, 700);
+outRoi = zoomRegionProxy.getRoi();
+print "ROI is ", outRoi;
+x = outRoi[0];
+y = outRoi[1];
+w = outRoi[2];
+h = outRoi[3];
+print "ROI is now ", outRoi, " centre at (", x + w / 2, y + h / 2, ")";
+print ""
+response = raw_input(">>> MOVE MOUSE TO SEE CROSSHAIRS, THEN PRESS RETURN TO CONTINUE ...");
+
+# Manipulate cross hairs via DBus
+print "Setting crosshairs width to 30"
+magProxy.setCrosswireSize(30);
+scratch = magProxy.getCrosswireSize();
+print "Reported size is ", scratch;
+response = raw_input("Press return to continue ...");
+
+print "Setting crosshairs length to 100"
+magProxy.setCrosswireLength(100);
+scratch = magProxy.getCrosswireLength();
+print "Reported length is ", scratch;
+response = raw_input("Press return to continue ...");
+
+print "Setting crosshairs colour to magenta"
+oldColor = magProxy.getCrosswireColor();
+print "Old colour is ", hex(oldColor);
+magProxy.setCrosswireColor(0xff00ffff);
+scratch = magProxy.getCrosswireColor();
+print "Reported colour is ", hex(scratch);
+response = raw_input("Press return to continue ...");
+
+print "Setting crosshairs colour to blue"
+magProxy.setCrosswireColor(0x0000ffff);
+scratch = magProxy.getCrosswireColor();
+print "Reported colour is ", hex(scratch);
+response = raw_input("Press return to continue ...");
+
+print "Resetting colour..."
+magProxy.setCrosswireColor(oldColor);
+
+print "Clipping crosshairs"
+magProxy.setCrosswireClip(True);
+scratch = magProxy.getCrosswireClip();
+print "Reported clip is ", scratch;
+response = raw_input("Press return to continue ...");
+print "Turning clip off"
+magProxy.setCrosswireClip(False);
+scratch = magProxy.getCrosswireClip();
+print "Reported clip is ", scratch;
+response = raw_input("Press return to continue ...");
+
+
+
+print "DONE";



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]