def testHasProxy(self):
        """FacadeTest: Test hasProxy()"""
        # Create facades
        facade1 = Facade.getInstance(self.KEY1)
        facade2 = Facade.getInstance(self.KEY2)

        # Register proxies
        proxy1 = Proxy('hasProxy1', [1, 2, 3])
        proxy2 = Proxy('hasProxy2', [10, 20, 30])

        facade1.registerProxy(proxy1)
        facade2.registerProxy(proxy2)

        self.assertEqual(True, facade1.hasProxy('hasProxy1'))
        self.assertEqual(False, facade2.hasProxy('hasProxy1'))

        self.assertEqual(True, facade2.hasProxy('hasProxy2'))
        self.assertEqual(False, facade1.hasProxy('hasProxy2'))

        # Remove proxies
        facade1.removeProxy('hasProxy1')
        facade2.removeProxy('hasProxy2')

        self.assertEqual(False, facade1.hasProxy('hasProxy1'))
        self.assertEqual(False, facade2.hasProxy('hasProxy2'))
    def testHasMediator(self):
        """FacadeTest: Test hasMediator()"""
        # Create facades
        facade1 = Facade.getInstance(self.KEY1)
        facade2 = Facade.getInstance(self.KEY2)

        # Register mediators
        mediator1 = Mediator('Mediator1', object())
        mediator2 = Mediator('Mediator2', object())

        facade1.registerMediator(mediator1)
        facade2.registerMediator(mediator2)

        self.assertEqual(True, facade1.hasMediator('Mediator1'))
        self.assertEqual(False, facade2.hasMediator('Mediator1'))

        self.assertEqual(False, facade1.hasMediator('Mediator2'))
        self.assertEqual(True, facade2.hasMediator('Mediator2'))

        # Remove mediators
        facade1.removeMediator('Mediator1')
        facade2.removeMediator('Mediator2')

        self.assertEqual(False, facade1.hasMediator('Mediator1'))
        self.assertEqual(False, facade2.hasMediator('Mediator2'))
    def testNotNone(self):
        """FacadeTest: Test instance not null"""
        facade1 = Facade.getInstance(self.KEY1)
        facade2 = Facade.getInstance(self.KEY2)

        self.assertNotEqual(None, facade1)
        self.assertNotEqual(None, facade2)
        self.assertNotEqual(facade1, facade2)
Esempio n. 4
0
 def mouseReleaseEvent(self, e):
     """:type e: QMouseEvent.QMouseEvent"""
     if self.__drag_item:
         released_item = self.itemAt(e.pos())
         if released_item and released_item is not self.__drag_item:
             drag_indexes = self.get_indexes(self.__drag_item)
             released_indexes = self.get_indexes(released_item)
             Facade.getInstance().sendNotification(Notes.TREE_MODEL_MOVE, TreeModelMoveVO(drag_indexes, released_indexes))
     QTreeWidget.mouseReleaseEvent(self, e)
     self.__drag_item = None
Esempio n. 5
0
 def mouseReleaseEvent(self, e):
     """:type e: QMouseEvent.QMouseEvent"""
     if self.__drag_item:
         released_item = self.itemAt(e.pos())
         if released_item and released_item is not self.__drag_item:
             drag_indexes = self.get_indexes(self.__drag_item)
             released_indexes = self.get_indexes(released_item)
             Facade.getInstance().sendNotification(
                 Notes.TREE_MODEL_MOVE,
                 TreeModelMoveVO(drag_indexes, released_indexes))
     QTreeWidget.mouseReleaseEvent(self, e)
     self.__drag_item = None
Esempio n. 6
0
 def on_accept(self):
     hotkey_str = ""
     key = self.edit_line.text()
     if key:
         if self.control_check.isChecked():
             hotkey_str += "Ctrl+"
         if self.alt_check.isChecked():
             hotkey_str += "Alt+"
         if self.shift_check.isChecked():
             hotkey_str += "Shift+"
         hotkey_str += key
     if key == "":
         hotkey_str = ""
     Facade.getInstance().sendNotification(
         HotkeyDialogView.HOTKEY_DIALOG_OK, {"key_sequence": hotkey_str})
Esempio n. 7
0
 def new_step(step_uid, **kwargs):
     step = Step()
     step.uid = step_uid
     if step.uid == StepUids.NULL_STEP:
         step.script = "alert ('nullStep');"
         return step
     elif step.uid == StepUids.TEST_STEP:
         step.default_args_dict = {
             "isOk": True,
             "numLines": 4,
             "portion": 0.1234567890,
             "portion2": 1,
             "none": None,
             "hello": "HelloWorld",
             "hasReturn": True
         }
         step.script = """
             var step_result = args
             args.hello = "byeBye!!"
             alert ('testStep');
         """
         return step
     elif step.uid == StepUids.FROM_JSX:
         if "script_path_name" in kwargs.keys():
             step_pool = Facade.getInstance().retrieveProxy(
                 StepPoolProxy.NAME).__get_step_pool()
             step = step_pool.get_step(
                 file_path_name=kwargs["script_path_name"])
         return step
     else:
         print("StepFactory.new_step no step with such uid")
         return StepFactory.new_step(StepUids.NULL_STEP)
