Beispiel #1
0
 def close_dialog_through_button(self, button):
     with EventListener(self._xContext, "DialogClosed") as event:
         button.executeAction("CLICK", tuple())
         while True:
             if event.executed:
                 time.sleep(DEFAULT_SLEEP)
                 return
             time.sleep(DEFAULT_SLEEP)
Beispiel #2
0
 def execute_dialog_through_command(self, command, printNames=False):
     with EventListener(self._xContext,
                        "DialogExecute",
                        printNames=printNames) as event:
         if not self._xUITest.executeDialog(command):
             raise DialogNotExecutedException(command)
         while True:
             if event.executed:
                 time.sleep(DEFAULT_SLEEP)
                 return
             time.sleep(DEFAULT_SLEEP)
Beispiel #3
0
 def close_dialog_through_button(self, button):
     with EventListener(self._xContext, "DialogClosed") as event:
         button.executeAction("CLICK", tuple())
         time_ = 0
         while time_ < MAX_WAIT:
             if event.executed:
                 time.sleep(DEFAULT_SLEEP)
                 return
             time_ += DEFAULT_SLEEP
             time.sleep(DEFAULT_SLEEP)
     raise DialogNotClosedException()
Beispiel #4
0
    def execute_modeless_dialog_through_command(self, command):
        with EventListener(self._xContext, "ModelessDialogVisible") as event:
            self._xUITest.executeCommand(command)
            time_ = 0
            while time_ < 30:
                if event.executed:
                    time.sleep(DEFAULT_SLEEP)
                    return
                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)

        raise DialogNotExecutedException(command)
Beispiel #5
0
 def load_file(self, url):
     desktop = self.get_desktop()
     with EventListener(self._xContext, "OnLoad") as event:
         component = desktop.loadComponentFromURL(url, "_default", 0,
                                                  tuple())
         time_ = 0
         while time_ < 30:
             if event.executed:
                 time.sleep(DEFAULT_SLEEP)
                 return component
             time_ += DEFAULT_SLEEP
             time.sleep(DEFAULT_SLEEP)
Beispiel #6
0
    def execute_dialog_through_command(self, command):
        with EventListener(self._xContext, "DialogExecute") as event:
            if not self._xUITest.executeDialog(command):
                raise DialogNotExecutedException(command)
            time_ = 0
            while time_ < MAX_WAIT:
                if event.executed:
                    time.sleep(DEFAULT_SLEEP)
                    return
                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)

        raise DialogNotExecutedException(command)
Beispiel #7
0
    def execute_modeless_dialog_through_command(self, command, printNames=False):
        with EventListener(self._xContext, "ModelessDialogVisible", printNames = printNames) as event:
            if not self._xUITest.executeCommand(command):
                raise DialogNotExecutedException(command)
            time_ = 0
            while time_ < MAX_WAIT:
                if event.executed:
                    time.sleep(DEFAULT_SLEEP)
                    return
                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)

        raise DialogNotExecutedException(command)
Beispiel #8
0
    def create_doc_in_start_center(self, app):
        xStartCenter = self._xUITest.getTopFocusWindow()
        xBtn = xStartCenter.getChild(app + "_all")
        with EventListener(self._xContext, "OnNew") as event:
            xBtn.executeAction("CLICK", tuple())
            time_ = 0
            while time_ < 30:
                if event.executed:
                    return
                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)

        print("failure doc in start center")
Beispiel #9
0
    def execute_dialog_through_action(self, ui_object, action, parameters = None, event_name = "DialogExecute"):
        if parameters is None:
            parameters = tuple()

        with EventListener(self._xContext, event_name) as event:
            ui_object.executeAction(action, parameters)
            time_ = 0
            while time_ < MAX_WAIT:
                if event.executed:
                    time.sleep(DEFAULT_SLEEP)
                    return
                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)
        raise DialogNotExecutedException(action)
