~om26er/dialer-app/simply_smart_dialing_test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This file is part of dialer-app.
#
# dialer-app is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.

"""Dialer app autopilot emulators."""

from ubuntuuitoolkit import emulators as toolkit_emulators


class MainView(toolkit_emulators.MainView):
    def __init__(self, *args):
        super(MainView, self).__init__(*args)

    @property
    def dialer_page(self):
        return self.select_single(DialerPage)


class DialerPage(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
    def __init__(self, *args):
        super(DialerPage, self).__init__(*args)

    def get_keypad_entry(self):
        return self.select_single("KeypadEntry")

    def get_keypad_keys(self):
        return self.select_many("KeypadButton")

    def get_keypad_key(self, number):
        buttonsDict = {
            "0": "buttonZero",
            "1": "buttonOne",
            "2": "buttonTwo",
            "3": "buttonThree",
            "4": "buttonFour",
            "5": "buttonFive",
            "6": "buttonSix",
            "7": "buttonSeven",
            "8": "buttonEight",
            "9": "buttonNine",
            "*": "buttonAsterisk",
            "#": "buttonHash",
        }
        return self.select_single("KeypadButton",
                                  objectName=buttonsDict[number])

    def get_key_from_letter(self, letter):
        buttonsDict = {
            "A": "buttonTwo",
            "B": "buttonTwo",
            "C": "buttonTwo",
            "D": "buttonThree",
            "E": "buttonThree",
            "F": "buttonThree",
            "G": "buttonFour",
            "H": "buttonFour",
            "I": "buttonFour",
            "J": "buttonFive",
            "K": "buttonFive",
            "L": "buttonFive",
            "M": "buttonSix",
            "N": "buttonSix",
            "O": "buttonSix",
            "P": "buttonSeven",
            "Q": "buttonSeven",
            "R": "buttonSeven",
            "S": "buttonSeven",
            "T": "buttonEight",
            "U": "buttonEight",
            "V": "buttonEight",
            "W": "buttonNine",
            "X": "buttonNine",
            "Y": "buttonNine",
            "Z": "buttonNine",
        }
        return self.select_single("KeypadButton",
                                  objectName=buttonsDict[letter.upper()])

    def get_erase_button(self):
        return self.select_single("CustomButton", objectName="eraseButton")

    def get_call_button(self):
        return self.select_single(objectName="callButton")