~nskaggs/ubuntu-filemanager-app/revert-rev132

« back to all changes in this revision

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

  • Committer: Omer Akram
  • Date: 2013-05-31 12:23:54 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: om26er@ubuntu.com-20130531122354-8pwcavg3c7ojrygu
add skeleton for autopilot tests

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 2013 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
"""Filemanager app autopilot tests."""
 
9
 
 
10
import os.path
 
11
 
 
12
from autopilot.input import Mouse, Touch, Pointer
 
13
from autopilot.platform import model
 
14
from autopilot.testcase import AutopilotTestCase
 
15
 
 
16
from time import sleep
 
17
 
 
18
from ubuntu_filemanager_app.emulators.main_window import MainWindow
 
19
 
 
20
 
 
21
class FileManagerTestCase(AutopilotTestCase):
 
22
 
 
23
    """A common test case class that provides several useful methods for
 
24
    filemanager-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 = "../../ubuntu-filemanager-app.qml"
 
33
 
 
34
    def setUp(self):
 
35
        self.pointing_device = Pointer(self.input_device_class.create())
 
36
        super(FileManagerTestCase, 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-filemanager-app/ubuntu-filemanager-app.qml",
 
52
            "--desktop_file_hint=/usr/share/applications/ubuntu-filemanager-app.desktop",
 
53
            app_type='qt')
 
54
 
 
55
    def tap_item(self, item):
 
56
        self.pointing_device.move_to_object(item)
 
57
        self.pointing_device.press()
 
58
        sleep(1)
 
59
        self.pointing_device.release()
 
60
 
 
61
    @property
 
62
    def main_window(self):
 
63
        return MainWindow(self.app)