1
# -*- coding: utf-8 -*-
3
# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
5
# Copyright 2010 Canonical Ltd.
7
# This program is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License version 3, as published
9
# by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
# PURPOSE. See the GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License along
17
# with this program. If not, see <http://www.gnu.org/licenses/>.
19
"""The test suite for the control panel user interface."""
23
from twisted.trial.unittest import TestCase
25
from ubuntuone.control_panel import gui, utils
28
class FakedBuilder(object):
29
"""A faked builder."""
32
self.add_from_file = lambda fname: setattr(self, 'filename', fname)
33
self.connect_signals = lambda arg: setattr(self, 'signals', arg)
34
self.get_objects = lambda: []
37
class BasicControlPanelUITestCase(TestCase):
38
"""The basic test suite for the control panel user interface."""
43
def _set_called(self, *args, **kwargs):
44
"""Store 'args' and 'kwargs' for test assertions."""
45
self._called = (args, kwargs)
47
def test_ui_can_be_created(self):
48
"""UI main class exists and can be created."""
49
ui = gui.ControlPanelUI()
50
self.assertTrue(ui is not None)
52
def test_main_start_gtk_main_loop(self):
53
"""The GTK main loop is started when calling main()."""
54
ui = gui.ControlPanelUI()
55
self.patch(gtk, 'main', self._set_called)
57
self.assertEqual(self._called, ((), {}), 'gtk.main was called.')
59
def test_ui_file_is_read_at_startup(self):
60
"""The ui file is read and parse at startup."""
61
self.patch(gtk, 'Builder', FakedBuilder)
62
ui = gui.ControlPanelUI()
63
self.assertEqual(ui.builder.filename, utils.get_data_file('main.ui'))
65
def test_signals_are_connected_at_startup(self):
66
"""The signals are connectedt at startup."""
67
self.patch(gtk, 'Builder', FakedBuilder)
68
ui = gui.ControlPanelUI()
69
self.assertEqual(ui.builder.signals, ui.builder)