~ubuntu-branches/ubuntu/precise/ubuntuone-control-panel/precise-updates

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/qt/main/tests/test_main.py

  • Committer: Package Import Robot
  • Author(s): Natalia Bidart (nessita), Natalia B. Bidart, Roberto Alsina, Rodney Dawes
  • Date: 2012-03-07 17:37:47 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20120307173747-0eex8aezexmbfmve
Tags: 2.99.90-0ubuntu1
* New upstream release:
  [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
    - Changed the initial signin page so both login and register options
      are shown, and when clicked, the user is presented with either the Qt
      login dialog, or the Qt registration dialog (LP: #933576).
    - 'Apply these settings' button should be at the bottom right corner
      in the Settings tab (LP: #944120).
    - No more strings coming up from the Designer ui files (LP: #938626).
    - Make gettext return unicode so we can format strings
      with unicode variables (LP: #937809).
  [ Roberto Alsina <roberto.alsina@canonical.com> ]
    - Added a barebones manpage for ubuntuone-control-panel-qt
      (LP: #933021).
    - Preserved the scrollbar position when clearing/filling the folder
      list (LP: #942355).
    - Added keyboard shortcuts for quitting the control panel
      (LP: #900753).
    - Cleanup the ubuntuone-control-panel-qt script moving all logic into
      the main module (LP: #938102).
    - Parse Qt options correctly (LP: #910834).
    - Migrated to argparse when parsin command line options.
  [ Rodney Dawes <rodney.dawes@canonical.com> ]
    - Remove the GTK+ 2.x control panel (LP: #934270).
    - Pass ubuntuone-installer as app name to QApplication to avoid
      duplication (LP: #939691).
* debian/control:
  - Bumped dependencies on ubuntu-sso-client to 2.99.90, on
    ubuntuone-client to 2.99.90, and on ubuntuone-installer to 2.99.90.
  - Converted ubuntuone-control-panel-gtk into a transitional package that
    depends on ubuntuone-control-panel-qt.
  - Made ubuntuone-control-panel suggests ubuntuone-control-panel-gui
    instead of recommending it, to avid seeding the Qt control panel to the
    default install.
  - Updated Standards-Version to 3.9.3.
* debian/ubuntuone-control-panel-qt.install:
  - Install the new manpage provided by upstream.
* debian/patches/fix-948970.patch:
  - Apply patch from upstream to have the new manpage being detected by
    disutils-extra and thus it gets installed in the expected location
    (LP: #948970).
* debian/watch:
  - Updated to fetch latest milestone.
* Removed debian/ubuntuone-control-panel-gtk.install since
  ubuntuone-control-panel-gtk is now a transitional package.
* Removed patches which were included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Copyright 2012 Canonical Ltd.
 
4
#
 
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.
 
8
#
 
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.
 
13
#
 
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/>.
 
16
 
 
17
"""Tests for the control panel's Qt main."""
 
18
 
 
19
from twisted.internet.defer import inlineCallbacks
 
20
 
 
21
from ubuntuone.controlpanel.gui.qt import main
 
22
from ubuntuone.controlpanel.tests import TestCase
 
23
 
 
24
 
 
25
class FakeApplication(object):
 
26
 
 
27
    """A fake application."""
 
28
 
 
29
    def __init__(self):
 
30
        self.args = None
 
31
        self.style = None
 
32
 
 
33
    def __call__(self, argv, *args, **kwargs):
 
34
        """Fake arg filtering function."""
 
35
        if '-title' in argv:
 
36
            argv.remove('-title')
 
37
        self.args = (argv, args, kwargs)
 
38
        return self
 
39
 
 
40
    # pylint: disable=C0103
 
41
    def setStyleSheet(self, *args, **kwargs):
 
42
        """Fake setStyleSheet."""
 
43
        self.style = (args, kwargs)
 
44
    # pylint: enable=C0103
 
45
 
 
46
    def arguments(self):
 
47
        """Fake arguments function."""
 
48
        return self.args[0]
 
49
 
 
50
    def exec_(self):
 
51
        """Fake event loop."""
 
52
        pass
 
53
 
 
54
 
 
55
class FakeStart(object):
 
56
 
 
57
    """Fake start function."""
 
58
 
 
59
    def __init__(self):
 
60
        self.args = None
 
61
 
 
62
    def __call__(self, *args, **kwargs):
 
63
        self.args = (args, kwargs)
 
64
        return None, None
 
65
 
 
66
 
 
67
class MainTestCase(TestCase):
 
68
 
 
69
    """Test the argument parsing and passing in main."""
 
70
 
 
71
    @inlineCallbacks
 
72
    def setUp(self):
 
73
        yield super(MainTestCase, self).setUp()
 
74
        self.app = FakeApplication()
 
75
        self.start = FakeStart()
 
76
        self.patch(main, "UniqueApplication", self.app)
 
77
        self.patch(main, "start", self.start)
 
78
 
 
79
    def test_wm_class(self):
 
80
        """Test that we set the 1st argument, used for WM_CLASS, correctly."""
 
81
        main.main([])
 
82
        self.assertEqual(self.app.args,
 
83
            (['ubuntuone-installer'], ('ubuntuone-control-panel',), {}))
 
84
 
 
85
    def test_title_not_fail(self):
 
86
        """Ensure -title is removed before it gets to OptParser."""
 
87
        main.main(["blah", "-title"])
 
88
        # Did not crash!
 
89
 
 
90
    def test_minimized_option(self):
 
91
        """Ensure the --minimized option is parsed and passed correctly."""
 
92
        main.main(["blah", "--minimized"])
 
93
        self.assertEqual(self.start.args[1],
 
94
            {'minimized': True, 'with_icon': False})
 
95
 
 
96
    def test_with_icon_option(self):
 
97
        """Ensure the --minimized option is parsed and passed correctly."""
 
98
        main.main(["blah", "--with-icon"])
 
99
        self.assertEqual(self.start.args[1],
 
100
            {'minimized': False, 'with_icon': True})
 
101
 
 
102
    def test_style_loads(self):
 
103
        """Ensure the stylesheet is loaded."""
 
104
        main.main([])
 
105
        self.assertTrue(self.app.style)