Esempio n. 8
0
 def new_step(step_uid, **kwargs):
     step = Step()
     step.uid = step_uid
     if step.uid == StepUids.NULL_STEP:
         step.script = "alert ('nullStep');"
         return step
     elif step.uid == StepUids.TEST_STEP:
         step.default_args_dict = {
             "isOk": True,
             "numLines": 4,
             "portion": 0.1234567890,
             "portion2": 1,
             "none": None,
             "hello": "HelloWorld",
             "hasReturn": True
         }
         step.script = """
             var step_result = args
             args.hello = "byeBye!!"
             alert ('testStep');
         """
         return step
     elif step.uid == StepUids.FROM_JSX:
         if "script_path_name" in kwargs.keys():
             step_pool = Facade.getInstance().retrieveProxy(StepPoolProxy.NAME).__get_step_pool()
             step = step_pool.get_step(file_path_name=kwargs["script_path_name"])
         return step
     else:
         print("StepFactory.new_step no step with such uid")
         return StepFactory.new_step(StepUids.NULL_STEP)
Esempio n. 9
0
 def on_accept(self):
     hotkey_str = ""
     key = self.edit_line.text()
     if key:
         if self.control_check.isChecked():
             hotkey_str += "Ctrl+"
         if self.alt_check.isChecked():
             hotkey_str += "Alt+"
         if self.shift_check.isChecked():
             hotkey_str += "Shift+"
         hotkey_str += key
     if key == "":
         hotkey_str = ""
     Facade.getInstance().sendNotification(
         HotkeyDialogView.HOTKEY_DIALOG_OK,
         {"key_sequence": hotkey_str}
     )
    def testRegisterCommandAndSendNotification(self):
        """FacadeTest: Test registerCommand() and sendNotification()"""

        fcde = Facade.getInstance(self.KEY1)
        fcde.registerCommand('FacadeTestNote', FacadeTestCommand)

        vo = FacadeTestVO(32)
        fcde.sendNotification('FacadeTestNote', vo)

        self.assertEqual(True, vo.result == 64)
    def testHasCommand(self):
        """FacadeTest: Test hasCommand()"""
        # Create facades
        facade1 = Facade.getInstance(self.KEY1)
        facade2 = Facade.getInstance(self.KEY2)

        # Register commands
        facade1.registerCommand('TestCommand', FacadeTestCommand)
        facade2.registerCommand('InstanceCommand', FacadeInstanceTestCommand)

        self.assertEqual(True, facade1.hasCommand('TestCommand'))
        self.assertEqual(False, facade2.hasCommand('TestCommand'))

        self.assertEqual(False, facade1.hasCommand('InstanceCommand'))
        self.assertEqual(True, facade2.hasCommand('InstanceCommand'))

        # Remove commands
        facade1.removeCommand('TestCommand')
        facade2.removeCommand('InstanceCommand')

        self.assertEqual(False, facade1.hasCommand('TestCommand'))
        self.assertEqual(False, facade2.hasCommand('InstanceCommand'))
Esempio n. 12
0
    def __init__(self):
        self.__treeView = Facade.getInstance().retrieveMediator(TreeView2Mediator.NAME).viewComponent
        """@type :TreeView2"""
        self.__main = MainWindow(self.__treeView)
        """@type :MainWindow"""
        super(MainWindowMediator, self).__init__(MainWindowMediator.NAME, self.__main)

        self.__main.btn_play_pressed.connect(self.on_play_pressed)
        self.__main.btn_remove_pressed.connect(self.on_remove_pressed)
        self.__main.btn_new_pressed.connect(self.on_new_pressed)
        self.__main.btn_save_pressed.connect(self.on_save_pressed)
        self.__main.activated.connect(self.on_activated)
        self.__main.deactivated.connect(self.on_deactivated)
        self.__main.btn_menu_pressed.connect(self.on_btn_menu_pressed)
    def testRegisterAndRemoveProxy(self):
        """FacadeTest: Test registerProxy() and removeProxy()"""

        fcde = Facade.getInstance(self.KEY1)
        pxy = Proxy('sizes', ['7', '13', '21'])
        fcde.registerProxy(pxy)

        removedProxy = fcde.removeProxy('sizes')

        self.assertEqual(True, removedProxy.getProxyName() == 'sizes')

        pxy = fcde.retrieveProxy('sizes')

        self.assertEqual(True, pxy == None)
    def testRegisterRetrieveAndRemoveMediator(self):
        """FacadeTest: Test registerMediator() retrieveMediator() and
        removeMediator()
        """

        fcde = Facade.getInstance(self.KEY1)
        fcde.registerMediator(Mediator(Mediator.NAME, object()))

        self.assertEqual(
            True, fcde.retrieveMediator(Mediator.NAME) is not None)

        removedMediator = fcde.removeMediator(Mediator.NAME)

        self.assertEqual(
            True, removedMediator.getMediatorName() == Mediator.NAME)
        self.assertEqual(True, fcde.retrieveMediator(Mediator.NAME) == None)
