~alecu/ubuntu-sso-client/timestamp-autofix

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/tests/test_windows.py

  • Committer: Tarmac
  • Author(s): Diego Sarmentero
  • Date: 2011-09-16 12:26:08 UTC
  • mfrom: (783.3.7 ubuntu-sso-client-845750)
  • Revision ID: tarmac-20110916122608-ppk8x30y1v1ftyxe
- Fixed button style from Reset Password Page and Forgotten Password Page. (LP: #845750).

Show diffs side-by-side

added added

removed removed

Lines of Context:
971
971
        self.controller.setupUi(self.view)
972
972
 
973
973
 
974
 
class FakeForgottenPasswordPage(FakeView):
 
974
class FakeForgottenPasswordPage(tests.FakePageUiStyle):
975
975
    """Fake the page."""
976
976
 
977
977
    def __init__(self):
 
978
        super(FakeForgottenPasswordPage, self).__init__()
978
979
        self.email_address_line_edit = self
979
980
        self.send_button = self
980
 
        self._text = ""
981
 
        self._enabled = False
982
 
        super(FakeForgottenPasswordPage, self).__init__()
983
 
 
984
 
    def text(self):
985
 
        """Return text."""
986
 
        return self._text
987
 
 
988
 
    # setText, setEnabled are inherited
989
 
    # pylint: disable=C0103
990
 
    def setText(self, text):
991
 
        """Save text."""
992
 
        self._text = text
993
 
 
994
 
    def setEnabled(self, value):
995
 
        """Fake setEnabled."""
996
 
        self._enabled = value
997
 
 
998
 
    def enabled(self):
999
 
        """Fake enabled."""
1000
 
        return self._enabled
1001
981
 
1002
982
 
1003
983
class ForgottenPasswordControllerValidationTest(TestCase):
1017
997
        """Store 'args' and 'kwargs' for test assertions."""
1018
998
        self._called = (args, kwargs)
1019
999
 
 
1000
    def test_page_initialized(self):
 
1001
        """Test the initial state of the page when it is loaded."""
 
1002
        self.controller.pageInitialized()
 
1003
        self.assertFalse(self.controller.view.send_button.enabled())
 
1004
        self.assertTrue(self.controller.view.send_button.properties['default'])
 
1005
        self.assertTrue("DisabledState" in self.controller.view.properties)
 
1006
        self.assertEqual(self.controller.view.properties["DisabledState"],
 
1007
            not self.controller.view.send_button.enabled())
 
1008
        self.assertTrue(self.controller.view.properties.get('unpolish', False))
 
1009
        self.assertTrue(self.controller.view.properties.get('polish', False))
 
1010
 
1020
1011
    def test_valid(self):
1021
1012
        """The submit button should be enabled with a valid email."""
1022
1013
        self.controller.view.email_address_line_edit.setText("a@b")
1024
1015
            self.controller.view.email_address_line_edit.text()), u"")
1025
1016
        self.controller._validate()
1026
1017
        self.assertTrue(self.controller.view.send_button.enabled())
 
1018
        self.assertTrue("DisabledState" in self.controller.view.properties)
 
1019
        self.assertEqual(self.controller.view.properties["DisabledState"],
 
1020
            not self.controller.view.send_button.enabled())
 
1021
        self.assertTrue(self.controller.view.properties.get('unpolish', False))
 
1022
        self.assertTrue(self.controller.view.properties.get('polish', False))
1027
1023
 
1028
1024
    def test_invalid(self):
1029
1025
        """The submit button should be disabled with an invalid email."""
1032
1028
            unicode(self.controller.view.email_address_line_edit.text()), u"")
1033
1029
        self.controller._validate()
1034
1030
        self.assertFalse(self.controller.view.send_button.enabled())
 
1031
        self.assertTrue("DisabledState" in self.controller.view.properties)
 
1032
        self.assertEqual(self.controller.view.properties["DisabledState"],
 
1033
            not self.controller.view.send_button.enabled())
 
1034
        self.assertTrue(self.controller.view.properties.get('unpolish', False))
 
