[Sugar-devel] How to resolve a GError while writing UI tests for Read

Gonzalo Odiard godiard at sugarlabs.org
Mon Jul 28 12:54:36 EDT 2014


Hi Gaurav,

I think I have found a solution to how open a file in Read, hopefully can
be useful in a more general case.
I am not an expert on testing, then would be good if others can confirm
this is the right way:

I have added a method run_activity_with_uri in the UITestCase class

https://github.com/sugarlabs/sugar-toolkit-gtk3/pull/155

Also modified the activity Read to be able to manage the uri

https://git.sugarlabs.org/read/mainline/commit/77cc1020f4c7527b0066538028a12567e168fd07

Then your test_operations.py can be implemented in this way:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os
import logging
import time
from sugar3.test import unittest
from sugar3.test import uitree
from jarabe.journal import model

class OperationsTest(unittest.UITestCase):

    def setUp(self):
        unittest.UITestCase.setUp(self)
        self.bundle_id = "org.laptop.sugar.ReadActivity"

    def test_open_file(self):
        uri = 'file://' + os.getcwd() + '/tests/integration/test.txt'
        logging.error('OPEN WITH URI %s', uri)
        with self.run_activity_with_uri(uri):
            root = uitree.get_root()
            activity = root.find_child(name="Read Activity",
role_name="frame")
            try:
                logging.error(activity.dump())
            except:
                logging.error("EEEEEEEEE : Error")
                pass

Is this a good solution? The change to Read is already pushed,
the change in sugar-toolkit-gtk3 need review.

Gonzalo



On Sun, Jul 27, 2014 at 3:53 AM, Gaurav Parida <gparida94 at gmail.com> wrote:

> 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.
>
> I have attached the test that  I have written for Read till now. In order
> to run it, please follow the given steps-
>
> 1. cd sugar-build/activities/Read.activity
> 2. mkdir -p tests/integration
> 3. cd tests/integration
> 4. cp <Downloads-directory>/test_operations.py ./
>     cp <Downloads-directory>/test.txt ./
> 5. Now run sugar build ./osbuild run
> 6. Open Terminal activity
> 7. cd ~/activities/Read.activity
> 8. ./setup.py check integration #this runs the test
> 9. If everything runs fine, then you can see a tree like structure showing
> the heirarchial arrangement of the activity as seen by atspi.
> 10. If you stumbled with GError, then you see "EEEEEEEEE : Error" in the
> terminal activity.
>
> 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.
>
> If anyone has been able to resolve this problem, then it would be a great
> help to know on how to solve it. Thanks.
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>


-- 
Gonzalo Odiard

SugarLabs - Software for children learning
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140728/832a2295/attachment.html>


More information about the Sugar-devel mailing list