Esempio n. 15
0
    def __init__(self):
        self.__treeView = Facade.getInstance().retrieveMediator(
            TreeView2Mediator.NAME).viewComponent
        """@type :TreeView2"""
        self.__main = MainWindow(self.__treeView)
        """@type :MainWindow"""
        super(MainWindowMediator, self).__init__(MainWindowMediator.NAME,
                                                 self.__main)

        self.__main.btn_play_pressed.connect(self.on_play_pressed)
        self.__main.btn_remove_pressed.connect(self.on_remove_pressed)
        self.__main.btn_new_pressed.connect(self.on_new_pressed)
        self.__main.btn_save_pressed.connect(self.on_save_pressed)
        self.__main.activated.connect(self.on_activated)
        self.__main.deactivated.connect(self.on_deactivated)
        self.__main.btn_menu_pressed.connect(self.on_btn_menu_pressed)
Esempio n. 16
0
 def play(self, step_items, start_i=0):
     """
     Plays steps in action starting from i
     """
     del self.results[:]
     ps_app = win32com.client.Dispatch('Photoshop.Application')
     step_pool_proxy = Facade.getInstance().retrieveProxy(StepPoolProxy.NAME)
     """:type :StepPoolProxy"""
     action_script = ""
     for cur_i in xrange(len(step_items)):
         if cur_i < start_i:
             continue
         action_script += Step.py_args_to_javascript_script.encode('string_escape')
         action_script += step_pool_proxy.get_step(step_items[cur_i].leaf.step_uid).script.encode('string_escape')
         action_script += Step.return_script.encode('string_escape')
     self.js_play(ps_app, action_script)
    def testRegisterAndRetrieveProxy(self):
        """FacadeTest: Test registerProxy() and retrieveProxy()"""
        fcde = Facade.getInstance(self.KEY1)
        fcde.registerProxy(Proxy('colors', ['red', 'green', 'blue']))
        pxy = fcde.retrieveProxy('colors')

        self.assertEqual(True, isinstance(pxy, IProxy))

        data = pxy.getData()

        self.assertEqual(True, data is not None)
        self.assertEqual(True, isinstance(data, list))
        self.assertEqual(True, len(data) == 3)
        self.assertEqual(True, data[0] == 'red')
        self.assertEqual(True, data[1] == 'green')
        self.assertEqual(True, data[2] == 'blue')
Esempio n. 18
0
    def __init__(self, *args, **kwargs):
        super(ContextMenuView, self).__init__(*args, **kwargs)
        self.__menu_steps = Facade.getInstance().retrieveProxy(StepPoolProxy.NAME).get_step_files()

        self.__rename = QAction(ContextMenuView.RENAME_ACTION, None)
        self.__replace_step = QAction(ContextMenuView.REPLACE_STEP_ACTION, None)
        self.__set_hotkey = QAction(ContextMenuView.SET_HOTKEY_ACTION, None)
        # noinspection PyUnresolvedReferences
        self.__rename.triggered.connect(self.on_rename_menu)
        # noinspection PyUnresolvedReferences
        self.__replace_step.triggered.connect(self.on_replace_step)
        # noinspection PyUnresolvedReferences
        self.__set_hotkey.triggered.connect(self.on_set_hotkey)

        self.fill(None)
        self.addAction(self.__rename)
        self.addAction(self.__replace_step)
        self.addAction(self.__set_hotkey)
Esempio n. 19
0
    def __init__(self, *args, **kwargs):
        super(ContextMenuView, self).__init__(*args, **kwargs)
        self.__menu_steps = Facade.getInstance().retrieveProxy(
            StepPoolProxy.NAME).get_step_files()

        self.__rename = QAction(ContextMenuView.RENAME_ACTION, None)
        self.__replace_step = QAction(ContextMenuView.REPLACE_STEP_ACTION,
                                      None)
        self.__set_hotkey = QAction(ContextMenuView.SET_HOTKEY_ACTION, None)
        # noinspection PyUnresolvedReferences
        self.__rename.triggered.connect(self.on_rename_menu)
        # noinspection PyUnresolvedReferences
        self.__replace_step.triggered.connect(self.on_replace_step)
        # noinspection PyUnresolvedReferences
        self.__set_hotkey.triggered.connect(self.on_set_hotkey)

        self.fill(None)
        self.addAction(self.__rename)
        self.addAction(self.__replace_step)
        self.addAction(self.__set_hotkey)
