示例#1
0
 def setUp(self):
     """Do the test basic setup."""
     win = MainWindow()
     diagram = Diagram(MainWindow())
     blockmodel = BlockModel()
     self.block = Block(diagram, blockmodel)
     self.blockmenu = BlockMenu(self.block, None)
示例#2
0
    def setUp(self):
        """Do the test basic setup."""
        win = MainWindow()
        self.blockmanager = BlockManager(win)

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel()
        self.block = Block(diagram, blockmodel)
示例#3
0
class TestMainWindow(TestCase):
    def setUp(self):
        """Do the test basic setup."""
        self.main_window = MainWindow()

    # ----------------------------------------------------------------------x
    def test_update(self):
        self.assertIsNone(self.main_window.update())

    # ----------------------------------------------------------------------x
    def test_set_title(self):
        title = "Testando SET TITLE MAIN WINDOW"
        self.assertIsNone(self.main_window.set_title(title))
    def test_save(self):
        # NÃO TRABALHA COM None
        # block = None
        # self.assertTrue(self.blockpersistence.save(block))

        diagram = Diagram(MainWindow())
        block = Block(diagram, None)
        self.assertTrue(self.blockpersistence.save(block))

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel(None)
        block = Block(diagram, blockmodel)
        block.type = "teste_blockpersistence"
        self.assertTrue(self.blockpersistence.save(block))
示例#5
0
    def setUp(self):
        """Do the test basic setup."""
        win = MainWindow()
        self.diagram = Diagram(win)

        blockmodel = BlockModel()
        self.block = Block(self.diagram, blockmodel)
示例#6
0
 def setUp(self):
     """Do the test basic setup."""
     diagram = Diagram(MainWindow())
     blockmodel = BlockModel()
     block = Block(diagram, blockmodel)
     blockmodel = BlockModel(None)
     self.blockcodeeditor = BlockCodeEditor(BlockEditor(), Block())
示例#7
0
class TestMainWindow(TestBase):
    def setUp(self):
        self.main_window = MainWindow()

    def test_set_title(self):
        self.main_window.set_title("Test")

    def test_update(self):
        self.main_window.update()

    def test_event(self):
        event = Gdk.Event()
        event.key.type = Gdk.EventType.KEY_PRESS
        event.state = Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD2_MASK
        event.keyval = Gdk.KEY_a
        self.main_window.emit("key-press-event", event)
        self.main_window.emit("check-resize")
        self.main_window.emit("delete_event", event)
示例#8
0
    def test_save(self):
        # NÃO TRABALHA COM None
        # diagram = None
        # self.assertTrue(self.diagrampersistence.save(diagram))

        diagram = Diagram(MainWindow())
        self.assertTrue(self.diagrampersistence.save(diagram))

        diagram.file_name = "Template de teste"
        self.assertTrue(self.diagrampersistence.save(diagram))
    def setUp(self):
        """Do the test basic setup."""
        win = MainWindow()

        diagram = Diagram(win)
        blockmodel = BlockModel()
        block = Block(diagram, blockmodel)

        block_manager = BlockManager(win)
        self.blockporteditor = BlockPortEditor (block_manager, block)
示例#10
0
    def test_save_dialog(self):
        main_window = MainWindow()
        title = "Save"
        filetype = None
        self.assertIsNone(self.dialog.save_dialog(main_window, title,
                                                  filetype))

        # TESTANDO O BOTAO CANCEL
        main_window = MainWindow()
        title = "Save"
        filetype = "XML"
        self.assertIsNone(self.dialog.save_dialog(main_window, title,
                                                  filetype))

        # TESTANDO O BOTAO OK
        main_window = MainWindow()
        title = "Save"
        filetype = "XML"
        self.assertIsNotNone(
            self.dialog.save_dialog(main_window, title, filetype))
示例#11
0
    def test_load(self):

        diagram = Diagram(MainWindow())
        # NOTE: TESTANDO COM DIAGRAM = None
        # BUG: NÃO TRATA None
        # diagram = None
        # self.assertIsNone(self.diagrampersistence.load(diagram))

        # NOTE: TESTANDO COM NOME DE ARQUIVO VERDADEIRO
        diagram.file_name = "/home/lucas/mosaicode/teste/Untitled.mscd"
        self.assertTrue(self.diagrampersistence.load(diagram))
示例#12
0
    def test_set_block(self):
        # from mosaicode.GUI.block import Block
        # from mosaicode.GUI.diagram import Diagram as Diagram
        # from mosaicode.model.blockmodel import BlockModel as BlockModel
        #
        # block = Block(Diagram, BlockModel)
        # self.assertIsNone(self.main_control.set_block(block))

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel()
        block = Block(diagram, blockmodel)
        self.assertIsNone(self.main_control.set_block(block))
