1
# -*- coding: utf-8 -*-
3
# Copyright 2012 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""The test suite for Sign In UI."""
19
from PyQt4 import QtGui
20
from twisted.internet import defer
22
from ubuntu_sso.qt import sign_in_page as gui
23
from ubuntu_sso.qt.ui.choose_sign_in_ui import Ui_ChooseSignInPage
24
from ubuntu_sso.qt.tests import BaseTestCase, FakeMainWindow, FakeSignal
27
class SignInPageTestCase(BaseTestCase):
28
"""Test the SignInPage code."""
30
@defer.inlineCallbacks
32
"""Initialize this test instance."""
33
yield super(SignInPageTestCase, self).setUp()
34
self.signals_results = []
35
self.patch(gui.SignInPage, "existingAccountSelected", FakeSignal())
36
self.patch(gui.SignInPage, "newAccountSelected", FakeSignal())
37
self.patch(gui.SignInPage, "singInCanceled", FakeSignal())
38
self.ui = gui.SignInPage(Ui_ChooseSignInPage(), QtGui.QPixmap())
40
def test_show_event(self):
41
"""Check the page is initialized correctly."""
42
wizard = FakeMainWindow()
43
self.patch(self.ui, 'wizard', lambda *args: wizard)
44
self.ui.initializePage()
46
self.addCleanup(self.ui.hide)
47
self.assertTrue(self.ui.ui.existing_account_button.isDefault())
49
# pylint: disable=W0212
50
def test_set_next_existing(self):
51
"""Test _set_next_existing method."""
55
self.signals_results.append(1)
56
self.ui.existingAccountSelected.connect(slot)
57
self.ui._set_next_existing()
58
self.assertIn(1, self.signals_results)
60
def test_set_next_new(self):
61
"""Test _set_next_existing method."""
65
self.signals_results.append(1)
66
self.ui.newAccountSelected.connect(slot)
67
self.ui._set_next_new()
68
self.assertIn(1, self.signals_results)
69
# pylint: enable=W0212