~nataliabidart/software-center/winged-migration

« back to all changes in this revision

Viewing changes to tests/gtk3/test_panes.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, GObject
4
1
import unittest
5
2
 
6
 
from testutils import setup_test_env
 
3
from tests.utils import (
 
4
    do_events,
 
5
    setup_test_env,
 
6
)
7
7
setup_test_env()
8
8
 
9
 
TIMEOUT=300
 
9
from tests.gtk3 import windows
 
10
 
10
11
 
11
12
class TestPanes(unittest.TestCase):
12
13
 
13
14
    def test_availablepane(self):
14
 
        from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
15
 
        win = get_test_window()
16
 
        GObject.timeout_add(TIMEOUT, lambda: win.destroy())
17
 
        Gtk.main()
 
15
        win = windows.get_test_window_availablepane()
 
16
        self.addCleanup(win.destroy)
18
17
 
19
18
    def test_globalpane(self):
20
 
        from softwarecenter.ui.gtk3.panes.globalpane import get_test_window
21
 
        win = get_test_window()
22
 
        GObject.timeout_add(TIMEOUT, lambda: win.destroy())
23
 
        Gtk.main()
 
19
        win =  windows.get_test_window_globalpane()
 
20
        self.addCleanup(win.destroy)
24
21
 
25
22
    def test_pendingpane(self):
26
 
        from softwarecenter.ui.gtk3.panes.pendingpane import get_test_window
27
 
        win = get_test_window()
28
 
        GObject.timeout_add(TIMEOUT, lambda: win.destroy())
29
 
        Gtk.main()
 
23
        win =  windows.get_test_window_pendingpane()
 
24
        self.addCleanup(win.destroy)
30
25
 
31
26
    def test_historypane(self):
32
 
        from softwarecenter.ui.gtk3.panes.historypane import get_test_window
33
 
        win = get_test_window()
34
 
        GObject.timeout_add(TIMEOUT, lambda: win.destroy())
35
 
        Gtk.main()
 
27
        win =  windows.get_test_window_historypane()
 
28
        self.addCleanup(win.destroy)
36
29
 
37
30
    def test_installedpane(self):
38
 
        from softwarecenter.ui.gtk3.panes.installedpane import get_test_window
39
 
        win = get_test_window()
 
31
        win =  windows.get_test_window_installedpane()
 
32
        self.addCleanup(win.destroy)
40
33
        pane = win.get_data("pane")
41
34
        # ensure it visible
42
35
        self.assertTrue(pane.get_property("visible"))
43
36
        # ensure the treeview is there and has data
44
 
        self._p()
 
37
        do_events()
45
38
        self.assertTrue(len(pane.treefilter.get_model()) > 5)
46
 
        # schedule close
47
 
        GObject.timeout_add(TIMEOUT, lambda: win.destroy())
48
 
        Gtk.main()
49
 
 
50
 
    def _p(self):
51
 
        while Gtk.events_pending():
52
 
            Gtk.main_iteration()
53
39
 
54
40
 
55
41
if __name__ == "__main__":
56
 
    import logging
57
 
    logging.basicConfig(level=logging.DEBUG)
58
42
    unittest.main()