示例#13
0
    def setUp(self):
        """Do the test basic setup."""
        win = MainWindow()
        diagram = Diagram(win)

        blockmodel = BlockModel()
        source = Block(diagram, blockmodel)

        # NAO TRATA NONE
        # source = None
        source_port = 0
        conn_type = None
        self.connector = Connector(diagram, source, source_port, conn_type)
示例#14
0
    def test_message_dialog(self):

        title = "Testando Message Dialog 1"
        message = "Realizando teste no message dialog"
        main_window = None
        self.assertIsNone(
            self.dialog.message_dialog(title, message, main_window))

        title = "Testando Message Dialog 2"
        message = "main_window = MainWindow()"
        main_window = MainWindow()
        self.assertIsNone(
            self.dialog.message_dialog(title, message, main_window))
示例#15
0
    def test_open_dialog(self):

        # Deve-se apertar o botão CANCEL
        title = "Open"
        main_window = None
        filetype = None
        self.assertIsNone(self.dialog.open_dialog(title, main_window,
                                                  filetype))

        # Deve-se pesquisar um arquivo para abrir
        title = "Open"
        main_window = MainWindow()
        filetype = "xml"
        self.assertIsNotNone(
            self.dialog.open_dialog(title, main_window, filetype))
示例#16
0
    def test_add_block(self):
        # QUALQUER UMA DAS FORMAS ABAIXO APRESENTARÁ NONE
        # self.assertIsNone(self.blockmanager.add_block(self.block))
        # self.assertIsNone(self.blockmanager.add_block(None))

        # self.block.label = "Teste"
        # self.assertIsNone(self.blockmanager.add_block(self.block))

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel()
        block = Block(diagram, blockmodel)

        block.label = "Teste Block manager"

        self.assertIsNone(self.blockmanager.add_block(block))
示例#17
0
    def test_confirm_overwrite(self):

        name = "/home/lucas/Faculdade/2017-1/Iniciacao/Mosaicode/mosaicode/test/files_for_test/output/Dialog_Overwrite.mscd"
        main_window = None
        self.assertTrue(self.dialog.confirm_overwrite(name, main_window))

        # Testando o botão CANCEL
        name = "/home/lucas/Faculdade/2017-1/Iniciacao/Mosaicode/mosaicode/test/files_for_test/input/Teste1.mscd"
        main_window = None
        self.assertFalse(self.dialog.confirm_overwrite(name, main_window))

        # Testando o botão OK
        name = "/home/lucas/Faculdade/2017-1/Iniciacao/Mosaicode/mosaicode/test/files_for_test/input/Teste1.mscd"
        main_window = None
        self.assertTrue(self.dialog.confirm_overwrite(name, main_window))

        name = ""
        main_window = MainWindow()
        self.assertTrue(self.dialog.confirm_overwrite(name, main_window))
示例#18
0
 def test_add_diagram(self):
     # NÃO TRABALHA COM None
     # diagram = None
     # self.assertIsNone(self.work_area.add_diagram(diagram))
     diagram = Diagram(MainWindow())
     self.assertIsNone(self.work_area.add_diagram(diagram))
示例#19
0
 def create_main_window(self):
     return MainWindow()
示例#20
0
 def test_show_block_property(self):
     diagram = Diagram(MainWindow())
     blockmodel = BlockModel()
     block = Block(diagram, blockmodel)
     self.assertIsNone(self.main_control.show_block_property(block))
示例#21
0
    def test_delete_block(self):

        diagram = Diagram(MainWindow())
        blockmodel = BlockModel()
        block = Block(diagram, blockmodel)
        self.assertIsNone(self.main_control.delete_block(block))
示例#22
0
 def setUp(self):
     self.main_window = MainWindow()
示例#23
0
 def setUp(self):
     """Do the test basic setup."""
     self.main_window = MainWindow()
示例#24
0
 def setUp(self):
     """Do the test basic setup."""
     win = MainWindow()
     self.work_area = WorkArea(win)