1035
        self.assertTrue(self.controller.view.properties.get('polish', False))
1035
1036
 
1036
1037
    def test_empty(self):
1037
1038
        """The submit button should be disabled without email."""
1225
1226
                                                                    password))
1226
1227
 
1227
1228
 
1228
 
class FakeResetPasswordPage(object):
 
1229
class FakeResetPasswordPage(tests.FakePageUiStyle):
1229
1230
 
1230
1231
    """Fake ResetPasswordPage."""
1231
1232
 
1232
1233
    def __init__(self, *args):
1233
1234
        """Initialize."""
1234
 
        self.ui = self
 
1235
        super(FakeResetPasswordPage, self).__init__()
1235
1236
        self.ui.reset_code_line_edit = FakeLineEdit()
1236
1237
        self.ui.password_line_edit = FakeLineEdit()
1237
1238
        self.ui.confirm_password_line_edit = FakeLineEdit()
1238
1239
        self.reset_password_button = self
1239
1240
        self._enabled = 9  # Intentionally wrong.
1240
1241
 
1241
 
    # setEnabled is inherited
1242
 
    # pylint: disable=C0103
1243
 
    def setEnabled(self, value):
1244
 
        """Fake setEnabled."""
1245
 
        self._enabled = value
1246
 
 
1247
 
    def enabled(self):
1248
 
        """Fake enabled."""
1249
 
        return self._enabled
1250
 
 
1251
1242
 
1252
1243
class ResetPasswordControllerValidationTest(TestCase):
1253
1244
 
1260
1251
        self.controller.view = FakeResetPasswordPage()
1261
1252
        self._called = False
1262
1253
 
 
1254
    def test_page_initialized(self):
 
1255
        """Test the initial state of the page when it is loaded."""
 
1256
        self.controller.pageInitialized()
 
1257
        self.assertFalse(
 
1258
            self.controller.view.reset_password_button.enabled())
 
1259
        self.assertTrue(
 
1260
            self.controller.view.reset_password_button.properties['default'])
 
1261
        self.assertTrue("DisabledState" in self.controller.view.properties)
 
1262
        self.assertEqual(self.controller.view.properties["DisabledState"],
 
1263
            not self.controller.view.reset_password_button.enabled())
 
1264
        self.assertTrue(self.controller.view.properties.get('unpolish', False))
 
1265
        self.assertTrue(self.controller.view.properties.get('polish', False))
 
1266
 
1263
1267
    def _set_called(self, *args, **kwargs):
1264
1268
        """Store 'args' and 'kwargs' for test assertions."""
1265
1269
        self._called = (args, kwargs)
1271
1275
        self.controller.view.confirm_password_line_edit.setText("1234567A")
1272
1276
        self.controller._validate()
1273
1277
        self.assertTrue(self.controller.view.reset_password_button.enabled())
 
1278
        self.assertTrue("DisabledState" in self.controller.view.properties)
 
1279
        self.assertEqual(self.controller.view.properties["DisabledState"],
 
1280
            not self.controller.view.reset_password_button.enabled())
 
1281
        self.assertTrue(self.controller.view.properties.get('unpolish', False))
 
1282
        self.assertTrue(self.controller.view.properties.get('polish', False))
1274
1283
 
1275
1284
    def test_invalid_code(self):
1276
1285
        """Disable the button with an invalid code."""
1279
1288
        self.controller.view.confirm_password_line_edit.setText("1234567A")
1280
1289
        self.controller._validate()
1281
1290
        self.assertFalse(self.controller.view.reset_password_button.enabled())
 
1291
        self.assertTrue("DisabledState" in self.controller.view.properties)
 
1292
        self.assertEqual(self.controller.view.properties["DisabledState"],
 
1293
            not self.controller.view.reset_password_button.enabled())
 
1294
        self.assertTrue(self.controller.view.properties.get('unpolish', False))
 
1295
        self.assertTrue(self.controller.view.properties.get('polish', False))
1282
1296
 
1283
1297
    def test_invalid_password(self):
1284
1298
        """Disable the button with an invalid password."""