~canonical-platform-qa/ubuntu-system-settings-online-accounts/launch_fixture

« back to all changes in this revision

Viewing changes to tests/autopilot/online_accounts_ui/tests/__init__.py

  • Committer: CI bot
  • Author(s): Leo Arias
  • Date: 2014-07-08 11:05:26 UTC
  • mfrom: (128.2.4 clean_tests)
  • Revision ID: ps-jenkins@lists.canonical.com-20140708110526-k86rmxqu1qn4tam6
Refactored the autopilot tests to use the page object pattern. Added the method go to add account to be used in UX tests. 
Approved by: PS Jenkins bot, PS Jenkins bot, PS Jenkins bot, Víctor R. Ruiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
#
 
3
# Copyright (C) 2013, 2014 Canonical Ltd.
 
4
#
 
5
# This file is part of ubuntu-system-settings-online-accounts.
 
6
#
 
7
# ubuntu-system-settings-online-accounts is free software: you can
 
8
# redistribute it and/or modify it under the terms of the GNU General Public
 
9
# License as published by the Free Software Foundation; version 3.
 
10
#
 
11
# ubuntu-system-settings-online-accounts is distributed in the hope that it
 
12
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 
13
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
import fixtures
 
20
import subprocess
 
21
import time
 
22
 
 
23
import ubuntuuitoolkit
 
24
from autopilot import platform
 
25
from autopilot.matchers import Eventually
 
26
from testtools.matchers import Equals
 
27
 
 
28
import online_accounts_ui
 
29
 
 
30
 
 
31
class BaseOnlineAccountsUITestCase(
 
32
        ubuntuuitoolkit.base.UbuntuUIToolkitAppTestCase):
 
33
 
 
34
    def setUp(self):
 
35
        super(BaseOnlineAccountsUITestCase, self).setUp()
 
36
 
 
37
        if platform.model() != 'Desktop':
 
38
            self.skipTest('Skip because of bug http://pad.lv/1252294')
 
39
 
 
40
        application_proxy = self.launch_application()
 
41
        self.application = online_accounts_ui.OnlineAccountsUI(
 
42
            application_proxy)
 
43
        self.assertThat(
 
44
            self.application.main_view.visible, Eventually(Equals(True)))
 
45
 
 
46
    def launch_application(self):
 
47
        # Increase the timeout of online-accounts-ui, to make sure it won't
 
48
        # quit before the system settings panel asks it to open.
 
49
        self.useFixture(
 
50
            fixtures.EnvironmentVariable('OAU_DAEMON_TIMEOUT', '120'))
 
51
        application = self.launch_test_application(
 
52
            'online-accounts-ui',
 
53
            '--desktop_file_hint='
 
54
            '/usr/share/applications/online-accounts-ui.desktop',
 
55
            app_type='qt',
 
56
            emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase,
 
57
            capture_output=True)
 
58
        system_settings = subprocess.Popen(
 
59
            ['system-settings', 'online-accounts',
 
60
             '--desktop_file_hint='
 
61
             '/usr/share/applications/ubuntu-system-settings.desktop'])
 
62
        self.addCleanup(system_settings.terminate)
 
63
        time.sleep(1)
 
64
        return application