1
# -*- coding: utf-8 -*-
4
# Copyright 2011 Canonical Ltd.
6
# This program is free software: you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License version 3, as published
8
# by the Free Software Foundation.
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranties of
12
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
# PURPOSE. See the GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License along
16
# with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""Tests for the tabbed panel."""
20
from PyQt4 import QtGui
21
from twisted.internet import defer
22
from twisted.trial.unittest import TestCase
24
from ubuntuone.controlpanel.gui.qt import tabbed_panel
27
class FakeOverlayWidget(QtGui.QLabel):
28
"""Fake a widget that does have the show_orvelay attribute."""
30
def __init__(self, *args, **kwargs):
31
super(FakeOverlayWidget, self).__init__(*args, **kwargs)
32
self.show_overlay = False
35
class TabbedPanelTestCase(TestCase):
36
"""Test the tabbed panel."""
38
@defer.inlineCallbacks
41
yield super(TabbedPanelTestCase, self).setUp()
42
self.tab_widget = tabbed_panel.TabbedPanel()
44
def test_all_overlay_supported(self):
45
"""Test when all the widgets support the overlay feature."""
46
labels = [FakeOverlayWidget("Test"),
47
FakeOverlayWidget("Test"),
48
FakeOverlayWidget("Test")]
50
self.tab_widget.addTab(lab, 'label')
52
self.tab_widget.show_overlay = True
53
self.assertTrue(all([l.show_overlay for l in labels]))
54
self.tab_widget.show_overlay = False
55
self.assertFalse(any([l.show_overlay for l in labels]))