After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 547091 - ooldtp support for ldtpeditor
ooldtp support for ldtpeditor
Status: RESOLVED FIXED
Product: LDTP
Classification: Other
Component: editor
1.2.0
Other All
: Normal enhancement
: ---
Assigned To: shreyankg
LDTP Development Mailing List
Depends on:
Blocks:
 
 
Reported: 2008-08-09 18:44 UTC by shreyankg
Modified: 2008-08-30 23:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch for ooldtp support (4.88 KB, patch)
2008-08-09 22:57 UTC, shreyankg
committed Details | Review
patch for bugs in ooldtp support (3.53 KB, patch)
2008-08-12 11:53 UTC, shreyankg
none Details | Review
patch for bugs in ooldtp support (4.36 KB, patch)
2008-08-12 12:16 UTC, shreyankg
committed Details | Review

Description shreyankg 2008-08-09 18:44:22 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
Comment 1 shreyankg 2008-08-09 22:57:40 UTC
Created attachment 116268 [details] [review]
patch for ooldtp support
Comment 2 shreyankg 2008-08-10 18:52:38 UTC
new format

from ooldtp import *
from ldtputils import *

try:
        context0 = context ("*gedit*")
        context0.click ("btnNew")
        context0.selectmenuitem ("mnuNew")
except LdtpExecutionError, msg:
        raise
Comment 3 Nagappan Alagappan 2008-08-10 21:08:24 UTC
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')
Comment 4 shreyankg 2008-08-12 11:53:11 UTC
Created attachment 116417 [details] [review]
patch for bugs in ooldtp support

enable:
1. real context names,
2. waittillguiexists() 
3. generate data XML
Comment 5 shreyankg 2008-08-12 12:14:18 UTC
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):
Comment 6 shreyankg 2008-08-12 12:16:36 UTC
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