Example #1
0
    def update_scratch_dir(self, name=""):
        """ Update the directory where Dogtail saves screenshots. """
        path = os.path.join(testconfig.config.get("resultsdir", ""), name)
        if not path.endswith("/"):
            path += "/"

        dogtail_config.load({"scratchDir": path})
Example #2
0
    def update_scratch_dir(self, name=""):
        """ Update the directory where Dogtail saves screenshots. """
        path = os.path.join(testconfig.config.get("resultsdir", ""), name)
        if not path.endswith("/"):
            path += "/"

        dogtail_config.load({"scratchDir": path})
Example #3
0
    def setUp(self):
        # Force the locale/language to English.
        # Otherwise we won't be able to grab the right widgets.
        os.environ["LC_ALL"] = 'C'
        # Try to speed up UI interaction a little.
        # Do not change "typingDelay" from its default (0.075 secs);
        # Setting it too low makes dogtail type characters in random order!
        from dogtail.config import config
        config.load({'actionDelay': 0.1,
                     'runTimeout': 1,
                     'searchCutoffCount': 5,
                     'defaultDelay': 0.1})
        from dogtail.utils import run
        from dogtail.tree import root
        # Setting appName is critically important here.
        # Otherwise it will try to look for "bin/pitivi" through AT-SPI and fail,
        # making the tests take ages to start up.
        self.pid = run('bin/pitivi', dumb=False, appName="pitivi")
        # Apparently, if we start inspecting "too fast"... we slow down startup.
        # With GNOME 3.6, startup would be delayed to the point where the "Esc"
        # keypress to dismiss the welcome dialog would happen too soon.
        sleep(1)

        self.pitivi = root.application('pitivi')
        timer_start = time()
        # This is a performance hack to very quickly get the widgets we want,
        # by using their known position instead of searching.
        # Reuse those variables throughout your scripts for efficient access.
        # FIXME: this will probably break with detached tabs.
        mainwindow = self.pitivi.children[0].children[0]  # this is a vbox
        mainwindow_upper = mainwindow.children[2].child(name="upper half", recursive=False)
        timeline_area = mainwindow.children[2].child(name="timeline area", recursive=False)
        primary_tabs = mainwindow_upper.children[0].child(name="primary tabs", recursive=False)
        secondary_tabs = mainwindow_upper.children[0].child(name="secondary tabs", recursive=False)
        # These are the "shortcut" variables you can use for better perfs:
        self.menubar = mainwindow.child(roleName='menu bar')
        self.medialibrary = primary_tabs.children[0]
        self.effectslibrary = primary_tabs.children[1]
        self.clipproperties = secondary_tabs.children[0]
        self.transitions = secondary_tabs.children[0]
        self.titles = secondary_tabs.children[0]
        self.viewer = mainwindow_upper.child(name="viewer", recursive=False)
        self.zoom_best_fit_button = timeline_area.child(name="Zoom", recursive=True)
        self.timeline = timeline_area.child(name="timeline canvas", recursive=False)
        self.timeline_toolbar = timeline_area.child(name="timeline toolbar", recursive=False)
        # Used to speed up helper_functions in particular:
        self.import_button = self.medialibrary.child(name="media_import_button")
        self.insert_button = self.medialibrary.child(name="media_insert_button")
        start_time = time() - timer_start
        if start_time > 0.1:
            # When we were simply searching the toplevel for the menu bar,
            # startup time was 0.0043 seconds. Anything significantly longer
            # means there are optimizations to be done, avoid recursive searches
            print "\nWARNING: setUp in test_base took", start_time, "seconds, that's too slow.\n"
        try:
            self.unlink
        except AttributeError:
            self.unlink = []
Example #4
0
    def runTest(self):
        """A version of TestCase.runTest that attempts to take a screenshot of
           anaconda should a test fail.  Subclasses should not override this.
           See the documentation for _run.
        """
        config.load({"scratchDir": "/mnt/anactest/result/"})

        try:
            self._run()
        except (AssertionError, SearchError):
            # Try to take a screenshot of whatever screen anaconda's on, so
            # we can attempt to figure out what went wrong.
            screenshot()
            raise