Esempio n. 20
0
 def rename(self, new_name, *indexes):
     renamed_node = self.__tree.rename(new_name, *indexes)
     Facade.getInstance().sendNotification(
         Notes.TREE_NODE_RENAMED,
         TreeNodeRenamedVO(new_name, indexes),
     )
Esempio n. 21
0
 def on_accept(self):
     Facade.getInstance().sendNotification(ComboDialog.COMBO_DIALOG_OK, )
Esempio n. 22
0
 def on_reject(self):
     Facade.getInstance().sendNotification(
         ComboDialog.COMBO_DIALOG_CANCEL, )
Esempio n. 23
0
 def on_reject(self):
     Facade.getInstance().sendNotification(
         HotkeyDialogView.HOTKEY_DIALOG_CANCEL, )
Esempio n. 24
0
 def show_menu(self, point):
     selected_item = self.itemAt(point)
     Facade.getInstance().sendNotification(Notes.SHOW_CONTEXT_MENU, ShowContextMenuVO(self, selected_item))
Esempio n. 25
0
 def play(self, ps_app):
     step_pool_proxy = Facade.getInstance().retrieveProxy(StepPoolProxy.NAME)
     step = step_pool_proxy.get_step(self.step_uid)
     return step.play(ps_app, self.args)
Esempio n. 26
0
 def on_set_hotkey(self):
     Facade.getInstance().sendNotification(Notes.CONTEXT_MENU_SET_HOTKEY)
Esempio n. 27
0
 def on_accept(self):
     Facade.getInstance().sendNotification(
         TextDialog.TEXT_DIALOG_OK,
         {"text": self.edit_line.text()},
     )
Esempio n. 28
0
 def play(self, ps_app):
     step_pool_proxy = Facade.getInstance().retrieveProxy(
         StepPoolProxy.NAME)
     step = step_pool_proxy.get_step(self.step_uid)
     return step.play(ps_app, self.args)
Esempio n. 29
0
 def on_reject(self):
     Facade.getInstance().sendNotification(
         TextDialog.TEXT_DIALOG_CANCEL,
     )
Esempio n. 30
0
 def rename(self, new_name, *indexes):
     renamed_node = self.__tree.rename(new_name, *indexes)
     Facade.getInstance().sendNotification(
         Notes.TREE_NODE_RENAMED,
         TreeNodeRenamedVO(new_name, indexes),
     )
Esempio n. 31
0
 def on_accept(self):
     Facade.getInstance().sendNotification(
         TextDialog.TEXT_DIALOG_OK,
         {"text": self.edit_line.text()},
     )
Esempio n. 32
0
 def on_reject(self):
     Facade.getInstance().sendNotification(
         HotkeyDialogView.HOTKEY_DIALOG_CANCEL,
     )
Esempio n. 33
0
 def on_accept(self):
     Facade.getInstance().sendNotification(
         ComboDialog.COMBO_DIALOG_OK,
     )
 def __init__(self):
     Facade.__init__(self)
Esempio n. 35
0
 def on_reject(self):
     Facade.getInstance().sendNotification(
         ComboDialog.COMBO_DIALOG_CANCEL,
     )
Esempio n. 36
0
 def on_reject(self):
     Facade.getInstance().sendNotification(TextDialog.TEXT_DIALOG_CANCEL, )
Esempio n. 37
0
 def on_rename_menu(self):
     Facade.getInstance().sendNotification(Notes.CONTEXT_MENU_RENAME)
    def testIsIFacade(self):
        """FacadeTest: Test instance implements IFacade"""
        fcde = Facade.getInstance(self.KEY1)

        self.assertEqual(True, isinstance(fcde, IFacade))
Esempio n. 39
0
 def on_rename_menu(self):
     Facade.getInstance().sendNotification(Notes.CONTEXT_MENU_RENAME)
Esempio n. 40
0
 def on_replace_step(self):
     Facade.getInstance().sendNotification(Notes.CONTEXT_MENU_REPLACE_STEP)
Esempio n. 41
0
 def on_set_hotkey(self):
     Facade.getInstance().sendNotification(Notes.CONTEXT_MENU_SET_HOTKEY)
Esempio n. 42
0
 def show_menu(self, point):
     selected_item = self.itemAt(point)
     Facade.getInstance().sendNotification(
         Notes.SHOW_CONTEXT_MENU, ShowContextMenuVO(self, selected_item))
Esempio n. 43
0
 def on_replace_step(self):
     Facade.getInstance().sendNotification(Notes.CONTEXT_MENU_REPLACE_STEP)