~osomon/software-center/qml-5.0

« back to all changes in this revision

Viewing changes to test/gtk3/test_dialogs.py

  • Committer: Olivier Tilloy
  • Date: 2011-11-03 16:42:37 UTC
  • mfrom: (1773.49.652 software-center)
  • Revision ID: olivier@tilloy.net-20111103164237-xhkcn96dmh1gu8a3
Merged the latest changes from trunk.

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
import os
 
5
import sys
 
6
import unittest
 
7
 
 
8
sys.path.insert(0,"..")
 
9
 
 
10
# ensure datadir is pointing to the right place
 
11
import softwarecenter.paths
 
12
softwarecenter.paths.datadir = os.path.join(
 
13
    os.path.dirname(__file__), "..", "..", 'data')
 
14
 
 
15
import softwarecenter.ui.gtk3.dialogs
 
16
 
 
17
# window destory timeout
 
18
TIMEOUT=200
 
19
 
 
20
class TestDialogs(unittest.TestCase):
 
21
    """ basic tests for the various gtk3 dialogs """
 
22
 
 
23
    def test_dependency_dialogs(self):
 
24
        from softwarecenter.ui.gtk3.dialogs.dependency_dialogs import get_test_dialog
 
25
        dia = get_test_dialog()
 
26
        GObject.timeout_add(TIMEOUT, 
 
27
                            lambda: dia.response(Gtk.ResponseType.ACCEPT))
 
28
        dia.run()
 
29
        
 
30
    def test_confirm_repair_broken_cache(self):
 
31
        datadir = softwarecenter.paths.datadir
 
32
        GObject.timeout_add(TIMEOUT, self._close_dialog)
 
33
        res = softwarecenter.ui.gtk3.dialogs.confirm_repair_broken_cache(
 
34
            parent=None, datadir=datadir)
 
35
        self.assertEqual(res, False)
 
36
        
 
37
    def test_error_dialog(self):
 
38
        GObject.timeout_add(TIMEOUT, self._close_dialog)
 
39
        res = softwarecenter.ui.gtk3.dialogs.error(
 
40
            parent=None, primary="primary", secondary="secondary")
 
41
        self.assertEqual(res, False)
 
42
        
 
43
    # helper
 
44
    def _close_dialog(self):
 
45
        softwarecenter.ui.gtk3.dialogs._DIALOG.response(0)
 
46
 
 
47
if __name__ == "__main__":
 
48
    import logging
 
49
    logging.basicConfig(level=logging.DEBUG)
 
50
    unittest.main()