Example #5
0
    def runTest(self):
        """A version of TestCase.runTest that attempts to take a screenshot of
           anaconda should a test fail.  Subclasses should not override this.
           See the documentation for _run.
        """
        config.load({"scratchDir": "/mnt/anactest/result/"})

        try:
            self._run()
        except (AssertionError, SearchError):
            # Try to take a screenshot of whatever screen anaconda's on, so
            # we can attempt to figure out what went wrong.
            screenshot()
            raise
Example #6
0
    def setUp(self):
        """ Set up clear conf with a custom logger and repository folder.
        """
        self.conf_path = '/etc/galicaster/conf.ini'
        identifier = self.id().split('.')
        identifier.reverse()
        test_number = re.sub('\D','',identifier[0])
        self.test_path = '/tmp/test{}'.format(test_number)

        if os.path.exists(self.conf_path) and not os.path.exists('{}.old'.format(self.conf_path)):
            os.rename(self.conf_path,'{}.old'.format(self.conf_path))
        shutil.copyfile(get_resource('conf/functional_test.ini'),'/etc/galicaster/conf.ini')
        if not os.path.exists(self.test_path):
            os.makedirs('{}/logs/'.format(self.test_path))
        self.conf = Conf()

        self.conf.set('basic','repository','{}/Repository'.format(self.test_path))
        self.conf.set('logger','path','{}/logs/galicaster.log'.format(self.test_path))
        self.conf.update()

        config.load({'logDir':'{}/logs/'.format(self.test_path)})
        from . import recording
Example #7
0
    def setUp(self):
        # Force the locale/language to English.
        # Otherwise we won't be able to grab the right widgets.
        os.environ["LC_ALL"] = "C"
        # Try to speed up UI interaction a little
        from dogtail.config import config

        config.load(
            {"actionDelay": 0.1, "typingDelay": 0.02, "runTimeout": 1, "searchCutoffCount": 5, "defaultDelay": 0.1}
        )
        from dogtail.utils import run
        from dogtail.tree import root

        # Setting appName is critically important here.
        # Otherwise it will try to look for "bin/pitivi" through AT-SPI and fail,
        # making the tests take ages to start up.
        self.pid = run("bin/pitivi", dumb=False, appName="pitivi")
        self.pitivi = root.application("pitivi")
        self.menubar = self.pitivi.get_child()(roleName="menu bar")
        try:
            self.unlink
        except AttributeError:
            self.unlink = []
Example #8
0
    def setUp(self):
        # Force the locale/language to English.
        # Otherwise we won't be able to grab the right widgets.
        os.environ["LC_ALL"] = 'C'
        # Try to speed up UI interaction a little.
        # Do not change "typingDelay" from its default (0.075 secs);
        # Setting it too low makes dogtail type characters in random order!
        from dogtail.config import config
        config.load({
            'actionDelay': 0.1,
            'runTimeout': 1,
            'searchCutoffCount': 5,
            'defaultDelay': 0.1
        })
        from dogtail.utils import run
        from dogtail.tree import root
        # Setting appName is critically important here.
        # Otherwise it will try to look for "bin/pitivi" through AT-SPI and fail,
        # making the tests take ages to start up.
        self.pid = run('bin/pitivi', dumb=False, appName="pitivi")
        # Apparently, if we start inspecting "too fast"... we slow down startup.
        # With GNOME 3.6, startup would be delayed to the point where the "Esc"
        # keypress to dismiss the welcome dialog would happen too soon.
        sleep(1)

        self.pitivi = root.application('pitivi')
        timer_start = time()
        # This is a performance hack to very quickly get the widgets we want,
        # by using their known position instead of searching.
        # Reuse those variables throughout your scripts for efficient access.
        # FIXME: this will probably break with detached tabs.
        mainwindow = self.pitivi.children[0].children[0]  # this is a vbox
        mainwindow_upper = mainwindow.children[2].child(name="upper half",
                                                        recursive=False)
        mainwindow_lower = mainwindow.children[2].child(name="lower half",
                                                        recursive=False)
        primary_tabs = mainwindow_upper.children[0].child(name="primary tabs",
                                                          recursive=False)
        secondary_tabs = mainwindow_upper.children[0].child(
            name="secondary tabs", recursive=False)
        # These are the "shortcut" variables you can use for better perfs:
        self.menubar = mainwindow.child(roleName='menu bar')
        self.medialibrary = primary_tabs.children[0]
        self.effectslibrary = primary_tabs.children[1]
        self.clipproperties = secondary_tabs.children[0]
        self.transitions = secondary_tabs.children[0]
        self.titles = secondary_tabs.children[0]
        self.viewer = mainwindow_upper.child(name="viewer", recursive=False)
        self.timeline = mainwindow_lower.children[0].children[1].child(
            name="timeline canvas", recursive=False)
        self.timeline_toolbar = mainwindow_lower.child(name="timeline toolbar",
                                                       recursive=False)
        # Used to speed up helper_functions in particular:
        self.import_button = self.medialibrary.child(
            name="media_import_button")
        self.insert_button = self.medialibrary.child(
            name="media_insert_button")
        start_time = time() - timer_start
        if start_time > 0.1:
            # When we were simply searching the toplevel for the menu bar,
            # startup time was 0.0043 seconds. Anything significantly longer
            # means there are optimizations to be done, avoid recursive searches
            print "\nWARNING: setUp in test_base took", start_time, "seconds, that's too slow.\n"
        try:
            self.unlink
        except AttributeError:
            self.unlink = []
