
| Current Path : /home/ift/52_procpy/dataninja/test/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //home/ift/52_procpy/dataninja/test/test1.py |
# coding: utf8
import os,re,sys,time
import procpy
import random
from . import autotest_logging
class Test1 (object):
def __init__ (self,api):
self.api = api
def run (self):
#************************************************Test Cases*******************************************
#************************test 1: DONE******************************
print ("LOL")
self.test_1('graph1.py')
def test_1(self, name):
autotest_logging.info ( 'task_test2: Test 1 build graph running')
autotest_logging.info ( 't01 --> t02')
self.build_graph(name, 2, [[0,1]])
self.show_grid
autotest_logging.info ( 'task_test2: test 1 run.----------')
autotest_logging.info('\n')
#************************test 1: DONE******************************
'''self.test_1_1('graph1.py')
def test_1_1(self, name):
autotest_logging.info ( 'task_test2: Test 1 build graph running')
autotest_logging.info ( 't01 --> t02*')
self.build_graph(name, 2, [[0,1], [1,1]])
self.show_grid
autotest_logging.info ( 'task_test2: test 1 run.----------')
autotest_logging.info('\n')
#************************test 1: DONE******************************
self.test_1_2('graph1.py')
def test_1_2(self, name):
autotest_logging.info ( 'task_test2: Test 1 build graph running...')
autotest_logging.info ( 't01 <--> t02')
self.build_graph(name, 2, [[0,1],[1,0]])
self.show_grid
autotest_logging.info ( 'task_test2: test 1 run.----------')
autotest_logging.info('\n')
#************************test 1: DONE******************************
self.test_1_3('graph1.py')
def test_1_3(self, name):
autotest_logging.info ( 'task_test2: Test 1 build graph running...')
autotest_logging.info ( 't00 <-->> t01')
self.build_graph(name, 2, [[0,1],[1,0],[0,1]])
self.show_grid
autotest_logging.info ( 'task_test2: test 1 run.----------')
autotest_logging.info('\n')
#************************test 1: DONE******************************
self.test_1_4('graph1.py')
def test_1_4(self, name):
autotest_logging.info ( 'task_test2: Test 1 build graph running...')
autotest_logging.info ( 't00 <<-->> t01')
self.build_graph(name, 2, [[0,1],[1,0],[0,1],[1,0]])
self.show_grid
autotest_logging.info ( 'task_test2: test 1 run.----------')
#***************************************test 2: DONE*************
self.test_2('graph2.py')
def test_2(self, name):
autotest_logging.info ( 'task_test2: Test 3 build graph running...')
autotest_logging.info ( 't01 --> t02')
autotest_logging.info ( 't01 --> t03')
autotest_logging.info ( 't01 --> t04')
self.build_graph(name, 5, [[0,1],[1,2],[1,3],[2,3],[3,2]])
autotest_logging.info ( 'task_test2: test 2 run.----------')
#***************************************test 2: DONE*************
self.test_3('graph3.py')
def test_3(self, name):
autotest_logging.info ('task_test2: Test build graph running...')
autotest_logging.info ('t01 --> t02 --> t03 --> t04')
self.build_graph(name, 4, [[0,1],[1,2],[2,3]])
autotest_logging.info ('task_test2: test 2 run.----------')
autotest_logging.info('\n')
#***************************************test 2: DONE*************
self.test_3_1('graph3.py')
def test_3_1(self, name):
autotest_logging.info ( 'task_test2: Test build graph running...')
autotest_logging.info ( 't01 --> t02 --> t03 --> t04')
autotest_logging.info ( 't01 <-- t04')
self.build_graph(name, 5, [[0,1],[1,2],[2,3],[3,0]])
autotest_logging.info ( 'task_test2: test 2 run.----------')
autotest_logging.info('\n')
#***************************************test 2: DONE*************
self.test_3_2('graph3.py')
def test_3_2(self, name):
autotest_logging.info ( 'task_test2: Test build graph running...')
autotest_logging.info ( 't01 <--> t02 <--> t03 <--> t04')
self.build_graph(name, 4, [[0,1],[1,0],[1,2],[2,1],[2,3],[3,2]])
autotest_logging.info ( 'task_test2: test 2 run.----------')
autotest_logging.info('\n')
#************************test 4: DONE******************************
self.test_4('rearr_graph1.py')
def test_4(self, name):
autotest_logging.info ( 'task_test2: Test 4 rearrange the graph running...')
autotest_logging.info ( 't00 --> t01 --> t02 --> t03')
autotest_logging.info ( ' t01 --> t03')
self.build_graph(name, 4, [[0,1],[1,2],[1,3],[2,3]])
self.rearr_graph
autotest_logging.info ( 'task_test2: test 4 run.----------')
autotest_logging.info('\n')
#************************test 5: DONE******************************
self.test_5('rearr_sugiyama1.py')
def test_5(self, name):
autotest_logging.info ( 'task_test2: Test 5 rearrange the graph running...')
autotest_logging.info ( 't00 --> t01 --> t02 --> t03')
autotest_logging.info ( ' t01 --> t03')
self.build_graph(name, 4, [[0,1],[1,2],[1,3],[2,3]])
self.rearr_sugiyama
autotest_logging.info ( 'task_test2: test 5 run.----------')
autotest_logging.info('\n')
#************************test 6: DONE******************************
self.test_6('rearr_circle1.py')
def test_6(self, name):
autotest_logging.info ( 'task_test2: Test 6 rearrange the graph running...')
autotest_logging.info ( 't00 --> t01 --> t02 --> t03')
autotest_logging.info ( ' t01 --> t03')
self.build_graph(name, 4, [[0,1],[1,2],[1,3],[2,3]])
self.rearr_circle
autotest_logging.info ( 'task_test2: test 6 run.----------')
autotest_logging.info('\n')
#************************test 7: DONE******************************
self.test_7('rearr_swimlane1.py')
def test_7(self, name):
autotest_logging.info ( 'task_test2: Test 7 rearrange the graph running...')
autotest_logging.info ( 't00 --> t01 --> t02 --> t03')
autotest_logging.info ( ' t01 --> t03')
self.build_graph(name, 4, [[0,1],[1,2],[1,3],[2,3]])
self.rearr_circle
autotest_logging.info ( 'task_test2: test 7 run.----------')
autotest_logging.info('\n')
'''
#************************************************UTILITIY FUNCTIONS (UF)*******************************************
#********************************UF: open_graph DONE*****************************************
# From 'Gui1' corresponding to 'self.api.gui' in Test1
def open_graph (self, path):
print ('opening graph ...')
return self.api.gui.fileopen(path)
#********************************UF: create_block DONE*****************************************
# Draws the a block with the given x, y, width and height property inside the given tab.
def create_block (self, tab, block=[0,0,0,0]):
tab.create_block(block)
#********************************UF: connect_blocks DONE*****************************************
# Connects the given blocks pairs drawn inside the given tab together.
#e.g.: self.connect_blocks (self.tab, [[0,1]])
def connect_blocks (self, tab, connectors=[]):
for i in range(len(connectors)):
self.api.next(2, self.click_once(self.tab.blocks[connectors[i][0]]))
self.api.next(2, self.click_twice(self.tab.blocks[connectors[i][1]]))
#********************************UF: build_graph DONE*****************************************
#Build a graph with the given numbers of blocks and connectors.
#e.g.: self.build_graph ('graph.py', 2, [[0,1]])
def build_graph (self, path, nbr_of_block, connectors=[]):
self.tab = self.open_graph(path)
print ('building graph...')
for i in range(nbr_of_block):
dx = (random.randint(1, nbr_of_block))
dy = (random.randint(1, nbr_of_block))
self.api.next(2, self.create_block(self.tab, [100*dx, 100*dy, 70, 40]))
self.api.next(2, self.connect_blocks (self.tab, connectors))
#self.api.next(10, self.save_graph)
print ('graph built.')
#********************************UF: show_grid WIP*****************************************
def show_grid(self):
print ('Showing the grid ...')
self.api.next(2, self.api.gui.loopobj.app.event_generate('<Control-r>'))
#********************************UF: save_graph WIP*****************************************
# From 'Gui1' corresponding to 'self.api.gui' in Test1
def xxxsave_graph (self):
print ('saving ...')
self.api.gui.filesave
print ('saved.')
#********************************UF: click_once DONE****************************************
# From 'Block' corresponding to 'self.tab.blocks[i]' in Test1
def click_once (self, block):
if 'content' in vars(block):
block.content.event_generate("<Button-1>",x=100, y=100)
block.content.event_generate("<ButtonRelease-1>",x=100, y=100)
#****************************UF: click_twice DONE********************************************
def click_twice (self, block):
if 'content' in vars(block):
block.content.event_generate("<Button-1>",x=100, y=100)
block.content.event_generate("<ButtonRelease-1>",x=100, y=100)
block.content.event_generate("<B1-Motion>",x=100, y=100)
block.content.event_generate("<Button-1>",x=100, y=100)
block.content.event_generate("<ButtonRelease-1>",x=100, y=100)
#****************************UF: rearr_graph DONE********************************************
# From 'Gui1' corresponding to 'self.api.gui' in Test1
def rearr_graph (self):
print ('rearranging the graph ...')
self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-d>'))
#****************************UF: rearr_sugiyama DONE********************************************
# From 'Gui1' corresponding to 'self.api.gui' in Test1
def rearr_sugiyama (self):
print ('rearranging the graph ...')
self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-q>'))
#****************************UF: rearr_circle DONE********************************************
# From 'Gui1' corresponding to 'self.api.gui' in Test1
def rearr_circle (self):
print ('rearranging the graph ...')
self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-i>'))
#****************************UF: rearr_swimlane DONE********************************************
# From 'Gui1' corresponding to 'self.api.gui' in Test1
def rearr_swimlane (self):
print ('rearranging the graph ...')
self.api.next(3, self.api.gui.loopobj.app.event_generate('<Control-e>'))
#*************************prod2 20160822****************************************************
'''
def run (self):
self.tab = self.api.gui.fileopen("eee.py")
#self.tab.event_generate("<ButtonRelease-1>",x=100,y=100)
#self.tab.graphcanvas.event_generate("<Double-Btton-1>",x=100,y=100)
self.api.next(3,self.t01)
def t01 (self):
self.tab.create_block([100,100,70,30])
self.api.next(3,self.t02)
def t02 (self):
self.tab.create_block([200,200,70,30])
self.api.next(3,self.t03)
def t03 (self):
self.tab.blocks[0].press_button()
time.sleep(0.05)
self.tab.blocks[0].release_button()
'''