~pkunal-parmar/ubuntu-calendar-app/ICalImport

« back to all changes in this revision

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

  • Committer: Omer Akram
  • Date: 2013-05-27 15:09:40 UTC
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: om26er@ubuntu.com-20130527150940-15q8vpdfl52drukn
add initial autopilot tests structure

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
# Copyright 2012 Canonical
 
3
#
 
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.
 
7
 
 
8
"""Calendar app autopilot tests."""
 
9
 
 
10
import os.path
 
11
 
 
12
from autopilot.input import Mouse, Touch, Pointer
 
13
from autopilot.matchers import Eventually
 
14
from autopilot.platform import model
 
15
from autopilot.testcase import AutopilotTestCase
 
16
from testtools.matchers import Equals
 
17
 
 
18
from ubuntu_calendar_app.emulators.main_window import MainWindow
 
19
 
 
20
 
 
21
class CalendarTestCase(AutopilotTestCase):
 
22
 
 
23
    """A common test case class that provides several useful methods for
 
24
    calendar-app tests.
 
25
 
 
26
    """
 
27
    if model() == 'Desktop':
 
28
        scenarios = [('with mouse', dict(input_device_class=Mouse))]
 
29
    else:
 
30
        scenarios = [('with touch', dict(input_device_class=Touch))]
 
31
 
 
32
    local_location = "../../calendar.qml"
 
33
 
 
34
    def setUp(self):
 
35
        self.pointing_device = Pointer(self.input_device_class.create())
 
36
        super(CalendarTestCase, self).setUp()
 
37
        if os.path.exists(self.local_location):
 
38
            self.launch_test_local()
 
39
        else:
 
40
            self.launch_test_installed()
 
41
 
 
42
    def launch_test_local(self):
 
43
        self.app = self.launch_test_application(
 
44
            "qmlscene",
 
45
            self.local_location,
 
46
            app_type='qt')
 
47
 
 
48
    def launch_test_installed(self):
 
49
        self.app = self.launch_test_application(
 
50
            "qmlscene",
 
51
            "/usr/share/ubuntu-calendar-app/ubuntu-calendar-app.qml",
 
52
            "--desktop_file_hint=/usr/share/applications/ubuntu-calendar-app.desktop",
 
53
            app_type='qt')
 
54
 
 
55
    @property
 
56
    def main_window(self):
 
57
        return MainWindow(self.app)