示例#25
0
    def setUp(self):
        """Do the test basic setup."""
        self.blockmodel = BlockModel()

        self.blockmodel.id = 1
        self.blockmodel.x = 2
        self.blockmodel.y = 2

        self.blockmodel.language = "c"
        self.blockmodel.framework = "opencv"
        self.blockmodel.help = "Adiciona bordas na imagem."
        self.blockmodel.label = "Add Border"
        self.blockmodel.color = "0:180:210:150"
        self.blockmodel.in_ports = [{
            "type": "mosaicode_c_opencv.extensions.ports.image",
            "name": "input_image",
            "label": "Input Image"
        }, {
            "type": "mosaicode_c_opencv.extensions.ports.int",
            "name": "border_size",
            "label": "Border Size"
        }]
        self.blockmodel.out_ports = [{
            "type": "mosaicode_c_opencv.extensions.ports.image",
            "name": "output_image",
            "label": "Output Image"
        }]
        self.blockmodel.group = "Experimental"
        self.blockmodel.properties = [{
            "label": "Color",
            "name": "color",
            "type": MOSAICODE_COLOR,
            "value": "#FF0000"
        }, {
            "name":
            "type",
            "label":
            "Type",
            "type":
            MOSAICODE_COMBO,
            "value":
            "IPL_BORDER_CONSTANT",
            "values": [
                "IPL_BORDER_CONSTANT", "IPL_BORDER_REPLICATE",
                "IPL_BORDER_REFLECT", "IPL_BORDER_WRAP"
            ]
        }, {
            "label": "Border Size",
            "name": "border_size",
            "type": MOSAICODE_INT,
            "value": "50"
        }]
        self.blockmodel.codes[0] = \
            "CvScalar get_scalar_color(const char * rgbColor){\n" + \
            "   if (strlen(rgbColor) < 13 || rgbColor[0] != '#')\n" + \
            "       return cvScalar(0,0,0,0);\n" + \
            "   char r[4], g[4], b[4];\n" + \
            "   strncpy(r, rgbColor+1, 4);\n" + \
            "   strncpy(g, rgbColor+5, 4);\n" + \
            "   strncpy(b, rgbColor+9, 4);\n" + \
            "\n" + \
            "   int ri, gi, bi = 0;\n" + \
            "   ri = (int)strtol(r, NULL, 16);\n" + \
            "   gi = (int)strtol(g, NULL, 16);\n" + \
            "   bi = (int)strtol(b, NULL, 16);\n" + \
            "\n" + \
            "   ri /= 257;\n" + \
            "   gi /= 257;\n" + \
            "   bi /= 257;\n" + \
            "   \n" + \
            "   return cvScalar(bi, gi, ri, 0);\n" + \
            "}\n"
        self.blockmodel.codes[1] = \
            "IplImage * block$id$_img_i0 = NULL;\n" + \
            "int block$id$_int_i1 = $prop[border_size]$;\n" + \
            "IplImage * block$id$_img_o0 = NULL;\n"
        self.blockmodel.codes[2] = \
            'if(block$id$_img_i0){\n' + \
            '\tCvSize size$id$ = cvSize(block$id$_img_i0->width +' + \
            ' block$id$_int_i1 * 2, block$id$_img_i0->height' + \
            ' + block$id$_int_i1 * 2);\n' + \
            '\tblock$id$_img_o0 = cvCreateImage(size$id$,' + \
            ' block$id$_img_i0->depth,block$id$_img_i0->nChannels);\n' + \
            '\tCvPoint point$id$ = cvPoint' + \
            '(block$id$_int_i1, block$id$_int_i1);\n' + \
            '\tCvScalar color = get_scalar_color("$prop[color]$");\n' + \
            '\tcvCopyMakeBorder(block$id$_img_i0, block$id$_img_o0,' + \
            ' point$id$, $prop[type]$, color);\n' + \
            '}\n'

        win = MainWindow()
        self.diagram = Diagram(win)
        self.codetemplate = CodeTemplate()
        #block = Block(diagram, blockmodel)
        #diagram.language = None
        self.code_generator = CodeGenerator(None, None)
        self.diagram.language = None
        self.code_generator = CodeGenerator(self.diagram, None)
        self.diagram.language = ""
        self.code_generator = CodeGenerator(self.diagram, None)
        self.code_generator = CodeGenerator(self.diagram, self.codetemplate)
示例#26
0
 def setUp(self):
     """Do the test basic setup."""
     win = MainWindow()
     language = "python"
     self.blocks_tree_view = BlocksTreeView(win, language)
示例#27
0
 def test_rename_diagram(self):
     diagram = Diagram(MainWindow())
     self.assertIsNone(self.work_area.rename_diagram(diagram))
示例#28
0
 def setUp(self):
     """Do the test basic setup."""
     win = MainWindow()
     self.blocknotebook = BlockNotebook(win)
示例#29
0
 def setUp(self):
     """Do the test basic setup."""
     win = MainControl(MainWindow())
     self.diagram_control = DiagramControl(win)
示例#30
0
 def setUp(self):
     """Do the test basic setup."""
     win = MainWindow()
     self.main_control = MainControl(win)