~ubuntu-branches/ubuntu/oneiric/ubuntuone-control-panel/oneiric

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/qt/tests/test_start.py

* New upstream release:
  [ Alejandro J. Cura <alecu@canonical.com>]
    - Do not throw a webclient error when closing
      (LP: #845105).
  [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
    - Removed all code related to Bookmarks (LP: #850142).
    - Replaces references to "Evolution" by "Thunderbird" (LP: #849494).
  [ Rodney Dawes <rodney.dawes@canonical.com> ]
    - Don't install a .desktop file for control panel
      (part of LP: #838778).
    - Point the indicator/Unity API at the installer .desktop file
      (part of LP: #838778).
    - Set the WMCLASS so Unity will fall back properly
      (part of LP: #838778).
    - Fix a few grammar mistakes (LP: #835093).
    - Don't show the "Get NGB free!" label on "Join now" button at all
      (LP: #819955).
* debian/control:
  - ubuntuone-control-panel-gtk depends now on ubuntuone-installer >= 2.0.0.
  - require ubuntuone-client >= 2.0.0.
  - require ubuntu-sso-client >= 1.4.0.
  - no longer install a .desktop file (will be installed by ubuntuone-installer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Author: Roberto Alsina <roberto.alsina@canonical.com>
 
4
#
 
5
# Copyright 2011 Canonical Ltd.
 
6
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.
 
18
 
 
19
"""Tests for the start function."""
 
20
 
 
21
from twisted.internet import defer
 
22
 
 
23
from ubuntuone.controlpanel.gui.qt import gui
 
24
from ubuntuone.controlpanel.gui.qt.tests import NO_OP
 
25
from ubuntuone.controlpanel.tests import TestCase
 
26
 
 
27
 
 
28
class FakeThing(object):
 
29
 
 
30
    """A fake thing."""
 
31
 
 
32
    def __init__(self):
 
33
        self.args = []
 
34
        self.shown = False
 
35
 
 
36
    def __call__(self, *args, **kwargs):
 
37
        self.args.append((args, kwargs))
 
38
        return self
 
39
 
 
40
    def show(self):
 
41
        """Show."""
 
42
        self.shown = True
 
43
 
 
44
 
 
45
class FakeReactor(object):
 
46
    """A fake reactor."""
 
47
 
 
48
    def run(self):
 
49
        """Start."""
 
50
 
 
51
    def stop(self):
 
52
        """Stop."""
 
53
 
 
54
 
 
55
class StartTestCase(TestCase):
 
56
    """Test the qt control panel."""
 
57
 
 
58
    @defer.inlineCallbacks
 
59
    def setUp(self):
 
60
        yield super(StartTestCase, self).setUp()
 
61
        self.main_window = FakeThing()
 
62
        self.tray_icon = FakeThing()
 
63
        self.patch(gui, "MainWindow", self.main_window)
 
64
        self.patch(gui, "TrayIcon", self.tray_icon)
 
65
 
 
66
    def test_minimized(self):
 
67
        """Test behaviour with minimized=True."""
 
68
        gui.start(NO_OP, minimized=True, with_icon=True)
 
69
        self.assertEqual(self.tray_icon.args, [((), {'window': None})])
 
70
        self.assertEqual(self.main_window.args, [])
 
71
 
 
72
    def test_with_icon(self):
 
73
        """Test behaviour with with_icon=True."""
 
74
        gui.start(NO_OP, with_icon=True, minimized=False)
 
75
        self.assertEqual(self.main_window.args, [((), {})])
 
76
        self.assertEqual(self.tray_icon.args, [((),
 
77
            {'window': self.main_window})])
 
78
 
 
79
    def test_both_false(self):
 
80
        """Test behaviour when with_icon and minimized are False."""
 
81
        gui.start(NO_OP, with_icon=False, minimized=False)
 
82
        # Should be called
 
83
        self.assertNotEqual(self.main_window.args, [])
 
84
        # Should not be called
 
85
        self.assertEqual(self.tray_icon.args, [])
 
86
 
 
87
    def test_both_true(self):
 
88
        """Test behaviour when with_icon and minimized are True."""
 
89
        gui.start(NO_OP, with_icon=True, minimized=True)
 
90
        self.assertEqual(self.tray_icon.args, [((), {'window': None})])
 
91
        self.assertEqual(self.main_window.args, [])