1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2013 Canonical
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License version 3, as published
6
# by the Free Software Foundation.
8
"""address-book-app autopilot tests."""
14
from autopilot.input import Mouse, Touch, Pointer
15
from autopilot.platform import model
16
from autopilot.testcase import AutopilotTestCase
17
from autopilot.matchers import Eventually
18
from testtools.matchers import Equals
20
from address_book_app.emulators.main_window import MainWindow
23
class AddressBookAppTestCase(AutopilotTestCase):
24
"""A common test case class that provides several useful methods for
25
address-book-app tests.
28
DEFAULT_DEV_LOCATION = "../../src/app/address-book-app"
30
if model() == 'Desktop':
32
('with mouse', dict(input_device_class=Mouse))]
35
('with touch', dict(input_device_class=Touch))]
38
self.pointing_device = Pointer(self.input_device_class.create())
39
super(AddressBookAppTestCase, self).setUp()
41
if 'AUTOPILOT_APP' in os.environ:
42
self.app_bin = os.environ['AUTOPILOT_APP']
44
self.app_bin = AddressBookAppTestCase.DEFAULT_DEV_LOCATION
46
print "Running from: %s" % (self.app_bin)
48
if not os.path.exists(self.app_bin):
49
self.launch_test_installed()
51
self.launch_test_local()
53
main_view = self.main_window.get_qml_view()
54
self.assertThat(main_view.visible, Eventually(Equals(True)))
56
def launch_test_local(self):
57
self.app = self.launch_test_application(self.app_bin, app_type='qt')
59
def launch_test_installed(self):
60
self.app = self.launch_test_application("address-book-app",
61
"--desktop_file_hint=/usr/share/applications/address-book-app.desktop",
65
def main_window(self):
66
return MainWindow(self.app)