def kde_common_before_all(context): common_before_all(context) # Start ksnapshot for screenshots os.system("kstart -iconify ksnapshot") # Record video via recordmydesktop os.system("rm -rf /tmp/screencast.ogv") master, slave = pty.openpty() cmd = "recordmydesktop --no-sound --on-the-fly-encoding -o /tmp/screencast.ogv" p = Popen(cmd, shell=True, stdin=PIPE, stdout=slave, stderr=slave, close_fds=True) context.recordvideo_stdout = os.fdopen(master) if isA11yEnabled() is False: print("Enabling a11y") enableA11y(True) if isA11yEnabled() is False: sleep(5) print("Warning: second attempt to enable a11y") enableA11y(True) # Wait for ksplash to dissappear wait_for_kde_splash_to_dissapear()
# -*- coding: UTF-8 -*- from dogtail.utils import isA11yEnabled, enableA11y if isA11yEnabled() is False: enableA11y(True) from time import time, sleep from functools import wraps from os import strerror, errno, system from signal import signal, alarm, SIGALRM from subprocess import Popen, PIPE from behave import step from gi.repository import GLib, Gio import fcntl, os from dogtail.rawinput import keyCombo, absoluteMotion, pressKey from dogtail.tree import root from unittest import TestCase # Create a dummy unittest class to have nice assertions class dummy(TestCase): def runTest(self): # pylint: disable=R0201 assert True def wait_until(my_lambda, element, timeout=30, period=0.25): """ This function keeps running lambda with specified params until the result is True or timeout is reached Sample usages: * wait_until(lambda x: x.name != 'Loading...', context.app)
# -*- coding: UTF-8 -*- from time import sleep from dogtail.utils import isA11yEnabled, enableA11y if not isA11yEnabled(): enableA11y(True) from common_steps import App, cleanup from dogtail.config import config from os import system, makedirs from shutil import copyfile def before_all(context): """Setup xviewer stuff Being executed before all features """ try: # Skip dogtail actions to print to stdout config.logDebugToStdOut = False config.typingDelay = 0.2 context.app_class = App('xviewer') context.screenshot_counter = 0 context.save_screenshots = False except Exception as e: print("Error in before_all: %s" % e.message)
# -*- coding: UTF-8 -*- from dogtail.utils import isA11yEnabled, enableA11y if isA11yEnabled() is False: enableA11y(True) from time import time, sleep from functools import wraps from os import strerror, errno, system from signal import signal, alarm, SIGALRM from subprocess import Popen, PIPE from behave import step, then from gi.repository import GLib, Gio import fcntl, os from dogtail.rawinput import keyCombo, click, typeText, absoluteMotion, pressKey from dogtail.tree import root, SearchError from iniparse import ConfigParser import traceback from unittest import TestCase import logging # Create a dummy unittest class to have nice assertions class dummy(TestCase): def runTest(self): # pylint: disable=R0201 assert True def wait_until(my_lambda, element, timeout=30, period=0.25): """ This function keeps running lambda with specified params until the result is True or timeout is reached
# -*- coding: UTF-8 -*- from time import sleep, localtime, strftime from dogtail.utils import isA11yEnabled, enableA11y if not isA11yEnabled(): enableA11y(True) from dogtail.rawinput import pressKey from subprocess import call from common_steps import App, dummy, non_block_read, ensure_app_running from dogtail.config import config import os from urllib2 import urlopen, URLError, HTTPError import sys def downloadfile(url): # Open the url try: f = urlopen(url) print("** Downloading: " + url) # Open our local file for writing if not os.path.isfile("%s/Downloads/%s" % (os.path.expanduser("~"), os.path.basename(url))): with open("%s/Downloads/%s" % (os.path.expanduser("~"), os.path.basename(url)), "wb") as local_file: local_file.write(f.read()) except HTTPError, e: print("HTTP Error:", e.code, url) except URLError, e: print("URL Error:", e.reason, url) def do_backup():
on the hub, the current test case will be failed. """ button = self.find("_Done", "push button", node=node) self.assertIsNotNone(button, msg="Done button not found") button.click() doDelay(5) self.check_window_displayed(hubName) @unittest.skipIf(os.geteuid() != 0, "GUI tests must be run as root") @unittest.skipIf( os.environ.get("DISPLAY", "") == "", "DISPLAY must be defined") @unittest.skipIf( selinux.is_selinux_enabled() and selinux.security_getenforce() == 1, "SELinux must be disabled or in Permissive mode, see rhbz#1276376") @unittest.skipIf(not isA11yEnabled(), "Assistive Technologies are disabled") class DogtailTestCase(unittest.TestCase): """A subclass that defines all the parameters for starting a local copy of anaconda, inspecting results, and managing temporary data! Most subclasses will only need to define the following four attributes: drives -- A list of tuples describing disk images to create. Each tuple is the name of the drive and its size as a blivet.Size. environ -- A dictionary of environment variables that should be added to the environment the test suite will run under. name -- A unique string that names the test. This name will be used in creating the results directory (and perhaps other places in the future) so make sure it doesn't conflict with another object. tests -- A list describing which test cases make up this test.
"""Leave a spoke by clicking the Done button in the upper left corner, then verify we have returned to the proper hub. Since most spokes are off the summary hub, that's the default. If we are not back on the hub, the current test case will be failed. """ button = self.find("_Done", "push button", node=node) self.assertIsNotNone(button, msg="Done button not found") button.click() doDelay(5) self.check_window_displayed(hubName) @unittest.skipIf(os.geteuid() != 0, "GUI tests must be run as root") @unittest.skipIf(os.environ.get("DISPLAY", "") == "", "DISPLAY must be defined") @unittest.skipIf(selinux.is_selinux_enabled() and selinux.security_getenforce() == 1, "SELinux must be disabled or in Permissive mode, see rhbz#1276376") @unittest.skipIf(not isA11yEnabled(), "Assistive Technologies are disabled") class DogtailTestCase(unittest.TestCase): """A subclass that defines all the parameters for starting a local copy of anaconda, inspecting results, and managing temporary data! Most subclasses will only need to define the following four attributes: drives -- A list of tuples describing disk images to create. Each tuple is the name of the drive and its size as a blivet.Size. environ -- A dictionary of environment variables that should be added to the environment the test suite will run under. name -- A unique string that names the test. This name will be used in creating the results directory (and perhaps other places in the future) so make sure it doesn't conflict with another object. tests -- A list describing which test cases make up this test.
import subprocess from dogtail import utils logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) parser = argparse.ArgumentParser(description='Connect with remote-viewer.') parser.add_argument("url", help="Url, eg: spice://127.0.0.1:5960") parser.add_argument("-t", "--ticket", help="Spice ticket.", default="", nargs="?") args = parser.parse_args() assert utils.isA11yEnabled(), "A11 accessibility is disabled." try: rv.Application(method="mouse") except rv.GeneralError: pass else: raise Exception("Found runing RV.") # Exec new instance RV, without arguments. RV shows 'Connection details.' # dialog. logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) rv_p = subprocess.Popen(["remote-viewer"]) rv_app = rv.Application(method="mouse")
sys.path.append(os.path.join(os.path.dirname(__file__), "lib")) import rv import subprocess from dogtail import utils logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) parser = argparse.ArgumentParser(description='Connect with remote-viewer.') parser.add_argument("url", help="Url, eg: spice://127.0.0.1:5960") parser.add_argument("-t", "--ticket", help="Spice ticket.", default="", nargs="?") args = parser.parse_args() assert utils.isA11yEnabled(), "A11 accessibility is disabled." try: rv.Application(method="mouse") except rv.GeneralError: pass else: raise Exception("Found runing RV.") # Exec new instance RV, without arguments. RV shows 'Connection details.' # dialog. logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) rv_p = subprocess.Popen(["remote-viewer"]) rv_app = rv.Application(method="mouse")