~mzanetti/unity/phablet-autopilot

« back to all changes in this revision

Viewing changes to tests/autopilot/qml_phone_shell/tests/testcases.py

  • Committer: Michael Zanetti
  • Date: 2013-02-27 14:27:58 UTC
  • Revision ID: michael.zanetti@canonical.com-20130227142758-2c84421eatm11mg6
move helper functions to a separate class

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from __future__ import absolute_import
11
11
 
12
12
from qml_phone_shell.tests import FormFactors
 
13
from qml_phone_shell.tests.helpers import TestShellHelpers
13
14
 
14
15
from testtools.matchers import Equals, NotEquals, GreaterThan
15
16
from autopilot.matchers import Eventually
19
20
import os
20
21
from os import path
21
22
 
22
 
class TestShell(object):
 
23
class TestShell(TestShellHelpers):
23
24
    """Tests the Shell"""
24
25
 
25
 
    def unlock_greeter(self):
26
 
        greeter = self.main_window.get_greeter()
27
 
        if greeter.multiUser:
28
 
            login_loader = self.main_window.get_login_loader()
29
 
            self.assertThat(login_loader.progress, Eventually(Equals(1)))
30
 
            login_list = self.main_window.get_login_list()
31
 
            path_view = login_list.get_children_by_type("QQuickPathView")[0]
32
 
            users = path_view.get_children_by_type("QQuickItem")
33
 
            for user in users:
34
 
                try:
35
 
                    user_label = user.get_children_by_type("Label")[0]
36
 
                    if user_label.text == "Guest":
37
 
                        self.pointing_device.move_to_object(user_label)
38
 
                        self.pointing_device.click()
39
 
                except:
40
 
                    pass
41
 
 
42
 
            password_field = login_list.get_children_by_type("TextField")[0]
43
 
            self.pointing_device.move_to_object(password_field)
44
 
            self.assertThat(password_field.opacity, Eventually(Equals(1)))
45
 
            self.pointing_device.click()
46
 
 
47
 
        else:
48
 
            rect = greeter.globalRect
49
 
            start_x = rect[0] + rect[2] - 1
50
 
            start_y = int(rect[1] + rect[3] / 2)
51
 
            stop_x = int(rect[0] + rect[2] / 2)
52
 
            stop_y = start_y
53
 
            self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
54
 
 
55
 
        self.assertThat(greeter.shown, Eventually(Equals(False)))
56
 
 
57
 
 
58
26
    def test_example_test_all(self):
59
27
        self.unlock_greeter()
60
28
        time.sleep(1)