[Pkg-privacy-commits] [onioncircuits] 03/03: adapt test case to use dogtail
Sascha Steinbiss
sascha at steinbiss.name
Tue Feb 23 23:56:48 UTC 2016
This is an automated email from the git hooks/post-receive script.
sascha-guest pushed a commit to branch master
in repository onioncircuits.
commit 3f91ac8c872e5cb126345a4299a2cca6a0013974
Author: Sascha Steinbiss <sascha at steinbiss.name>
Date: Tue Feb 23 23:54:45 2016 +0000
adapt test case to use dogtail
---
debian/tests/check-circuits | 77 ++++++++++++++++++++++++++++++++++++++-------
debian/tests/control | 4 +--
debian/tests/gui-test | 7 +++++
debian/tests/gui-tor-test | 46 +++++++++++++++++++++++++++
debian/tests/ldtp-test | 7 -----
debian/tests/ldtp-tor-test | 18 -----------
6 files changed, 121 insertions(+), 38 deletions(-)
diff --git a/debian/tests/check-circuits b/debian/tests/check-circuits
index 78f024a..43b280a 100755
--- a/debian/tests/check-circuits
+++ b/debian/tests/check-circuits
@@ -1,19 +1,74 @@
#!/usr/bin/env python
-import ldtp, ooldtp
+# -*- coding: utf-8 -*-
+# Copyright (C) 2016 Sascha Steinbiss <sascha at steinbiss.name>
+#
+# 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 3 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 General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# On Debian Systems you can find a copy of the text of GPL version 3
+# at /usr/share/common-licenses/GPL-3.
-ldtp.launchapp('onioncircuits')
+import gi
+gi.require_version('Atspi', '2.0')
+gi.require_version('Wnck', '3.0')
+import dogtail
+import dogtail.utils
+import dogtail.procedural
+import os
+import stem
+import stem.connection
+import unittest
-frm = ooldtp.context('Onion Circuits')
-frm.waittillguiexist()
-print(frm.getobjectlist())
+class TestOnionCircuitsGUI(unittest.TestCase):
-myitem = frm.getchild('ttbl0')
-rowcnt = myitem.getrowcount()
+ def setUp(self):
+ os.environ["LC_ALL"] = 'C'
+ self.pid = dogtail.utils.run('onioncircuits')
+ self.rootapp = dogtail.tree.root.application('onioncircuits')
+ self.window_title = 'Onion Circuits'
+ dogtail.procedural.focus.application("onioncircuits")
+ dogtail.procedural.focus.frame(self.window_title)
-assert(rowcnt > 0)
+ def _get_circuits(self):
+ circs = set()
+ with stem.connection.connect_socket_file() as controller:
+ controller.authenticate()
+ for circ in sorted(controller.get_circuits()):
+ if circ.status != stem.CircStatus.BUILT:
+ continue
+ nicks = []
+ for i, entry in enumerate(circ.path):
+ fingerprint, nickname = entry
+ nicks.append(nickname)
+ circs.add(", ".join(nicks))
+ return circs
-for i in range(0,rowcnt):
- print(myitem.getcellvalue(i, 0))
+ def test_has_correct_circuits(self):
+ children = self.rootapp.findChildren(
+ dogtail.predicate.GenericPredicate(roleName='table cell'))
+ lastcell = None
+ mycircs = set()
+ for child in children:
+ if child.text is not None:
+ if lastcell is not None:
+ if child.text == 'Built':
+ mycircs.add(lastcell)
+ lastcell = child.text
-ldtp.closewindow()
+ self.assertTrue(len(mycircs) > 0)
+ self.assertEqual(self._get_circuits(), mycircs)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/debian/tests/control b/debian/tests/control
index e4bd80d..f76cf5e 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,3 +1,3 @@
-Tests: ldtp-test
-Depends: @, xvfb, dbus-x11, ldtp, python-ldtp, tor
+Tests: gui-test
+Depends: @, psmisc, xvfb, dbus-x11, gir1.2-wnck-3.0, libglib2.0-bin, python-dogtail, tor, python-stem
Restrictions: needs-root, isolation-container, allow-stderr, needs-recommends
\ No newline at end of file
diff --git a/debian/tests/gui-test b/debian/tests/gui-test
new file mode 100755
index 0000000..6441f01
--- /dev/null
+++ b/debian/tests/gui-test
@@ -0,0 +1,7 @@
+#!/bin/sh
+# autopkgtest check: Run Onion Circuits and check displayed circuits
+# Author: Sascha Steinbiss <sascha at steinbiss.name>
+set -e
+
+useradd -g users -G debian-tor -m testuser
+su testuser -c debian/tests/gui-tor-test
\ No newline at end of file
diff --git a/debian/tests/gui-tor-test b/debian/tests/gui-tor-test
new file mode 100755
index 0000000..bf89567
--- /dev/null
+++ b/debian/tests/gui-tor-test
@@ -0,0 +1,46 @@
+#!/bin/sh
+# autopkgtest check: Run GUI test suite for Onion Circuits.
+# Author: Sascha Steinbiss <sascha at steinbiss.name>
+set -e
+
+printf "waiting for Tor to settle...\n"
+sleep 20
+
+WORKDIR=$(mktemp -d)
+
+# we don't always have a home directory, e.g. on buildds
+export XDG_CONFIG_HOME=$WORKDIR/.config
+export XDG_DATA_HOME=$WORKDIR/.local/share
+export XDG_CACHE_HOME=$WORKDIR/.cache
+export XDG_RUNTIME_DIR=$WORKDIR/runtime
+
+# start Xvfb
+# note that the screen size must be that large to avoid UI elements
+# going off screen, which would cause dogtail to fail with an error
+(Xvfb :5 -screen 0 1600x1200x24 -ac -noreset -v -fbdir $WORKDIR/ >/dev/null 2>&1 &)
+XVFB_PID=$!
+
+# XXX attach VNC session for local debugging only
+#x11vnc -ncache 10 -display :5 &
+#sleep 2
+#vncviewer localhost &
+
+# finish setting up X
+export DISPLAY=:5
+export XAUTHORITY=/dev/null
+
+# start local D-Bus session
+eval `dbus-launch`
+export DBUS_SESSION_BUS_ADDRESS
+
+# register clean up handler
+trap "rm -rf $WORKDIR && kill $DBUS_SESSION_BUS_PID $XVFB_PID" 0 INT QUIT ABRT PIPE TERM
+
+# enable assistive access, required for dogtail
+gsettings set org.gnome.desktop.interface toolkit-accessibility true
+
+# make sure no other instance is running, as it confuses dogtail
+killall -q onioncircuits || true
+
+# run test
+debian/tests/check-circuits
\ No newline at end of file
diff --git a/debian/tests/ldtp-test b/debian/tests/ldtp-test
deleted file mode 100755
index 7c87dd7..0000000
--- a/debian/tests/ldtp-test
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# autopkgtest check: Run Tor Monitor and check if it lists at least one circuit
-# Author: Sascha Steinbiss <sascha at steinbiss.name>
-set -e
-
-useradd -g users -G debian-tor -m testuser
-su testuser -c debian/tests/ldtp-tor-test
\ No newline at end of file
diff --git a/debian/tests/ldtp-tor-test b/debian/tests/ldtp-tor-test
deleted file mode 100755
index a67bd76..0000000
--- a/debian/tests/ldtp-tor-test
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-set -e
-
-printf "waiting for Tor to settle...\n"
-sleep 20
-
-# start X
-(Xvfb :5 >/dev/null 2>&1 &)
-XVFB_PID=$!
-export DISPLAY=:5
-
-# start local session D-BUS
-eval `dbus-launch`
-trap "kill $DBUS_SESSION_BUS_PID $XVFB_PID" 0 TERM QUIT INT
-export DBUS_SESSION_BUS_ADDRESS
-export XAUTHORITY=/dev/null
-
-debian/tests/check-circuits
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncircuits.git
More information about the Pkg-privacy-commits
mailing list