{"id":65,"date":"2007-07-05T00:02:00","date_gmt":"2007-07-05T07:02:00","guid":{"rendered":"http:\/\/sp2hari.com\/?p=65"},"modified":"2020-06-20T09:03:34","modified_gmt":"2020-06-20T09:03:34","slug":"file-roller","status":"publish","type":"post","link":"https:\/\/sp2hari.com\/index.php\/2007\/07\/05\/file-roller\/","title":{"rendered":"file-roller &#8230;"},"content":{"rendered":"<p>When i saw the mail from <a href=\"http:\/\/nagappanal.blogspot.com\/\">nags<\/a> saying<br \/>\n<span style=\"font-style: italic;\">&#8221; Can somebody evaluate it and send me back the results. It was done by <a href=\"http:\/\/yazhini.wordpress.com\/\">Yazhini<\/a>, long time back, but I could not check them.&#8221;<br \/>\n<\/span><\/p>\n<div style=\"text-align: justify;\">even i didn&#8217;t think i will write the test cases for file-roller that night. I just wanted to see the code and maybe make a comment. After seeing the code, i felt really sorry for file-roller \ud83d\ude1b . Yeah now it looks crazy, but not at that time. When evolution, gedit and other applications have new new scripts, why should file-roller have the old test scripts. \ud83d\ude42<\/div>\n<p>So wrote the test cases for file-roller according to the new file-roller and new LDTP.<\/p>\n<div style=\"text-align: justify;\">I will write about what all changes should be made while changing the scripts, so that it will be useful for someone who might change the code for other applications like gcalctool, bugbuddy, gnome-font, gnome-search-tool, gdf etc.<\/div>\n<div style=\"text-align: justify;\">The files can be downloaded from <a href=\"http:\/\/freeshells.ch\/%7Esp2hari\/soc\/fileroller.tar.gz\">here.<\/a> Just take care that you don&#8217;t have a file called ldtptestarchive.tar.gz in your home folder. Apart from that, you need to change the run.xml . I tried the scripts in solaris but setcontext didn&#8217;t work properly there :(. Have to check that soon.<\/div>\n<p>1. Names of objects in applications.<br \/>\nThis has changed a lot, especially in the frame names. In the old scripts for file roller, it will be like<br \/>\n<span style=\"font-style: italic;\">selectmenuitem (&#8216;ArchiveManager&#8217;,&#8217;mnuHelp;mnuAbout&#8217;)<\/span><br \/>\nBut according to the new LDTP, it is better to have<br \/>\n<span style=\"font-style: italic;\">selectmenuitem (&#8216;frmArchiveManager&#8217;,&#8217;mnuHelp;mnuAbout&#8217;) <\/span><\/p>\n<div style=\"text-align: justify;\">Note the way the window name is mentioned in the new version. If has the prefix <span style=\"font-style: italic;\">frm<\/span> in that. The older one might still work but it is better to change soon. The prefix for each and every object can be seen in a file called <a href=\"http:\/\/webcvs.freedesktop.org\/ldtp\/ldtp\/src\/remap.c?view=markup\"><span style=\"font-style: italic;\">remap.c<\/span><\/a> in src folder. The function <span style=\"font-style: italic;\">get_object_info (Accessible *accessible) <\/span>in that file is the one which can give information about the prefix for each object type.<\/div>\n<div style=\"text-align: justify;\">Apart from this, a ldtp function called <a href=\"http:\/\/ldtp.freedesktop.org\/user-doc\/getobjectlist.html\">getobjectlist ()<\/a> is also useful. Another utility called appmap is also useful in this case, but it is better not to use it, since the appmap is obsolete and latest changes are not incorporated into that. I think getobjectlist is the best solution. A tool called at-poke is also very useful to find the objects and object types inside an application.<\/div>\n<p>2. Runner XML.<\/p>\n<div style=\"text-align: justify;\">In the old scripts a python file used to call each and every other test case files using exec(). In many cases this main python file will be the name of the application. For example, check the file-roller.py<\/div>\n<p><span style=\"font-style: italic;\">#To create a new archive<\/span><br \/>\n<span style=\"font-style: italic;\">log (&#8216;Create New Archive&#8217;, &#8216;teststart&#8217;)<\/span><br \/>\n<span style=\"font-style: italic;\">execfile (&#8216;create-archive.py&#8217;)<\/span><br \/>\n<span style=\"font-style: italic;\">log (&#8216;Create New Archive&#8217;, &#8216;testend&#8217;)<\/span><\/p>\n<p><span style=\"font-style: italic;\">time.sleep(2)<\/span><br \/>\n<span style=\"font-style: italic;\">#To open an existing archive and extracing them.<\/span><br \/>\n<span style=\"font-style: italic;\">log (&#8216;Open Extract Archive &#8216;, &#8216;teststart&#8217;)<\/span><br \/>\n<span style=\"font-style: italic;\">execfile (&#8216;open-extract.py&#8217;)<\/span><br \/>\n<span style=\"font-style: italic;\">log (&#8216;Open Extract Archive&#8217;, &#8216;testend&#8217;)<\/span><\/p>\n<div style=\"text-align: justify;\">So this way many scripts are tested from the a single python file. In the new test files, the concept of <a href=\"http:\/\/ldtp.freedesktop.org\/wiki\/How_to_execute_scripts\">ldtprunner<\/a> and <a href=\"http:\/\/ldtp.freedesktop.org\/wiki\/ldtprunner_XML\">runner xml<\/a> is introduced. The links mentioned there are the best place to learn about runner XML. Just for the sake of completion let me add a sample runner xml for the above code here<\/p>\n<\/div>\n<p><span style=\"font-style: italic;\">&lt;ldtp&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;logfileoverwrite&gt;1&lt;\/logfileoverwrite&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;logfile&gt;log.xml&lt;\/logfile&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;group&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;script&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;name&gt;create-archive.py&lt;\/name&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;data&gt;fileroller.xml&lt;\/data&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;\/script&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;script&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;name&gt;open-extract.py&lt;\/name&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;data&gt;fileroller.xml&lt;\/data&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;\/script&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;\/group&gt;<\/span><br \/>\n<span style=\"font-style: italic;\">&lt;\/ldtp&gt;<\/span><\/p>\n<p>Scripts can be easily added, removed and grouped using the runner.xml .<\/p>\n<p>3. <a href=\"http:\/\/ldtp.freedesktop.org\/user-doc\/waittillguiexist.html\">waittillguiexist()<\/a> and <a href=\"http:\/\/ldtp.freedesktop.org\/user-doc\/waittillguinotexist.html\">waittillguinotexist()<\/a>.<\/p>\n<div style=\"text-align: justify;\">The two functions are really useful if you want your code till an object appears or disappears. The docs for these two functions explains the usage clearly. The old test code will have an approximate time.sleep() in their code. A better and proper solution is to incorporate waittillguiexist() and waittillguinotexist() and remove the unwanted time.sleep()<\/div>\n<p>4. LDTPExecutionError :<\/p>\n<div style=\"text-align: justify;\">The old code just has an except block which can catch any exception that occurs. It is better to handle the LDTPExecutionError separately and other errors in a different manner. A typical except block in the new script will be like<\/div>\n<p><span style=\"font-style: italic;\">except LdtpExecutionError, msg:<\/span><br \/>\n<span style=\"font-style: italic;\">\u00a0\u00a0msg = &#8216;open-extract test case failed&#8217;<\/span><br \/>\n<span style=\"font-style: italic;\">\u00a0\u00a0log (msg, &#8216;error&#8217;)<\/span><br \/>\n<span style=\"font-style: italic;\">\u00a0\u00a0raise LdtpExecutionError (msg)<\/span><\/p>\n<p>5. <a href=\"http:\/\/ldtp.freedesktop.org\/wiki\/Data_XML\">Data XML<\/a>.<\/p>\n<div style=\"text-align: justify;\">One of the most important thing in LDTP, which adds great flexibility to the test cases. The filenames and other variables need not be hard coded. <a href=\"http:\/\/ldtp.freedesktop.org\/wiki\/Sample_Data_XML\">A single XML<\/a> (generally called the data XML) can have all the details like the filenames, paths used in a test case and these value can be extracted from the XML file. Thus even the arguments passed to the test cases can be changed using a data XML.<\/div>\n<p>6. <a href=\"http:\/\/ldtp.freedesktop.org\/wiki\/About_Appmap\">Appmap file<\/a>.<\/p>\n<div style=\"text-align: justify;\">Since now in LDTP , the remapping of the objects in application is done automatically, there is no need to use <a href=\"http:\/\/ldtp.freedesktop.org\/user-doc\/initappmap.html\">initappmap()<\/a> or <a href=\"http:\/\/ldtp.freedesktop.org\/user-doc\/remap.html\">remap()<\/a> anymore. So there is no need to have a default map file for each application.<br \/>\nTherefore you can remove the following piece of code if you find it in your test case.<\/div>\n<p><span style=\"font-style: italic;\"><br \/>\nif len (sys.argv) == 1:<br \/>\nif os.access (&#8216;.\/file-roller.map&#8217;, os.F_OK | os.R_OK) == 0:<br \/>\nprint &#8216;Appmap path missing&#8217;<br \/>\nsys.exit(0);<br \/>\nelse:<br \/>\nappmap_path = &#8216;.&#8217;<br \/>\nelse:<br \/>\nappmap_path = sys.argv[1]<br \/>\ninitappmap (appmap_path + &#8216;\/file-roller.map&#8217;)<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When i saw the mail from nags saying &#8221; Can somebody evaluate it and send me back the results. It was done by Yazhini, long time back, but I could not check them.&#8221; even i didn&#8217;t think i will write the test cases for file-roller that night. I just wanted &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":2,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/65\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}