Beispiel #10
0
 def load_file(self, url):
     desktop = self.get_desktop()
     with EventListener(self._xContext, "OnLoad") as event:
         component = desktop.loadComponentFromURL(url, "_default", 0, tuple())
         time_ = 0
         while time_ < MAX_WAIT:
             if event.executed:
                 frames = self.get_frames()
                 if len(frames) == 1:
                     self.get_desktop().setActiveFrame(frames[0])
                 time.sleep(DEFAULT_SLEEP)
                 return component
             time_ += DEFAULT_SLEEP
             time.sleep(DEFAULT_SLEEP)
Beispiel #11
0
    def close_doc(self):
        with EventListener(self._xContext,
                           ["DialogExecute", "OnViewClosed"]) as event:
            self._xUITest.executeCommand(".uno:CloseDoc")
            time_ = 0
            while time_ < 30:
                if event.hasExecuted("DialogExecute"):
                    xCloseDlg = self._xUITest.getTopFocusWindow()
                    xNoBtn = xCloseDlg.getChild("discard")
                    xNoBtn.executeAction("CLICK", tuple())
                    return
                elif event.hasExecuted("OnViewClosed"):
                    return

                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)
Beispiel #12
0
    def execute_blocking_action(self,
                                action,
                                dialog_element=None,
                                args=(),
                                dialog_handler=None,
                                printNames=False):
        """Executes an action which blocks while a dialog is shown.

        Click a button or perform some other action on the dialog when it
        is shown.

        Args:
            action(callable): Will be called to show a dialog, and is expected
                to block while the dialog is shown.
            dialog_element(str, optional): The name of a button on the dialog
                which will be clicked when the dialog is shown.
            args(tuple, optional): The arguments to be passed to `action`
            dialog_handler(callable, optional): Will be called when the dialog
                is shown, with the dialog object passed as a parameter.
            printNames: print all received event names
        """

        thread = threading.Thread(target=action, args=args)
        with EventListener(self._xContext, [
                "DialogExecute", "ModelessDialogExecute",
                "ModelessDialogVisible"
        ],
                           printNames=printNames) as event:
            thread.start()
            time_ = 0
            # we are not necessarily opening a dialog, so wait much longer
            while time_ < 10 * MAX_WAIT:
                if event.executed:
                    xDlg = self._xUITest.getTopFocusWindow()
                    if dialog_element:
                        xUIElement = xDlg.getChild(dialog_element)
                        xUIElement.executeAction("CLICK", tuple())
                    if dialog_handler:
                        dialog_handler(xDlg)
                    thread.join()
                    return

                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)
        raise DialogNotExecutedException(
            "did not execute a dialog for a blocking action")
Beispiel #13
0
    def execute_blocking_action(self, action, dialog_element, args=()):
        thread = threading.Thread(target=action, args=args)
        with EventListener(
                self._xContext,
            ["DialogExecute", "ModelessDialogExecute"]) as event:
            thread.start()
            time_ = 0
            while time_ < 30:
                if event.executed:
                    xDlg = self._xUITest.getTopFocusWindow()
                    xUIElement = xDlg.getChild(dialog_element)
                    xUIElement.executeAction("CLICK", tuple())
                    thread.join()
                    return

                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)
        raise DialogNotExecutedException(
            "did not execute a dialog for a blocking action")
Beispiel #14
0
    def create_doc_in_start_center(self, app):
        xStartCenter = self._xUITest.getTopFocusWindow()
        try:
            xBtn = xStartCenter.getChild(app + "_all")
        except RuntimeException:
            print("Handled crash reporter")
            self._handle_crash_reporter()
            xStartCenter = self._xUITest.getTopFocusWindow()
            xBtn = xStartCenter.getChild(app + "_all")

        with EventListener(self._xContext, "OnNew") as event:
            xBtn.executeAction("CLICK", tuple())
            time_ = 0
            while time_ < MAX_WAIT:
                if event.executed:
                    frames = self.get_frames()
                    self.get_desktop().setActiveFrame(frames[0])
                    print(len(frames))
                    return
                time_ += DEFAULT_SLEEP
                time.sleep(DEFAULT_SLEEP)

        print("failure doc in start center")