~nataliabidart/software-center/winged-migration

« back to all changes in this revision

Viewing changes to tests/gtk3/test_install_progress.py

  • Committer: Natalia B. Bidart
  • Date: 2012-05-30 18:39:55 UTC
  • mto: This revision was merged to the branch mainline in revision 3030.
  • Revision ID: natalia.bidart@canonical.com-20120530183955-zbnjczayktmmg5tv
- Initial test cleanup:
  - Renamed test/ dir to tests/.
  - Isolated test code into tests/ directory, including moving all the
    get_test_window_foo from the gtk3 production modules to
    tests/gtk3/windows.py module.
  - Removed all the calls to Gtk.main() in gtk3 tests since that blocks the
    execution of the suite.
  - Pep8 and pyflakes fixes in the files already modified in this branch.
  - Minor bug fix in the softwarecenter/log.py module when trying to create a
    log dir with proper perms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
from gi.repository import Gtk
4
 
import time
5
1
import unittest
6
2
 
7
 
from testutils import setup_test_env
 
3
from tests.utils import (
 
4
    do_events_with_sleep,
 
5
    setup_test_env,
 
6
    start_dummy_backend,
 
7
    stop_dummy_backend,
 
8
)
8
9
setup_test_env()
9
10
 
10
11
 
11
12
from softwarecenter.db.application import Application
12
 
from softwarecenter.testutils import start_dummy_backend, stop_dummy_backend
 
13
from tests.gtk3.windows import get_test_window_appdetails
13
14
 
14
 
TIMEOUT=300
15
15
 
16
16
class TestViews(unittest.TestCase):
17
17
 
18
 
    def setUp(self):
19
 
        start_dummy_backend()
20
 
        
21
 
    def tearDown(self):
22
 
        stop_dummy_backend()
 
18
    #def setUp(self):
 
19
    #    start_dummy_backend()
 
20
    #    self.addCleanup(stop_dummy_backend)
23
21
 
24
22
    def test_install_appdetails(self):
25
 
        from softwarecenter.ui.gtk3.views.appdetailsview import get_test_window_appdetails
26
23
        win = get_test_window_appdetails()
27
24
        view = win.get_data("view")
28
25
        view.show_app(Application("", "2vcard"))
29
 
        self._p()
30
 
        app = view.app
31
 
        view.backend.install(app, "")
32
 
        self._p()
 
26
        view.backend.emit('transaction-progress-changed',
 
27
            view.app_details.pkgname, 10)
 
28
        do_events_with_sleep()
 
29
 
33
30
        self.assertTrue(view.pkg_statusbar.progress.get_property("visible"))
34
31
 
35
 
    def _p(self):
36
 
        for i in range(20):
37
 
            time.sleep(0.1)
38
 
            while Gtk.events_pending():
39
 
                Gtk.main_iteration()
40
32
 
41
33
if __name__ == "__main__":
42
 
    import logging
43
 
    logging.basicConfig(level=logging.INFO)
44
34
    unittest.main()