~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/fixture_setup.py

  • Committer: Leo Arias
  • Date: 2014-07-11 17:13:12 UTC
  • Revision ID: leo.arias@canonical.com-20140711171312-myqj07s4taih92la
Moved the launcher to a fixture so it can be reused outside of the testcase.

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) 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 subprocess
 
20
import time
 
21
 
 
22
import fixtures
 
23
import ubuntuuitoolkit
 
24
from autopilot import application
 
25
 
 
26
 
 
27
class LaunchBinaryOnlineAccountsUI(fixtures.Fixture):
 
28
 
 
29
    def setUp(self):
 
30
        super().setUp()
 
31
        self.application_proxy = self._launch_application()
 
32
 
 
33
    def _launch_application(self):
 
34
        # Increase the timeout of online-accounts-ui, to make sure it won't
 
35
        # quit before the system settings panel asks it to open.
 
36
        self.useFixture(
 
37
            fixtures.EnvironmentVariable('OAU_DAEMON_TIMEOUT', '120'))
 
38
        base_class = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase
 
39
        application_launcher = self.useFixture(
 
40
            application.NormalApplicationLauncher(
 
41
                emulator_base=base_class)
 
42
            )
 
43
        application_proxy = application_launcher.launch(
 
44
            'online-accounts-ui',
 
45
            '--desktop_file_hint='
 
46
            '/usr/share/applications/online-accounts-ui.desktop',
 
47
            app_type='qt', capture_output=True)
 
48
        system_settings = subprocess.Popen(
 
49
            ['system-settings', 'online-accounts',
 
50
             '--desktop_file_hint='
 
51
             '/usr/share/applications/ubuntu-system-settings.desktop'])
 
52
        self.addCleanup(system_settings.terminate)
 
53
        time.sleep(1)
 
54
        return application_proxy