<div dir="ltr">Hi Gonzalo,<div><br></div><div>It does the work as required for the use case. Thanks a lot for the help. I will get on to complete the tests for Read and I will apply the same for imageviewer to open the images.</div>
<div><br></div><div>Thanks,</div><div>Gaurav</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 28, 2014 at 10:24 PM, Gonzalo Odiard <span dir="ltr"><<a href="mailto:godiard@sugarlabs.org" target="_blank">godiard@sugarlabs.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Gaurav,<div><br></div><div>I think I have found a solution to how open a file in Read, hopefully can be useful in a more general case.</div>
<div>I am not an expert on testing, then would be good if others can confirm this is the right way:</div>
<div><br></div><div>I have added a method run_activity_with_uri in the UITestCase class</div><div><br></div><div><a href="https://github.com/sugarlabs/sugar-toolkit-gtk3/pull/155" target="_blank">https://github.com/sugarlabs/sugar-toolkit-gtk3/pull/155</a><br>

</div><div><br></div><div>Also modified the activity Read to be able to manage the uri</div><div><br></div><div><a href="https://git.sugarlabs.org/read/mainline/commit/77cc1020f4c7527b0066538028a12567e168fd07" target="_blank">https://git.sugarlabs.org/read/mainline/commit/77cc1020f4c7527b0066538028a12567e168fd07</a><br>

</div><div><br></div><div>Then your test_operations.py can be implemented in this way:</div><div><br></div><div><div><font face="courier new, monospace">#!/usr/bin/python</font></div><div><font face="courier new, monospace"># -*- coding: UTF-8 -*-</font></div>

<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">import os</font></div><div><font face="courier new, monospace">import logging</font></div><div><font face="courier new, monospace">import time</font></div>

<div><font face="courier new, monospace">from sugar3.test import unittest</font></div><div><font face="courier new, monospace">from sugar3.test import uitree</font></div><div><font face="courier new, monospace">from jarabe.journal import model</font></div>

<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">class OperationsTest(unittest.UITestCase):</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">    def setUp(self):</font></div>

<div><font face="courier new, monospace">        unittest.UITestCase.setUp(self)</font></div><div><font face="courier new, monospace">        self.bundle_id = "org.laptop.sugar.ReadActivity"</font></div><div><font face="courier new, monospace"><br>

</font></div><div><font face="courier new, monospace">    def test_open_file(self):</font></div><div><font face="courier new, monospace">        uri = 'file://' + os.getcwd() + '/tests/integration/test.txt'</font></div>

<div><font face="courier new, monospace">        logging.error('OPEN WITH URI %s', uri)</font></div><div><font face="courier new, monospace">        with self.run_activity_with_uri(uri):</font></div><div><font face="courier new, monospace">            root = uitree.get_root()</font></div>

<div><font face="courier new, monospace">            activity = root.find_child(name="Read Activity", role_name="frame")</font></div><div><font face="courier new, monospace">            try:</font></div>

<div><font face="courier new, monospace">                logging.error(activity.dump())</font></div><div><font face="courier new, monospace">            except:</font></div><div><font face="courier new, monospace">                logging.error("EEEEEEEEE : Error")</font></div>

<div><font face="courier new, monospace">                pass</font></div></div><div><br></div><div>Is this a good solution? The change to Read is already pushed,</div><div>the change in sugar-toolkit-gtk3 need review.</div>

<div><br></div><div>Gonzalo</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Sun, Jul 27, 2014 at 3:53 AM, Gaurav Parida <span dir="ltr"><<a href="mailto:gparida94@gmail.com" target="_blank">gparida94@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><font size="1">I am trying to write tests for Read activity and am facing a 'GError : timeout from dbind' while writing the test for it. The test that  I am trying to write is to open a file in Read Activity. After, searching on the error, I found out that as soom as Read starts, it has some dbus settings but as soon as I open the objectchooser to open the files, it takes the dbus settings of the journal and hence leading to atspi to assume that the read activity has stuck and thus giving the above error.</font><div>


<font size="1"><br></font></div><div><font size="1">I have attached the test that  I have written for Read till now. In order to run it, please follow the given steps-</font></div><div><br></div><div><font size="1">1. cd sugar-build/activities/Read.activity</font></div>


<div><font size="1">2. mkdir -p tests/integration</font></div><div><font size="1">3. cd tests/integration</font></div><div><font size="1">4. cp <Downloads-directory>/test_operations.py ./</font></div><div><font size="1">    </font><span style="font-size:x-small">cp <Downloads-directory>/test.txt ./</span></div>


<div><font size="1">5. Now run sugar build ./osbuild run</font></div><div><font size="1">6. Open Terminal activity</font></div><div><font size="1">7. cd ~/activities/Read.activity</font></div><div><font size="1">8. ./setup.py check integration #this runs the test</font></div>


<div><font size="1">9. If everything runs fine, then you can see a tree like structure showing the heirarchial arrangement of the activity as seen by atspi.</font></div><div><font size="1">10. If you stumbled with GError, then you see "EEEEEEEEE : Error" in the terminal activity.</font></div>


<div><font size="1"><br></font></div><div><font size="1">I am attaching the test_operations.py (test file) , test.txt(sample file that has to be opened in Read activity), screenshot of my Terminal after running the test.</font></div>


<div><font size="1"><br></font></div><div><font size="1">If anyone has been able to resolve this problem, then it would be a great help to know on how to solve it. Thanks. </font></div></div>
<br></div></div>_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org" target="_blank">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Gonzalo Odiard<br><br><div>SugarLabs - Software for children learning <br></div></div>
</font></span></div>
</blockquote></div><br></div>