GNOME Bugzilla – Bug 547091
ooldtp support for ldtpeditor
Last modified: 2008-08-30 23:03:40 UTC
LDTP Editor should be able to generate ooldtp scripts when an appropriate option is checked in the preferences dialog. Converted code when ooldtp option unchecked: from ldtp import * from ldtputils import * try: click ("*gedit*", "btnNew") selectmenuitem ("*gedit*", "mnuNew") except LdtpExecutionError, msg: raise Converted code when ooldtp option checked: from ooldtp import * from ldtputils import * try: context ("*gedit*").click ("btnNew") context ("*gedit*").selectmenuitem ("mnuNew") except LdtpExecutionError, msg: raise
Created attachment 116268 [details] [review] patch for ooldtp support
new format from ooldtp import * from ldtputils import * try: context0 = context ("*gedit*") context0.click ("btnNew") context0.selectmenuitem ("mnuNew") except LdtpExecutionError, msg: raise
Things to be fixed: * Code doesn't handle data XML part * Instead of context0, context1 etc, it has to use the actual context name ! Example: gedit = context ('*gedit*') gedit.click ('btnNew')
Created attachment 116417 [details] [review] patch for bugs in ooldtp support enable: 1. real context names, 2. waittillguiexists() 3. generate data XML
Comment on attachment 116417 [details] [review] patch for bugs in ooldtp support diff --git a/python/ChangeLog b/python/ChangeLog index 4bc36fb..beca898 100644 --- a/python/ChangeLog +++ b/python/ChangeLog @@ -1,3 +1,8 @@ +2008-08-12 Shreyank Gupta <shreyankg@gmail.com> + + * ldtpeditor (LdtpEditorGui): resolved ooldtp issues regarding + waittillguiexist() and Generate Data XML + 2008-08-10 Shreyank Gupta <shreyankg@gmail.com> * ldtpeditor (LdtpEditorGui): Added code to generate OO LDTP diff --git a/python/ldtpeditor b/python/ldtpeditor index 7c49e39..14e92a9 100755 --- a/python/ldtpeditor +++ b/python/ldtpeditor @@ -342,11 +342,16 @@ class LdtpEditorGui (gnome.Program): data = code [2][re.search ('\w+', code [2]).start () : len (code [2]) - 2] lines = '%s\t%s = xmlParser.gettagvalue (\"%s\")\n' \ % (lines, component, component) + if self.chkGenerateOoldtp == True and line.strip() != '' \ + and re.match ('wait\s', line) == None: + lines = '%s\t%s\"%s\", %s [0])\n' \ + % (lines, ldtplib.libldtpcodegen.objectOrient (code [0]), component, component) + else: lines = '%s\t%s, \"%s\", %s [0])\n' \ % (lines, code [0], component, component) xml = '%s<%s>%s</%s>\n' % (xml, component, saxutils.escape (data), component) continue - if self.chkGenerateOoldtp == True and line.strip() != '' and re.match ('wait', line) == None: + if self.chkGenerateOoldtp == True and line.strip() != '' and re.match ('wait\s', line) == None: line = ldtplib.libldtpcodegen.objectOrient (line) lines = '%s\t%s\n' % (lines, line) #lines += '\n\tlog (\"test script\", \"pass\")\n' diff --git a/python/ldtplib/ChangeLog b/python/ldtplib/ChangeLog index 01136c8..6490aa7 100644 --- a/python/ldtplib/ChangeLog +++ b/python/ldtplib/ChangeLog @@ -1,3 +1,7 @@ +2008-08-12 Shreyank Gupta <shreyankg@gmail.com> + * ldtpeditor (LdtpEditorGui): resolved ooldtp issues regarding + real context names + 2008-08-10 Shreyank Gupta <shreyankg@gmail.com> * libldtpcodegen.py (objectOrient): Function to generate OO LDTP diff --git a/python/ldtplib/libldtpcodegen.py b/python/ldtplib/libldtpcodegen.py index 5616150..35b61c9 100644 --- a/python/ldtplib/libldtpcodegen.py +++ b/python/ldtplib/libldtpcodegen.py @@ -48,7 +48,7 @@ APPHOME = "%s/.ldtp" % os.environ['HOME'] APPROOT = "/usr/share/ldtp" #ooldtp support Global -context = [] +contextList = [] # Let us not register our application under at-spi application list os.environ ['GTK_MODULES'] = '' @@ -668,7 +668,6 @@ def getapps (): def wildcard (str): global appList if len (appList) == 0: - print "Reading Data from file" appList = getapps () for item in appList: regex= '\"\S*?%s\S*?\"' % item @@ -691,24 +690,29 @@ def saveAppList (newAppList): #oldtp support specific function... initContext def initContext(): - global context - context = [] + global contextList + contextList = [] #ooldtp support specific function... objectOrient def objectOrient (line): - global context + global contextList re1 = re.compile ('\".*?\"') - shrink = re1.findall(line)[0] + shrink = re1.findall (line)[0] + re3 = re.compile ('\W|^\d*') + context = re3.sub ('', shrink) re2 = re.compile ('\".*?\"\,\s') + if re2.search (line) != None: parts = re2.split (line, 1) - for all in context: - if all == shrink: - line = 'context%d.%s%s' % (context.index(all), parts[0], parts[1]) + else: + parts = re1.split (line, 1) + for all in contextList: + if all == context: + line = '%s.%s%s' % (context, parts[0], parts[1]) return line - context.append (shrink) - last = len(context) - 1 - line = 'context%d = context(%s)\n\t' % (last, shrink) - line = '%scontext%d.%s%s' % (line, last, parts[0], parts[1]) + contextList.append (context) + #last = len(context) - 1 + line = '%s = context(%s)\n\t' % (context, shrink) + line = '%s%s.%s%s' % (line, context, parts[0], parts[1]) return line def callback (guiCallbackFunc, data, timeElapsed = None):
Created attachment 116418 [details] [review] patch for bugs in ooldtp support patch for bugs in ooldtp support enable: 1. real context names, 2. waittillguiexists() 3. generate data XML including ChangeLog