Example #9
0
    def setUp(self):
        # Force the locale/language to English.
        # Otherwise we won't be able to grab the right widgets.
        os.environ["LC_ALL"] = 'C'
        # Try to speed up UI interaction a little.
        # Do not change "typingDelay" from its default (0.075 secs);
        # Setting it too low makes dogtail type characters in random order!
        from dogtail.config import config
        config.load({
            'actionDelay': 0.1,
            'runTimeout': 1,
            'searchCutoffCount': 5,
            'defaultDelay': 0.1
        })
        # Specify custom xdg user dirs to not be influenced by the settings
        # chosen by the current user.
        if not hasattr(self, "user_dir"):
            self.user_dir = tempfile.mkdtemp()
            os.environ["PITIVI_USER_CONFIG_DIR"] = os.path.pathsep.join(
                [self.user_dir, "config"])
            os.environ["PITIVI_USER_DATA_DIR"] = os.path.pathsep.join(
                [self.user_dir, "data"])
            os.environ["PITIVI_USER_CACHE_DIR"] = os.path.pathsep.join(
                [self.user_dir, "cache"])
        from dogtail.utils import run
        from dogtail.tree import root
        # Setting appName is critically important here.
        # Otherwise it will try to look for "bin/pitivi" through AT-SPI and fail,
        # making the tests take ages to start up.
        self.pid = run('bin/pitivi', dumb=False, appName="pitivi")
        # Apparently, if we start inspecting "too fast"... we slow down startup.
        # With GNOME 3.6, startup would be delayed to the point where the "Esc"
        # keypress to dismiss the welcome dialog would happen too soon.
        time.sleep(1)

        self.pitivi = root.application('pitivi')
        timer_start = time.time()
        # This is a performance hack to very quickly get the widgets we want,
        # by using their known position instead of searching.
        # Reuse those variables throughout your scripts for efficient access.
        mainwindow = self.pitivi.children[0]
        self.assertEqual('main window', mainwindow.name)
        headerbar, contents = mainwindow.children

        # Headerbar
        self.main_menu_button = headerbar.children[5]
        self.assertEqual("main menu button", self.main_menu_button.name)

        # Content below the headerbar.
        self.assertEqual('contents', contents.name)
        upper_half, timeline_area = contents.children
        self.assertEqual('upper half', upper_half.name)
        self.assertEqual('timeline area', timeline_area.name)

        # Tabs
        primary_tabs = upper_half.children[0].child(name="primary tabs",
                                                    recursive=False)
        secondary_tabs = upper_half.children[0].child(name="secondary tabs",
                                                      recursive=False)
        self.medialibrary = primary_tabs.children[0]
        self.effectslibrary = primary_tabs.children[1]
        self.clipproperties = secondary_tabs.children[0]
        self.transitions = secondary_tabs.children[1]
        self.titles = secondary_tabs.children[2]
        self.viewer = upper_half.child(name="viewer", recursive=False)
        self.import_button = self.medialibrary.child(
            name="media_import_button")
        self.insert_button = self.medialibrary.child(
            name="media_insert_button")

        # Timeline area
        self.zoom_best_fit_button = timeline_area.child(name="Zoom",
                                                        recursive=True)
        self.timeline = timeline_area.child(name="timeline canvas",
                                            recursive=False)
        self.timeline_toolbar = timeline_area.child(name="timeline toolbar",
                                                    recursive=False)

        start_time = time.time() - timer_start
        if start_time > 0.1:
            # When we were simply searching the toplevel for the menu bar,
            # startup time was 0.0043 seconds. Anything significantly longer
            # means there are optimizations to be done, avoid recursive
            # searches
            print("\nWARNING: setUp in test_base took", start_time,
                  "seconds, that's too slow.\n")
        try:
            self.unlink
        except AttributeError:
            self.unlink = []
