~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-yakkety-1895

« back to all changes in this revision

Viewing changes to tests/qmltests/Fingerprint/tst_FingerprintVisual.qml

  • Committer: Bileto Bot
  • Date: 2016-06-20 14:01:03 UTC
  • mfrom: (103.6.69 fingerprint)
  • Revision ID: ci-train-bot@canonical.com-20160620140103-q57lulbze89e6yyd
jonas-drange
* Add components for Fingerprint management.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2016 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by Jonas G. Drange <jonas.drange@canonical.com>
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import QtTest 1.0
 
21
import Ubuntu.Components 1.3
 
22
import Ubuntu.Settings.Fingerprint 0.1
 
23
import Ubuntu.Test 0.1
 
24
 
 
25
Item {
 
26
    id: testRoot
 
27
    width: units.gu(50)
 
28
    height: units.gu(90)
 
29
 
 
30
    SignalSpy {
 
31
        id: visualReadySpy
 
32
        signalName: "ready"
 
33
    }
 
34
 
 
35
    Component {
 
36
        id: fingerprintVisualComp
 
37
 
 
38
        FingerprintVisual {
 
39
            id: vis
 
40
            objectName: "fingerprintVisual"
 
41
            width: 400
 
42
            height: width * 1.227
 
43
        }
 
44
    }
 
45
 
 
46
 
 
47
    UbuntuTestCase {
 
48
        name: "FingerprintVisual"
 
49
        when: windowShown
 
50
 
 
51
        function init() {
 
52
            visualReadySpy.target = fingerprintVisualComp.createObject(testRoot);
 
53
            visualReadySpy.wait()
 
54
        }
 
55
 
 
56
        function cleanup() {
 
57
            findChild(testRoot, "fingerprintVisual").destroy();
 
58
        }
 
59
 
 
60
        function test_masks_data() {
 
61
            return [
 
62
                { masks: null, targetMasks: [], tag: "null" },
 
63
                { masks: [], targetMasks: [], tag: "no masks" },
 
64
                {
 
65
                    masks: [{x: 0, y: 0, width: 0, height: 0 }],
 
66
                    targetMasks: [{x: 0, y: 0, width: 0, height: 0}],
 
67
                    tag: "0"
 
68
                },
 
69
                {
 
70
                    masks: [
 
71
                        {x: null, y: "-a", width: "0x1", height: true },
 
72
                        {},
 
73
                    ],
 
74
                    targetMasks: [],
 
75
                    tag: "bad values"
 
76
                },
 
77
 
 
78
                // Masks for manual, visual checks.
 
79
                {
 
80
                    masks: [
 
81
                        {x: 0, y: 0, width: 0.5, height: 0.5 }
 
82
                    ],
 
83
                    visualCheck: true,
 
84
                    tag: "top right corner"
 
85
                },
 
86
                {
 
87
                    masks: [
 
88
                        {x: 0.5, y: 0, width: 0.5, height: 0.5 }
 
89
                    ],
 
90
                    visualCheck: true,
 
91
                    tag: "top left corner"
 
92
                },
 
93
                {
 
94
                    masks: [
 
95
                        {x: 0, y: 0.5, width: 0.5, height: 0.5 }
 
96
                    ],
 
97
                    visualCheck: true,
 
98
                    tag: "bottom right corner"
 
99
                },
 
100
                {
 
101
                    masks: [
 
102
                        {x: 0.5, y: 0.5, width: 0.5, height: 0.5 }
 
103
                    ],
 
104
                    visualCheck: true,
 
105
                    tag: "bottom left corner"
 
106
                },
 
107
                {
 
108
                    masks: [
 
109
                        {x: 0, y: 0, width: 0.5, height: 0.5 },
 
110
                        {x: 0.5, y: 0, width: 0.5, height: 0.5 },
 
111
                        {x: 0, y: 0.5, width: 0.5, height: 0.5 },
 
112
                        {x: 0.5, y: 0.5, width: 0.5, height: 0.5 }
 
113
                    ],
 
114
                    visualCheck: true,
 
115
                    tag: "all corners"
 
116
                }
 
117
            ]
 
118
        }
 
119
 
 
120
        function test_masks (data) {
 
121
            var vis = findChild(testRoot, "fingerprintVisual");
 
122
            vis.masks = data.masks;
 
123
            if (data.visualCheck) {
 
124
                wait(1000);
 
125
            } else {
 
126
                var actualMasks = vis.getMasksToEnroll();
 
127
                var targetMasks = data.targetMasks;
 
128
                compare(actualMasks.length, targetMasks.length);
 
129
            }
 
130
        }
 
131
    }
 
132
}