Example #10
0
    def setUp(self):
        # Force the locale/language to English.
        # Otherwise we won't be able to grab the right widgets.
        os.environ["LC_ALL"] = 'C'
        # Try to speed up UI interaction a little.
        # Do not change "typingDelay" from its default (0.075 secs);
        # Setting it too low makes dogtail type characters in random order!
        from dogtail.config import config
        config.load({'actionDelay': 0.1,
                     'runTimeout': 1,
                     'searchCutoffCount': 5,
                     'defaultDelay': 0.1})
        # Specify custom xdg user dirs to not be influenced by the settings
        # chosen by the current user.
        if not hasattr(self, "user_dir"):
            self.user_dir = tempfile.mkdtemp()
            os.environ["PITIVI_USER_CONFIG_DIR"] = os.path.pathsep.join([self.user_dir, "config"])
            os.environ["PITIVI_USER_DATA_DIR"] = os.path.pathsep.join([self.user_dir, "data"])
            os.environ["PITIVI_USER_CACHE_DIR"] = os.path.pathsep.join([self.user_dir, "cache"])
        from dogtail.utils import run
        from dogtail.tree import root
        # Setting appName is critically important here.
        # Otherwise it will try to look for "bin/pitivi" through AT-SPI and fail,
        # making the tests take ages to start up.
        self.pid = run('bin/pitivi', dumb=False, appName="pitivi")
        # Apparently, if we start inspecting "too fast"... we slow down startup.
        # With GNOME 3.6, startup would be delayed to the point where the "Esc"
        # keypress to dismiss the welcome dialog would happen too soon.
        time.sleep(1)

        self.pitivi = root.application('pitivi')
        timer_start = time.time()
        # This is a performance hack to very quickly get the widgets we want,
        # by using their known position instead of searching.
        # Reuse those variables throughout your scripts for efficient access.
        mainwindow = self.pitivi.children[0]
        self.assertEqual('main window', mainwindow.name)
        headerbar, contents = mainwindow.children

        # Headerbar
        self.main_menu_button = headerbar.children[5]
        self.assertEqual("main menu button", self.main_menu_button.name)

        # Content below the headerbar.
        self.assertEqual('contents', contents.name)
        upper_half, timeline_area = contents.children
        self.assertEqual('upper half', upper_half.name)
        self.assertEqual('timeline area', timeline_area.name)

        # Tabs
        primary_tabs = upper_half.children[0].child(name="primary tabs", recursive=False)
        secondary_tabs = upper_half.children[0].child(name="secondary tabs", recursive=False)
        self.medialibrary = primary_tabs.children[0]
        self.effectslibrary = primary_tabs.children[1]
        self.clipproperties = secondary_tabs.children[0]
        self.transitions = secondary_tabs.children[1]
        self.titles = secondary_tabs.children[2]
        self.viewer = upper_half.child(name="viewer", recursive=False)
        self.import_button = self.medialibrary.child(name="media_import_button")
        self.insert_button = self.medialibrary.child(name="media_insert_button")

        # Timeline area
        self.zoom_best_fit_button = timeline_area.child(name="Zoom", recursive=True)
        self.timeline = timeline_area.child(name="timeline canvas", recursive=False)
        self.timeline_toolbar = timeline_area.child(name="timeline toolbar", recursive=False)

        start_time = time.time() - timer_start
        if start_time > 0.1:
            # When we were simply searching the toplevel for the menu bar,
            # startup time was 0.0043 seconds. Anything significantly longer
            # means there are optimizations to be done, avoid recursive searches
            print("\nWARNING: setUp in test_base took", start_time, "seconds, that's too slow.\n")
        try:
            self.unlink
        except AttributeError:
            self.unlink = []