Merge lp:~jonas-drange/ubuntu-settings-components/fingerprint into lp:~registry/ubuntu-settings-components/trunk

Proposed by Jonas G. Drange
Status: Work in progress
Proposed branch: lp:~jonas-drange/ubuntu-settings-components/fingerprint
Merge into: lp:~registry/ubuntu-settings-components/trunk
Diff against target: 4419 lines (+4053/-18)
55 files modified
debian/control (+5/-2)
examples/Fingerprint.qml (+43/-0)
plugins/Ubuntu/Settings/CMakeLists.txt (+1/-0)
plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt (+15/-0)
plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml (+64/-0)
plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml (+103/-0)
plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml (+133/-0)
plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml (+72/-0)
plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml (+440/-0)
plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml (+81/-0)
plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml (+95/-0)
plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml (+52/-0)
plugins/Ubuntu/Settings/Fingerprint/Setup.qml (+388/-0)
plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml (+84/-0)
plugins/Ubuntu/Settings/Fingerprint/assets.qrc (+11/-0)
plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json (+1/-0)
plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci (+7/-0)
plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci (+7/-0)
plugins/Ubuntu/Settings/Fingerprint/plugin.cpp (+35/-0)
plugins/Ubuntu/Settings/Fingerprint/plugin.h (+30/-0)
plugins/Ubuntu/Settings/Fingerprint/qmldir (+7/-0)
plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp (+39/-0)
plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h (+37/-0)
plugins/Ubuntu/Settings/Fingerprint/utils/segment.py (+84/-0)
po/ubuntu-settings-components.pot (+101/-16)
tests/qmltests/CMakeLists.txt (+7/-0)
tests/qmltests/Fingerprint/tst_FingerprintNames.qml (+364/-0)
tests/qmltests/Fingerprint/tst_FingerprintSetup.qml (+236/-0)
tests/qmltests/Fingerprint/tst_FingerprintVisual.qml (+132/-0)
tests/qmltests/Fingerprint/tst_Fingerprints.qml (+230/-0)
tests/qmltests/mocks/Biometryd/CMakeLists.txt (+20/-0)
tests/qmltests/mocks/Biometryd/MockDevice.cpp (+30/-0)
tests/qmltests/mocks/Biometryd/MockDevice.h (+38/-0)
tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp (+49/-0)
tests/qmltests/mocks/Biometryd/MockFingerprintReader.h (+65/-0)
tests/qmltests/mocks/Biometryd/MockObserver.cpp (+88/-0)
tests/qmltests/mocks/Biometryd/MockObserver.h (+52/-0)
tests/qmltests/mocks/Biometryd/MockOperation.cpp (+34/-0)
tests/qmltests/mocks/Biometryd/MockOperation.h (+36/-0)
tests/qmltests/mocks/Biometryd/MockService.cpp (+42/-0)
tests/qmltests/mocks/Biometryd/MockService.h (+46/-0)
tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp (+56/-0)
tests/qmltests/mocks/Biometryd/MockTemplateStore.h (+86/-0)
tests/qmltests/mocks/Biometryd/MockUser.cpp (+33/-0)
tests/qmltests/mocks/Biometryd/MockUser.h (+38/-0)
tests/qmltests/mocks/Biometryd/plugin.cpp (+60/-0)
tests/qmltests/mocks/Biometryd/plugin.h (+31/-0)
tests/qmltests/mocks/Biometryd/qmldir (+2/-0)
tests/qmltests/mocks/CMakeLists.txt (+32/-0)
tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt (+20/-0)
tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp (+124/-0)
tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h (+101/-0)
tests/qmltests/mocks/GSettings.1.0/plugin.cpp (+33/-0)
tests/qmltests/mocks/GSettings.1.0/plugin.h (+31/-0)
tests/qmltests/mocks/GSettings.1.0/qmldir (+2/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-settings-components/fingerprint
Reviewer Review Type Date Requested Status
Registry Administrators Pending
Review via email: mp+289292@code.launchpad.net

Commit message

components for allowing a user to manage fingerprints

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
 Yes, fingerprint bindings.
 * Did you perform an exploratory manual test run of your code change and any related functionality?
 TBD
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 N/A
 * If you changed the UI, has there been a design review?
 TBD
 * If you changed localized strings, has the POT file been updated?
 TBD

Rationale: https://docs.google.com/document/d/1d8gEataSjJMRacQbdSy0W4pSFA9q1UKA660CvXk-wNI/edit

To post a comment you must log in.
111. By Jonas G. Drange

mature the example

112. By Jonas G. Drange

merge trunk

113. By Jonas G. Drange

comp page

114. By Jonas G. Drange

add fingerprint qml test

115. By Jonas G. Drange

add qml tests

116. By Jonas G. Drange

use predicted signals and methods from discussions with tvoss

117. By Jonas G. Drange

remove dangling function keyword

118. By Jonas G. Drange

PageHeader crashes, use title instead

119. By Jonas G. Drange

conform to spec

120. By Jonas G. Drange

doc, sort props

Revision history for this message
Jonas G. Drange (jonas-drange) :
121. By Jonas G. Drange

implement some of the qml binding features

122. By Jonas G. Drange

add mocking

123. By Jonas G. Drange

add mocked biometryd

124. By Jonas G. Drange

rewrite tests to use mocking

125. By Jonas G. Drange

working enrollment test

126. By Jonas G. Drange

make enrollment work once again, albeit with deprecated animations

127. By Jonas G. Drange

init provider

128. By Jonas G. Drange

use qrc to put the paths in the binary (compressed)

129. By Jonas G. Drange

undo test comment

130. By Jonas G. Drange

small fixes, make renderPath private

131. By Jonas G. Drange

remove debug stuff in fingerprint page

132. By Jonas G. Drange

remove debug stuff in fingerprint page

133. By Jonas G. Drange

add test for fingerprint visual

134. By Jonas G. Drange

fix a lot of details

135. By Jonas G. Drange

some comments

136. By Jonas G. Drange

new paths from design

137. By Jonas G. Drange

add svg dep

138. By Jonas G. Drange

move paths to assets instead, add everything to qrc to get it compressed.

139. By Jonas G. Drange

use png as drop shadows

140. By Jonas G. Drange

fix broken transparent pngs

141. By Jonas G. Drange

buttons per spec

142. By Jonas G. Drange

biometryd is a depend of the binary package

143. By Jonas G. Drange

sync with trunk

144. By Jonas G. Drange

remove spurious mockoperation

145. By Jonas G. Drange

reverse X axis

146. By Jonas G. Drange

animated enrollment

147. By Jonas G. Drange

clean up cancel logic, add available to mock and test it

148. By Jonas G. Drange

add circular segment, completing the done animation

149. By Jonas G. Drange

remove unused asset

150. By Jonas G. Drange

add direction visual

151. By Jonas G. Drange

add red translucent rectangle for each scanner mask

152. By Jonas G. Drange

drop svg dep

153. By Jonas G. Drange

update pot

154. By Jonas G. Drange

size op only on available

155. By Jonas G. Drange

fix some design issues

156. By Jonas G. Drange

have failed and success screens on same page

157. By Jonas G. Drange

first stab at smart rotation

158. By Jonas G. Drange

complete directionvisual

Revision history for this message
Jonas G. Drange (jonas-drange) :
159. By Jonas G. Drange

start working on name story

160. By Jonas G. Drange

first part of named templates

161. By Jonas G. Drange

refactor tests, and add the last piece of the naming

162. By Jonas G. Drange

update pot

Unmerged revisions

162. By Jonas G. Drange

update pot

161. By Jonas G. Drange

refactor tests, and add the last piece of the naming

160. By Jonas G. Drange

first part of named templates

159. By Jonas G. Drange

start working on name story

158. By Jonas G. Drange

complete directionvisual

157. By Jonas G. Drange

first stab at smart rotation

156. By Jonas G. Drange

have failed and success screens on same page

155. By Jonas G. Drange

fix some design issues

154. By Jonas G. Drange

size op only on available

153. By Jonas G. Drange

update pot

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2016-03-01 15:37:36 +0000
+++ debian/control 2016-06-15 10:46:42 +0000
@@ -27,7 +27,10 @@
27Architecture: any27Architecture: any
28Multi-Arch: same28Multi-Arch: same
29Pre-Depends: dpkg (>= 1.15.6~)29Pre-Depends: dpkg (>= 1.15.6~)
30Depends: qml-module-qtquick-layouts,30Depends: gsettings-ubuntu-schemas (>= 0.0.7),
31 qml-module-biometryd,
32 qml-module-qtquick-layouts,
33 qtdeclarative5-gsettings1.0 (>=0.1+14.10.20140801.1),
31 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.1) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.1),34 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.1) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.1),
32 suru-icon-theme,35 suru-icon-theme,
33 ${misc:Depends},36 ${misc:Depends},
@@ -35,4 +38,4 @@
35Breaks: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3),38Breaks: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3),
36Replaces: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3),39Replaces: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3),
37Description: Ubuntu Settings Components40Description: Ubuntu Settings Components
38 Ubuntu settings components for Unity
39\ No newline at end of file41\ No newline at end of file
42 Ubuntu settings components for Unity
4043
=== added file 'examples/Fingerprint.qml'
--- examples/Fingerprint.qml 1970-01-01 00:00:00 +0000
+++ examples/Fingerprint.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,43 @@
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
19import QtQuick 2.4
20import QtQuick.Layouts 1.2
21import Ubuntu.Components 1.3
22import Ubuntu.Components.Popups 1.3
23import Ubuntu.Components.ListItems 1.3 as ListItems
24import Ubuntu.Settings.Components 0.1
25import Ubuntu.Settings.Fingerprint 0.1
26
27MainView {
28 width: units.gu(50)
29 height: units.gu(90)
30
31 PageStack {
32 id: pageStack
33
34 Component.onCompleted: push(fingerprintPage)
35
36 Component {
37 id: fingerprintPage
38 Fingerprints {
39 onRequestPasscode: passcodeSet = !passcodeSet
40 }
41 }
42 }
43}
044
=== modified file 'plugins/Ubuntu/Settings/CMakeLists.txt'
--- plugins/Ubuntu/Settings/CMakeLists.txt 2016-02-05 23:42:02 +0000
+++ plugins/Ubuntu/Settings/CMakeLists.txt 2016-06-15 10:46:42 +0000
@@ -1,3 +1,4 @@
1add_subdirectory(Components)1add_subdirectory(Components)
2add_subdirectory(Fingerprint)
2add_subdirectory(Menus)3add_subdirectory(Menus)
3add_subdirectory(Vpn)4add_subdirectory(Vpn)
45
=== added directory 'plugins/Ubuntu/Settings/Fingerprint'
=== added file 'plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt'
--- plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt 2016-06-15 10:46:42 +0000
@@ -0,0 +1,15 @@
1project(UbuntuSettingsFingerprintQml)
2
3include_directories(
4 ${CMAKE_CURRENT_SOURCE_DIR}
5 ${CMAKE_CURRENT_BINARY_DIR}
6)
7add_definitions(-DUBUNTUSETTINGSFINGERPRINT_LIBRARY)
8QT5_ADD_RESOURCES(assets assets.qrc)
9add_library(UbuntuSettingsFingerprintQml MODULE
10 plugin.cpp
11 ubuntusettingsfingerprint.cpp
12 ${assets}
13)
14qt5_use_modules(UbuntuSettingsFingerprintQml Core Qml Quick)
15add_usc_plugin(Ubuntu.Settings.Fingerprint 0.1 Ubuntu/Settings/Fingerprint TARGETS UbuntuSettingsFingerprintQml)
016
=== added file 'plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml'
--- plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,64 @@
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 Florian Boucault <florian.boucault@canonical.com>
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.3
21
22ShaderEffect {
23 implicitWidth: units.gu(20)
24 implicitHeight: units.gu(20)
25 height: width
26
27 property color color: "#3EB34F"
28 property real thickness: units.dp(3)
29 property real angleStop: 90
30
31 property real _texturePixel: 1/width
32 property real _thicknessTex: thickness/width
33 property real _angleStopRadians: angleStop * (Math.PI / 180)
34
35 fragmentShader: "
36 varying mediump vec2 qt_TexCoord0;
37 uniform lowp float qt_Opacity;
38 uniform lowp vec4 color;
39 uniform lowp float _texturePixel;
40 uniform lowp float _thicknessTex;
41 uniform lowp float _angleStopRadians;
42
43 void main() {
44 mediump vec2 center = vec2(0.5);
45 mediump float circleX = (qt_TexCoord0.x - center.x);
46 mediump float circleY = (qt_TexCoord0.y - center.y);
47 mediump float distanceToCenter = circleX*circleX + circleY*circleY;
48 const mediump float PI = 3.1415926535897932384626433832795;
49 mediump float angle = atan(-circleX, circleY) + PI;
50
51 mediump float radius = 0.5;
52 mediump float radiusSquare = radius * radius;
53 mediump float radiusInner = radius - _thicknessTex;
54 mediump float radiusInnerSquare = radiusInner * radiusInner;
55
56 lowp vec4 fillColor = mix(vec4(0),
57 mix(color, vec4(0), smoothstep(distanceToCenter-_texturePixel, distanceToCenter+_texturePixel, radiusInnerSquare)),
58 smoothstep(distanceToCenter-_texturePixel, distanceToCenter+_texturePixel, radiusSquare));
59 fillColor = mix(fillColor, vec4(0), step(_angleStopRadians, angle));
60 gl_FragColor = fillColor * qt_Opacity;
61 }
62 "
63}
64
065
=== added file 'plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml'
--- plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,103 @@
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
19import Biometryd 0.0
20import QtQuick 2.4
21import Ubuntu.Components 1.3
22import Ubuntu.Settings.Fingerprint 0.1
23
24Item {
25 property int direction: FingerprintReader.NotAvailable
26 opacity: direction !== FingerprintReader.NotAvailable ? 1 : 0
27 Behavior on opacity { UbuntuNumberAnimation {} }
28
29 UbuntuNumberAnimation {
30 id: rotationAnimation
31 alwaysRunToEnd: true
32
33 target: directionContainer
34 property: "rotation"
35
36 function normalizeAngle(v) {
37 if (v < 0)
38 return 360 + v;
39 else
40 return v % 360;
41 }
42
43 onStopped: {
44 directionContainer.rotation = normalizeAngle(directionContainer.rotation);
45 }
46 }
47
48 onDirectionChanged: {
49 var v1 = rotation;
50 var v2;
51 var length;
52
53 switch (direction) {
54 case FingerprintReader.North:
55 v2 = 0; break;
56 case FingerprintReader.NorthEast:
57 v2 = 45; break;
58 case FingerprintReader.East:
59 v2 = 90; break;
60 case FingerprintReader.SouthEast:
61 v2 = 135; break;
62 case FingerprintReader.South:
63 v2 = 180; break;
64 case FingerprintReader.SouthWest:
65 v2 = 225; break;
66 case FingerprintReader.West:
67 v2 = 270; break;
68 case FingerprintReader.NorthWest:
69 v2 = 315; break;
70 }
71
72 length = Math.min(Math.abs(v1 - v2),
73 Math.abs(v1 - 360 - v2),
74 Math.abs(v1 + 360 - v2));
75
76 if (length !== 180)
77 length = length % 180;
78
79 if (((length + v1) % 360) === v2)
80 v1 = v1 + length;
81 else
82 v1 = v1 -length;
83
84 rotationAnimation.from = rotation;
85 rotationAnimation.to = v1;
86 rotationAnimation.start();
87 }
88
89 Icon {
90 id: directionArrow
91 objectName: "fingerprintDirectionLabel"
92 anchors {
93 top: parent.top
94 topMargin: -units.gu(2)
95 horizontalCenter: parent.horizontalCenter
96 }
97 width: units.gu(5)
98 height: width
99
100 name: "down"
101 color: theme.palette.normal.activity
102 }
103}
0104
=== added file 'plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml'
--- plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,133 @@
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
19import QtQuick 2.4
20import Ubuntu.Components 1.3
21import Ubuntu.Components.Popups 1.3
22import Ubuntu.Components.Themes.Ambiance 1.3
23
24Page {
25 id: root
26 property string name
27 property string templateId
28
29 signal requestDeletion(string templateId)
30 signal requestRename(string templateId, string name)
31
32 function deletionFailed() {
33 PopupUtils.open(deletionFailed);
34 state = "";
35 }
36
37 header: PageHeader {
38 objectName: "templateHeader"
39 title: nameInput.text.length > 0 ? nameInput.text : name
40 flickable: flickable
41 }
42
43 states: [
44 State {
45 name: "deleting"
46 PropertyChanges {
47 target: nameInput
48 enabled: false
49 }
50 PropertyChanges {
51 target: deleteButton
52 enabled: false
53 }
54 }
55 ]
56
57 Flickable {
58 id: flickable
59 anchors {
60 fill: parent
61 topMargin: units.gu(2)
62 }
63 boundsBehavior: (contentHeight > root.height) ?
64 Flickable.DragAndOvershootBounds :
65 Flickable.StopAtBounds
66 contentHeight: contentItem.childrenRect.height
67
68 Column {
69 spacing: units.gu(2)
70 anchors {
71 left: parent.left
72 right: parent.right
73 margins: units.gu(3)
74 }
75
76 Label {
77 id: nameLabel
78 anchors.left: parent.left
79 anchors.right: parent.right
80 text: i18n.dtr("ubuntu-settings-components", "Fingerprint Name")
81 font.weight: Font.Light
82 }
83
84 TextField {
85 id: nameInput
86 objectName: "nameInput"
87 anchors.left: parent.left
88 anchors.right: parent.right
89 inputMethodHints: Qt.ImhNoPredictiveText
90 style: TextFieldStyle {}
91 text: name
92 onTextChanged: {
93 if (text)
94 requestRename(templateId, text)
95 }
96 onAccepted: {
97 if (text) {
98 requestRename(templateId, text);
99 pageStack.pop();
100 }
101 }
102 }
103
104 Button {
105 id: deleteButton
106 objectName: "templateDelete"
107 text: i18n.dtr("ubuntu-settings-components", "Delete Fingerprint")
108 onClicked: {
109 root.state = "deleting";
110 requestDeletion(templateId)
111 }
112 width: parent.width
113 }
114 }
115 }
116
117 Component {
118 id: deletionFailed
119
120 Dialog {
121 id: deletionFailedDialog
122 objectName: "fingerprintDeletionFailedDialog"
123 text: i18n.dtr("ubuntu-settings-components",
124 "Sorry, the fingerprint could not be deleted.")
125
126 Button {
127 objectName: "fingerprintDeleteionFailedOk"
128 onClicked: PopupUtils.close(deletionFailedDialog)
129 text: i18n.dtr("ubuntu-settings-components", "OK")
130 }
131 }
132 }
133}
0134
=== added file 'plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml'
--- plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,72 @@
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 * Florian Boucault <florian.boucault@canonical.com>
18 */
19
20import QtQuick 2.4
21import Ubuntu.Settings.Fingerprint 0.1
22
23SegmentedImage {
24 id: segmentedImage
25
26 property var masks: []
27
28 // http://stackoverflow.com/a/1830844/538866
29 function isNumeric (n) {
30 return !isNaN(parseFloat(n)) && isFinite(n);
31 }
32
33 function getMasksToEnroll () {
34 var outMasks = [];
35 if (masks && masks.length) {
36 masks.forEach(function (mask, i) {
37 // Format is "<source>/[x1,y1,w1,h1],…,[xn,yn,wn,hn]"
38 // If any value is non-numeric, we drop the mask.
39 if (!isNumeric(mask.x) || !isNumeric(mask.y) || !isNumeric(mask.width)
40 || !isNumeric(mask.height))
41 return;
42
43 // Translate the box so as to mirror the mask
44 mask.x = (1 - (mask.x + mask.width));
45
46 outMasks.push(mask);
47 });
48 }
49 return outMasks;
50 }
51
52 onMasksChanged: segmentedImage.enrollMasks(getMasksToEnroll())
53
54 textureSource: "qrc:/assets/fingerprint_segmented.png"
55 boxesSource: "qrc:/assets/fingerprint_boxes.json"
56
57 Repeater {
58 model: segmentedImage.masks
59
60 Rectangle {
61 visible: UbuntuSettingsFingerprint.debug
62 color: "red"
63 opacity: 0.25
64 x: modelData.x * segmentedImage.implicitWidth
65 y: modelData.y * segmentedImage.implicitHeight
66 width: modelData.width * segmentedImage.implicitWidth
67 height: modelData.height * segmentedImage.implicitHeight
68
69 Component.onCompleted: console.log('Scanner mask (x, y, w, h):', x, y, width, height)
70 }
71 }
72}
073
=== added file 'plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml'
--- plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,440 @@
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
19import QtQuick 2.4
20import QtQuick.Layouts 1.1
21import Biometryd 0.0
22import GSettings 1.0
23import Ubuntu.Components 1.3
24import Ubuntu.Components.Popups 1.3
25import Ubuntu.Settings.Fingerprint 0.1
26
27Page {
28 id: root
29 objectName: "fingerprintPage"
30
31 header: PageHeader {
32 title: i18n.dtr("ubuntu-settings-components", "Fingerprint ID")
33 flickable: content
34 }
35
36 property var _ts: Biometryd.defaultDevice.templateStore
37 property var _enrollmentOperation: null
38 property var _clearanceOperation: null
39 property var _removalOperation: null
40 property var _listOperation: null
41 property var _setupPage: null
42 property var _fpInstancePage: null
43 property var _settings: sysSettings
44
45 property Dialog _diag: null
46 property bool passcodeSet: false
47
48 function enroll () {
49 _enrollmentOperation = _ts.enroll(user);
50 _enrollmentOperation.start(enrollmentObserver);
51 }
52
53 function cancel () {
54 if (_enrollmentOperation !== null)
55 _enrollmentOperation.cancel();
56 }
57
58 function clear() {
59 _clearanceOperation = _ts.clear(user);
60 _clearanceOperation.start(clearanceObserver);
61 }
62
63 function removeTemplate(templateId) {
64 var names = sysSettings.fingerprintNames;
65 delete names[templateId];
66 sysSettings.fingerprintNames = names;
67 }
68
69 function renameTemplate(templateId, newName) {
70 var names = sysSettings.fingerprintNames;
71 names[templateId] = newName;
72 sysSettings.fingerprintNames = names;
73 }
74
75 function addTemplate(templateId, name) {
76 var names = sysSettings.fingerprintNames;
77 names[templateId] = name;
78 sysSettings.fingerprintNames = names;
79 }
80
81 function createTemplateName() {
82 var map = sysSettings.fingerprintNames;
83 var currentNames = [];
84 var newName;
85 for (var k in map) {
86 if (map.hasOwnProperty(k))
87 currentNames.push(map[k]);
88 }
89
90 var i = 0;
91 do {
92 newName = i18n.dtr("ubuntu-settings-components",
93 "Finger %1").arg(++i); // Start at 1
94 } while (currentNames.indexOf(newName) >= 0);
95 return newName;
96 }
97
98 // Assign names to unnamed fingerprints. This exist because we can't
99 // guarantee that all fingerprints get names (i.e. enrollment can complete
100 // after System Settings closes).
101 function assignNames(templateIds) {
102 var names = sysSettings.fingerprintNames;
103 for (var i = 0; i < templateIds.length; i++) {
104 if ( !(templateIds[i] in names) || !names[templateIds[i]])
105 names[templateIds[i]] = createTemplateName();
106 sysSettings.fingerprintNames = names;
107 }
108 }
109
110 signal requestPasscode()
111
112 Component.onCompleted: {
113 // Start a list operation immediately.
114 if (Biometryd.available) {
115 _listOperation = _ts.list(user);
116 _listOperation.start(listObserver);
117 }
118 }
119
120 Component.onDestruction: {
121 if (_enrollmentOperation !== null)
122 _enrollmentOperation.cancel();
123
124 if (_clearanceOperation !== null)
125 _clearanceOperation.cancel();
126
127 if (_removalOperation !== null)
128 _removalOperation.cancel();
129
130 if (_listOperation !== null)
131 _listOperation.cancel();
132 }
133
134 states: [
135 State {
136 name: "noPasscode"
137 PropertyChanges {
138 target: setupPasscode
139 visible: true
140 }
141 PropertyChanges {
142 target: setupFingerprint
143 enabled: false
144 }
145 PropertyChanges {
146 target: fingerprintsList
147 enabled: false
148 }
149 when: !passcodeSet
150 },
151 State {
152 name: "noScanner"
153 PropertyChanges {
154 target: setupFingerprint
155 enabled: false
156 }
157 PropertyChanges {
158 target: fingerprintsList
159 visible: false
160 }
161 when: !Biometryd.available
162 }
163 ]
164
165 Flickable {
166 id: content
167 anchors.fill: parent
168 boundsBehavior: (contentHeight > root.height) ?
169 Flickable.DragAndOvershootBounds :
170 Flickable.StopAtBounds
171 contentHeight: contentItem.childrenRect.height
172
173 Column {
174 anchors { left: parent.left; right: parent.right }
175 // spacing: units.gu(3)
176
177 Column {
178 id: setupPasscode
179 anchors { left: parent.left; right: parent.right }
180 visible: false
181
182 ListItem {
183 height: setPcodeLayout.height + (divider.visible ? divider.height : 0)
184 ListItemLayout {
185 id: setPcodeLayout
186 title.text: i18n.dtr(
187 "ubuntu-settings-components",
188 "Passcode required"
189 )
190 subtitle.text: i18n.dtr(
191 "ubuntu-settings-components",
192 "You must set a passcode to use fingerprint ID"
193 )
194 Button {
195 objectName: "fingerprintSetPasscodeButton"
196 onClicked: root.requestPasscode()
197 text: i18n.dtr(
198 "ubuntu-settings-components",
199 "Set Passcode…"
200 )
201 }
202 }
203 }
204 }
205
206 Column {
207 id: fingerprints
208 anchors { left: parent.left; right: parent.right }
209
210 Repeater {
211 id: fingerprintsList
212 property bool enabled: true
213 objectName: "fingerprintsList"
214 model: {
215 var map = sysSettings.fingerprintNames;
216 var m = [];
217 for (var k in map) {
218 if (map.hasOwnProperty(k)) {
219 m.push({
220 templateId: k,
221 name: map[k]
222 });
223 }
224 }
225 m.sort(function (a, b) {
226 if (a.name < b.name) return -1;
227 if (a.name > b.name) return 1;
228 if (a.name == b.name) return 0;
229 });
230 return m;
231 }
232
233 ListItem {
234 height: fpLayout.height + (divider.visible ? divider.height : 0)
235 onClicked: _fpInstancePage = pageStack.push(
236 Qt.resolvedUrl("Fingerprint.qml"), {
237 name: modelData.name,
238 templateId: modelData.templateId
239 }
240 )
241 enabled: fingerprintsList.enabled
242
243 ListItemLayout {
244 id: fpLayout
245 objectName: "fingerprintInstance-" + index
246 title.text: modelData.name
247
248 ProgressionSlot {}
249 }
250 }
251 }
252 }
253
254 Column {
255 id: setupFingerprint
256
257 anchors { left: parent.left; right: parent.right }
258 objectName: "fingerprintSetupEntry"
259 property bool enabled: true
260 spacing: units.gu(2)
261
262 ListItem {
263 height: addFpLayout.height + (divider.visible ? divider.height : 0)
264 onClicked: {
265 _setupPage = pageStack.push(Qt.resolvedUrl("Setup.qml"));
266 root.enroll();
267 }
268 enabled: parent.enabled
269
270 ListItemLayout {
271 id: addFpLayout
272 objectName: "fingerprintAddListItemLayout"
273 title.text: i18n.dtr(
274 "ubuntu-settings-components",
275 "Add fingerprint"
276 )
277
278 ProgressionSlot {}
279 }
280 }
281
282 Button {
283 anchors.horizontalCenter: parent.horizontalCenter
284 enabled: fingerprintsList.model.length > 0
285 objectName: "fingerprintRemoveAllButton"
286 onClicked: _diag = PopupUtils.open(removeAllAlert)
287 text: i18n.dtr("ubuntu-settings-components",
288 "Remove All…")
289 }
290 }
291 }
292 }
293
294 Component {
295 id: removeAllAlert
296
297 Dialog {
298 id: removeAllAlertDialog
299
300 objectName: "fingerprintRemoveAllDialog"
301 text: i18n.dtr(
302 "ubuntu-settings-components",
303 "Are you sure you want to forget all stored fingerprints?"
304 )
305
306 RowLayout {
307 anchors { left: parent.left; right: parent.right }
308 spacing: units.gu(2)
309
310 Button {
311 onClicked: PopupUtils.close(removeAllAlertDialog)
312 text: i18n.dtr("ubuntu-settings-components", "Cancel")
313 Layout.fillWidth: true
314 }
315
316 Button {
317 objectName: "fingerprintRemoveAllConfirmationButton"
318 onClicked: root.clear()
319 text: i18n.dtr("ubuntu-settings-components", "Remove")
320 Layout.fillWidth: true
321 }
322 }
323 }
324 }
325
326 Component {
327 id: fingerprintReaderBroken
328
329 Dialog {
330 id: fingerprintReaderBrokenDialog
331 objectName: "fingerprintReaderBrokenDialog"
332 text: i18n.dtr("ubuntu-settings-components",
333 "Sorry, the reader doesn’t seem to be working.")
334
335 Button {
336 objectName: "fingerprintReaderBrokenDialogOK"
337 onClicked: PopupUtils.close(fingerprintReaderBrokenDialog)
338 text: i18n.dtr("ubuntu-settings-components", "OK")
339 }
340 }
341 }
342
343 Connections {
344 target: _setupPage
345 onEnroll: root.enroll()
346 onCancel: root.cancel()
347 }
348
349 Connections {
350 target: _fpInstancePage
351
352 onRequestDeletion: {
353 _removalOperation = _ts.remove(user, templateId);
354 _removalOperation.start(removalObserver);
355 }
356 onRequestRename: renameTemplate(templateId, name)
357 }
358
359 Observer {
360 id: enrollmentObserver
361 objectName: "enrollmentObserver"
362 onFailed: {
363 if (_setupPage)
364 _setupPage.enrollmentFailed(reason);
365 _enrollmentOperation = null;
366 console.error("Enrollment failed", reason);
367 }
368 onProgressed: _setupPage.enrollmentProgressed(percent, details)
369 onSucceeded: {
370 if (!(result in sysSettings.fingerprintNames))
371 root.addTemplate(result, root.createTemplateName());
372 if (_setupPage)
373 _setupPage.enrollmentCompleted();
374 _enrollmentOperation = null;
375 }
376 onCanceled: _enrollmentOperation = null
377 }
378
379 Observer {
380 id: clearanceObserver
381 objectName: "clearanceObserver"
382 onFailed: {
383 _clearanceOperation = null;
384 if (_diag) PopupUtils.close(_diag);
385 _diag = PopupUtils.open(fingerprintReaderBroken);
386 console.error("Biometry clearance failed:", reason);
387 }
388 onSucceeded: {
389 _clearanceOperation = null;
390 if (_diag) PopupUtils.close(_diag);
391 sysSettings.fingerprintNames = {};
392 }
393 onCanceled: _clearanceOperation = null
394 }
395
396 Observer {
397 id: removalObserver
398 objectName: "removalObserver"
399 onFailed: {
400 _removalOperation = null;
401 if (_fpInstancePage)
402 _fpInstancePage.deletionFailed()
403 console.error("Biometryd template deletion failed:", reason);
404 }
405 onSucceeded: {
406 _removalOperation = null;
407 if (pageStack.currentPage === _fpInstancePage)
408 pageStack.pop();
409 root.removeTemplate(result);
410 }
411 onCanceled: _removalOperation = null
412 }
413
414 Observer {
415 id: listObserver
416 objectName: "listObserver"
417 onFailed: {
418 _listOperation = null;
419 if (_diag) PopupUtils.close(_diag);
420 _diag = PopupUtils.open(fingerprintReaderBroken);
421 console.error("Biometryd list failed:", reason);
422 }
423 onSucceeded: {
424 _listOperation = null;
425 root.assignNames(result);
426 }
427 onCanceled: _listOperation = null
428 }
429
430 User {
431 id: user
432 uid: UbuntuSettingsFingerprint.uid
433 }
434
435 GSettings {
436 id: sysSettings
437 objectName: "systemSettings"
438 schema.id: "com.ubuntu.touch.system"
439 }
440}
0441
=== added file 'plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml'
--- plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,81 @@
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 Florian Boucault <florian.boucault@canonical.com>
17 */
18
19import QtQuick 2.4
20
21QtObject {
22 id: segmentBoundingBoxes
23
24 property string source
25 onSourceChanged: parseBoundingBoxes(source)
26
27 property var boundingBoxes: []
28 property real width
29 property real height
30 property int count: boundingBoxes.length
31
32 // The API cannot be used reliably before this signal has been emitted.
33 signal ready()
34
35 function parseBoundingBoxes(source) {
36 var xhr = new XMLHttpRequest;
37 xhr.open("GET", source);
38 xhr.onreadystatechange = function() {
39 if (xhr.readyState == XMLHttpRequest.DONE) {
40 var b = [];
41 var json = JSON.parse(xhr.responseText);
42 boundingBoxes = json["boxes"];
43 width = json["width"];
44 height = json["height"];
45 ready();
46 }
47 }
48 xhr.send();
49 }
50
51 function intersects(box1, box2) {
52 // TODO: optimize
53 var x11 = box1[0];
54 var y11 = box1[1];
55 var x12 = box1[0] + box1[2];
56 var y12 = box1[1] + box1[3];
57 var x21 = box2[0];
58 var y21 = box2[1];
59 var x22 = box2[0] + box2[2];
60 var y22 = box2[1] + box2[3];
61 var x_overlap = Math.max(0, Math.min(x12,x22) - Math.max(x11,x21));
62 var y_overlap = Math.max(0, Math.min(y12,y22) - Math.max(y11,y21));
63 return (x_overlap / Math.min(box1[2], box2[2]) > 0.25
64 && y_overlap / Math.min(box1[3], box2[3]) > 0.25);
65 }
66
67 function computeIntersections(hitBox) {
68 var absoluteHitBox = [hitBox[0] * width, hitBox[1] * height,
69 hitBox[2] * width, hitBox[3] * height];
70
71 var intersections = [];
72 for (var i in boundingBoxes) {
73 var boundingBox = boundingBoxes[i];
74 if (intersects(absoluteHitBox, boundingBox)) {
75 intersections.push(i);
76 }
77 }
78
79 return intersections;
80 }
81}
082
=== added file 'plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml'
--- plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,95 @@
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 Florian Boucault <florian.boucault@canonical.com>
17 */
18
19import QtQuick 2.4
20import Ubuntu.Components 1.3
21
22ShaderEffect {
23 id: segmentRenderer
24
25 implicitWidth: texture.width
26 implicitHeight: texture.height
27
28 function animate(segments) {
29 for (var i in segments) {
30 var progressPixel = progressTexture.children[segments[i]];
31 if (progressPixel.progress == 0.0) {
32 progressPixel.animation.start();
33 }
34 }
35 }
36
37 property string source
38 property int segmentsCount
39 property color backgroundColor: theme.palette.normal.base
40 property color fillColor: theme.palette.normal.activity
41 property Image texture: Image {
42 source: segmentRenderer.source
43 }
44 property var progressTexture: progressTexture
45 property int progressTextureSize: progressTexture.size
46
47 fragmentShader: "
48 varying mediump vec2 qt_TexCoord0;
49 uniform lowp float qt_Opacity;
50 uniform lowp vec4 backgroundColor;
51 uniform lowp vec4 fillColor;
52 uniform lowp sampler2D texture;
53 uniform lowp sampler2D progressTexture;
54 uniform lowp int progressTextureSize;
55
56 void main() {
57 lowp vec4 p = texture2D(texture, qt_TexCoord0);
58 lowp float segment = p.r * 255.0;
59 lowp vec4 segmentProgress = step(0.9, segment) * texture2D(progressTexture, vec2((segment - 1.0 + 0.5) / float(progressTextureSize), 0.5));
60 lowp vec4 color = mix(fillColor, backgroundColor, step(segmentProgress.r, p.g));
61 gl_FragColor = vec4(color.rgb, 1.0) * p.b * qt_Opacity;
62 }
63 "
64
65 // TODO: not the most efficient; could be replaced with an image provider
66 Row {
67 id: progressTexture
68
69 property int size: 128
70 layer.enabled: true
71 layer.sourceRect: Qt.rect(0, 0, size, 1)
72 layer.textureSize: Qt.size(size, 1)
73 layer.wrapMode: ShaderEffectSource.ClampToEdge
74 visible: false
75
76 Repeater {
77 model: segmentRenderer.segmentsCount
78 Rectangle {
79 id: progressPixel
80 width: 1
81 height: 1
82 color: Qt.rgba(progress, progress, progress, 1.0)
83 property real progress
84 property NumberAnimation animation: NumberAnimation {
85 target: progressPixel
86 property: "progress"
87 from: 0.0
88 to: 1.0
89 duration: UbuntuAnimation.SleepyDuration
90 easing: UbuntuAnimation.StandardEasing
91 }
92 }
93 }
94 }
95}
096
=== added file 'plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml'
--- plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,52 @@
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 Florian Boucault <florian.boucault@canonical.com>
17 */
18
19import QtQuick 2.4
20
21Item {
22 id: segImg
23 property alias textureSource: segmentRenderer.source
24 property alias boxesSource: segmentBoundingBoxes.source
25
26 implicitWidth: segmentRenderer.implicitWidth
27 implicitHeight: segmentRenderer.implicitHeight
28
29 // Ready to enroll.
30 signal ready()
31
32 function enrollMasks(masks) {
33 if (masks && masks.length) {
34 var segments = [];
35 masks.forEach(function (mask, i) {
36 var hitBox = [mask.x, mask.y, mask.width, mask.height];
37 segments = segments.concat(segmentBoundingBoxes.computeIntersections(hitBox));
38 });
39 segmentRenderer.animate(segments);
40 }
41 }
42
43 SegmentRenderer {
44 id: segmentRenderer
45 segmentsCount: segmentBoundingBoxes.count
46 }
47
48 SegmentBoundingBoxes {
49 id: segmentBoundingBoxes
50 onReady: segImg.ready()
51 }
52}
053
=== added file 'plugins/Ubuntu/Settings/Fingerprint/Setup.qml'
--- plugins/Ubuntu/Settings/Fingerprint/Setup.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/Setup.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,388 @@
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
19import Biometryd 0.0
20import QtGraphicalEffects 1.0
21import QtQuick 2.4
22import QtQuick.Layouts 1.1
23import Ubuntu.Components 1.3
24import Ubuntu.Settings.Fingerprint 0.1
25
26Page {
27 id: root
28
29 objectName: "fingerprintSetupPage"
30
31 signal enroll()
32 signal cancel()
33
34 function enrollmentFailed(error) {
35 root.state = "failed";
36 }
37
38 function enrollmentCompleted() {
39 root.state = "done";
40 }
41
42 function enrollmentProgressed(progress, hints) {
43 root.state = "reading";
44 imageDefault.masks = hints[FingerprintReader.masks];
45 progressLabel.progress = 100 * progress;
46 directionContainer.direction = hints[FingerprintReader.suggestedNextDirection] || FingerprintReader.NotAvailable;
47 }
48
49 states: [
50 State {
51 name: ""
52 StateChangeScript {
53 script: statusLabel.setText(statusLabel.initialText)
54 }
55 },
56 State {
57 name: "reading"
58 StateChangeScript {
59 script: statusLabel.setText(
60 i18n.dtr("ubuntu-settings-components",
61 "Lift and press your finger again.")
62 )
63 }
64 PropertyChanges {
65 target: imageDefault
66 opacity: 1
67 }
68 PropertyChanges {
69 target: progressLabel
70 opacity: 1
71 }
72 },
73 State {
74 name: "longer"
75 StateChangeScript {
76 script: statusLabel.setText(
77 i18n.dtr("ubuntu-settings-components",
78 "Keep your finger on the reader for longer.")
79 )
80 }
81 },
82 State {
83 name: "failed"
84 PropertyChanges {
85 target: imageDefault
86 opacity: 0
87 }
88 PropertyChanges {
89 target: imageFailed
90 opacity: 1
91 }
92 PropertyChanges {
93 target: cancelButton
94 text: i18n.dtr("ubuntu-settings-components", "Back");
95 }
96 PropertyChanges {
97 target: doneButton
98 visible: false
99 }
100 StateChangeScript {
101 script: statusLabel.setText(
102 i18n.dtr("ubuntu-settings-components",
103 "Sorry, the reader doesn’t seem to be working."),
104 true // No animation
105 )
106 }
107 StateChangeScript {
108 script: imageFailed.start()
109 }
110 PropertyChanges {
111 target: directionContainer
112 opacity: 0
113 }
114 },
115 State {
116 name: "done"
117 PropertyChanges {
118 target: imageDefault
119 opacity: 0
120 }
121 PropertyChanges {
122 target: imageDone
123 opacity: 1
124 }
125 PropertyChanges {
126 target: cancelButton
127 visible: false
128 }
129 StateChangeScript {
130 script: statusLabel.setText(
131 i18n.dtr("ubuntu-settings-components", "All done!"),
132 true // No animation
133 )
134 }
135 PropertyChanges {
136 target: doneButton
137 enabled: true
138 text: i18n.dtr("ubuntu-settings-components", "OK")
139 }
140 StateChangeScript {
141 script: imageDone.start()
142 }
143 PropertyChanges {
144 target: directionContainer
145 opacity: 0
146 }
147 }
148 ]
149
150 header: PageHeader {
151 visible: false
152 }
153
154 Item {
155 anchors.fill: parent
156
157 Item {
158 id: fingerprintBox
159 anchors.centerIn: parent
160 width: units.gu(26)
161 height: units.gu(29)
162
163 Item {
164 id: imageContainer
165 anchors.centerIn: parent
166 width: imageDefault.implicitWidth
167 height: imageDefault.implicitHeight
168
169 // Default image.
170 FingerprintVisual {
171 id: imageDefault
172 objectName: "fingerprintDefaultVisual"
173 anchors.centerIn: parent
174
175 Behavior on opacity { UbuntuNumberAnimation {
176 duration: UbuntuAnimation.SlowDuration
177 easing: UbuntuAnimation.StandardEasing
178 }}
179 }
180
181 // Failed image.
182 CircularSegment {
183 id: imageFailed
184 objectName: "fingerprintFailedVisual"
185 opacity: 0
186 color: "#ED3146"
187 width: directionContainer.width - units.dp(3)
188
189 anchors.centerIn: parent
190
191 function start () {
192 failAngstopAnim.start();
193 failThichAnim.start();
194 }
195
196 NumberAnimation on angleStop {
197 id: failAngstopAnim
198 running: false
199 from: 0
200 to: 360
201 duration: UbuntuAnimation.SlowDuration
202 easing: UbuntuAnimation.StandardEasing
203 }
204
205 NumberAnimation on thickness {
206 id: failThichAnim
207 running: false
208 from: 0
209 to: units.dp(3)
210 duration: UbuntuAnimation.SlowDuration
211 easing: UbuntuAnimation.StandardEasing
212 }
213
214 Icon {
215 name: "close"
216 color: "#ED3146"
217 width: units.gu(18)
218 anchors.centerIn: parent
219 }
220
221 Behavior on opacity { UbuntuNumberAnimation {
222 duration: UbuntuAnimation.SlowDuration
223 easing: UbuntuAnimation.StandardEasing
224 }}
225 }
226
227 // Done image.
228 CircularSegment {
229 id: imageDone
230 objectName: "fingerprintDoneVisual"
231 opacity: 0
232 width: directionContainer.width - units.dp(3)
233
234 anchors.centerIn: parent
235
236 function start () {
237 angstopAnim.start();
238 thickAnim.start();
239 }
240
241 NumberAnimation on angleStop {
242 id: angstopAnim
243 running: false
244 from: 0
245 to: 360
246 duration: UbuntuAnimation.SlowDuration
247 easing: UbuntuAnimation.StandardEasing
248 }
249
250 NumberAnimation on thickness {
251 id: thickAnim
252 running: false
253 from: 0
254 to: units.dp(3)
255 duration: UbuntuAnimation.SlowDuration
256 easing: UbuntuAnimation.StandardEasing
257 }
258
259 Icon {
260 name: "tick"
261 color: "#3EB34F"
262 width: units.gu(18)
263 anchors.centerIn: parent
264 }
265
266 Behavior on opacity { UbuntuNumberAnimation {
267 duration: UbuntuAnimation.SlowDuration
268 easing: UbuntuAnimation.StandardEasing
269 }}
270 }
271
272 DirectionVisual {
273 id: directionContainer
274 objectName: "fingerprintDirectionVisual"
275 anchors.centerIn: parent
276
277 width: Math.sqrt(
278 imageContainer.width*imageContainer.width
279 + imageContainer.height*imageContainer.height
280 )
281 height: width
282 }
283 }
284 }
285
286 StatusLabel {
287 id: statusLabel
288 anchors {
289 left: parent.left
290 leftMargin: units.gu(2.9)
291 right: parent.right
292 rightMargin: units.gu(2.9)
293 top: parent.top
294 topMargin: units.gu(5)
295 }
296 initialText: i18n.dtr("ubuntu-settings-components",
297 "Place your finger on the home button.")
298 objectName: "fingerprintStatusLabel"
299 }
300
301
302 Label {
303 id: progressLabel
304 objectName: "fingerprintProgressLabel"
305 property int progress: 0
306 anchors {
307 top: fingerprintBox.bottom
308 topMargin: units.gu(1.5)
309 horizontalCenter: parent.horizontalCenter
310 }
311 text: i18n.dtr("ubuntu-settings-components", "%1%").arg((progress).toFixed());
312 opacity: 0
313 horizontalAlignment: Text.AlignHCenter
314 fontSize: "large"
315 color: theme.palette.normal.backgroundTertiaryText
316
317 Behavior on opacity { UbuntuNumberAnimation {} }
318 Behavior on progress {
319 NumberAnimation {
320 duration: UbuntuAnimation.SlowDuration
321 easing: UbuntuAnimation.StandardEasing
322 }
323 }
324 }
325
326 Rectangle {
327 id: actions
328
329 anchors {
330 left: parent.left
331 right: parent.right
332 bottom: parent.bottom
333 }
334
335 // Color and height values are copied from the Wizard.
336 color: "#f5f5f5"
337 height: units.gu(5)
338
339 AbstractButton {
340 id: cancelButton
341 property alias text: cancelButtonText.text
342 objectName: "fingerprintSetupCancelButton"
343 anchors {
344 left: parent.left
345 leftMargin: units.gu(3)
346 verticalCenter: parent.verticalCenter
347 }
348 height: parent.height
349 width: units.gu(10)
350 onClicked: {
351 root.cancel();
352 pageStack.pop();
353 }
354
355 Label {
356 id: cancelButtonText
357 anchors.verticalCenter: parent.verticalCenter
358 text: i18n.dtr("ubuntu-settings-components", "Cancel")
359 }
360 }
361
362 AbstractButton {
363 id: doneButton
364 property alias text: doneButtonText.text
365 objectName: "fingerprintSetupDoneButton"
366 anchors {
367 right: parent.right
368 rightMargin: units.gu(3)
369 verticalCenter: parent.verticalCenter
370 }
371 enabled: false
372 height: parent.height
373 width: units.gu(10)
374 onClicked: pageStack.pop()
375
376 Label {
377 id: doneButtonText
378 anchors {
379 verticalCenter: parent.verticalCenter
380 right: parent.right
381 }
382 font.bold: parent.enabled
383 text: i18n.dtr("ubuntu-settings-components", "Next")
384 }
385 }
386 }
387 }
388}
0389
=== added file 'plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml'
--- plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,84 @@
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
19import QtQuick 2.4
20import Ubuntu.Components 1.3
21
22Item {
23 id: root
24
25 property string initialText
26 property int origX: 0
27 readonly property alias text: label.text
28
29 signal slideStarted()
30 signal slideCompleted()
31
32 Component.onCompleted: origX = label.x
33
34 function setText(text, noAnimation) {
35 if (noAnimation === true) {
36 label.text = text;
37 return;
38 }
39
40 function outStoppedHandler () {
41 label.text = text;
42 label.x = units.gu(50)
43 inAnim.start();
44 outAnim.stopped.disconnect(outStoppedHandler);
45 }
46 outAnim.stopped.connect(outStoppedHandler);
47 outAnim.start();
48 }
49
50 Label {
51 id: label
52
53 font.pixelSize: units.gu(3.3)
54 horizontalAlignment: Text.AlignHCenter
55 height: units.gu(4)
56 text: initialText
57 width: parent.width
58 wrapMode: Text.WordWrap
59 }
60
61 NumberAnimation {
62 id: outAnim
63
64 alwaysRunToEnd: true
65 duration: UbuntuAnimation.FastDuration
66 easing: UbuntuAnimation.StandardEasing
67 onStarted: root.slideStarted()
68 property: "x"
69 target: label
70 to: -units.gu(50)
71 }
72
73 NumberAnimation {
74 id: inAnim
75
76 alwaysRunToEnd: true
77 duration: UbuntuAnimation.FastDuration
78 easing: UbuntuAnimation.StandardEasing
79 onStopped: root.slideCompleted()
80 property: "x"
81 target: label
82 to: root.origX
83 }
84}
085
=== added directory 'plugins/Ubuntu/Settings/Fingerprint/assets'
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets.qrc'
--- plugins/Ubuntu/Settings/Fingerprint/assets.qrc 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/assets.qrc 2016-06-15 10:46:42 +0000
@@ -0,0 +1,11 @@
1<!DOCTYPE RCC><RCC version="1.0">
2<qresource>
3 <file>assets/shape-up@27.png</file>
4 <file>assets/shape-up@27.sci</file>
5 <file>assets/shape-down@27.png</file>
6 <file>assets/shape-down@27.sci</file>
7
8 <file>assets/fingerprint_segmented@27.png</file>
9 <file>assets/fingerprint_boxes.json</file>
10</qresource>
11</RCC>
012
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json'
--- plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json 2016-06-15 10:46:42 +0000
@@ -0,0 +1,1 @@
1{"width": 451, "boxes": [[291, 515, 104, 50], [269, 510, 96, 34], [227, 506, 62, 16], [198, 505, 72, 60], [144, 498, 46, 67], [200, 467, 133, 32], [214, 449, 87, 28], [67, 432, 25, 104], [396, 420, 31, 89], [177, 395, 22, 103], [133, 390, 15, 96], [266, 375, 8, 31], [1, 356, 7, 42], [336, 355, 27, 114], [221, 350, 95, 105], [243, 323, 17, 106], [155, 317, 68, 248], [110, 317, 43, 243], [22, 314, 12, 155], [199, 310, 13, 127], [302, 296, 83, 223], [276, 295, 20, 136], [311, 275, 30, 189], [177, 266, 8, 114], [88, 263, 34, 287], [221, 249, 9, 86], [441, 238, 9, 169], [110, 231, 9, 70], [44, 226, 16, 280], [310, 225, 8, 181], [199, 223, 53, 86], [370, 217, 37, 288], [249, 208, 25, 153], [177, 201, 61, 49], [281, 195, 15, 85], [133, 183, 16, 196], [177, 178, 96, 29], [155, 167, 35, 134], [345, 166, 18, 173], [200, 156, 81, 31], [1, 149, 17, 192], [386, 145, 18, 60], [305, 142, 36, 118], [66, 139, 26, 277], [149, 134, 168, 77], [111, 132, 45, 85], [88, 130, 36, 120], [350, 118, 35, 162], [165, 111, 134, 28], [262, 92, 85, 64], [414, 91, 35, 133], [129, 89, 119, 36], [22, 88, 42, 211], [92, 67, 256, 62], [47, 64, 75, 149], [349, 47, 80, 360], [132, 44, 257, 90], [13, 41, 56, 95], [66, 22, 273, 60], [198, 1, 215, 76], [74, 1, 109, 39]], "height": 566}
02
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_segmented@27.png'
1Binary files plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_segmented@27.png 1970-01-01 00:00:00 +0000 and plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_segmented@27.png 2016-06-15 10:46:42 +0000 differ3Binary files plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_segmented@27.png 1970-01-01 00:00:00 +0000 and plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_segmented@27.png 2016-06-15 10:46:42 +0000 differ
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.png'
2Binary files plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.png 1970-01-01 00:00:00 +0000 and plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.png 2016-06-15 10:46:42 +0000 differ4Binary files plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.png 1970-01-01 00:00:00 +0000 and plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.png 2016-06-15 10:46:42 +0000 differ
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci'
--- plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci 2016-06-15 10:46:42 +0000
@@ -0,0 +1,7 @@
1border.top: 222
2border.right: 222
3border.bottom: 222
4border.left: 222
5horizontalTileMode: Round
6verticalTileMode: Round
7source: "shape-down@27.png"
08
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.png'
1Binary files plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.png 1970-01-01 00:00:00 +0000 and plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.png 2016-06-15 10:46:42 +0000 differ9Binary files plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.png 1970-01-01 00:00:00 +0000 and plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.png 2016-06-15 10:46:42 +0000 differ
=== added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci'
--- plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci 2016-06-15 10:46:42 +0000
@@ -0,0 +1,7 @@
1border.top: 260
2border.right: 260
3border.bottom: 260
4border.left: 260
5horizontalTileMode: Round
6verticalTileMode: Round
7source: "shape-up@27.png"
08
=== added file 'plugins/Ubuntu/Settings/Fingerprint/plugin.cpp'
--- plugins/Ubuntu/Settings/Fingerprint/plugin.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/plugin.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 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
17#include "plugin.h"
18#include "ubuntusettingsfingerprint.h"
19
20#include <QtQml/qqml.h>
21
22static QObject* fp_singletonprovider(QQmlEngine *engine, QJSEngine *scriptEngine)
23{
24 Q_UNUSED(engine)
25 Q_UNUSED(scriptEngine)
26
27 return new UbuntuSettingsFingerprint;
28}
29
30void UbuntuSettingsFingerprintPlugin::registerTypes(const char *uri)
31{
32 qmlRegisterSingletonType<UbuntuSettingsFingerprint>(
33 uri, 0, 1, "UbuntuSettingsFingerprint", fp_singletonprovider
34 );
35}
036
=== added file 'plugins/Ubuntu/Settings/Fingerprint/plugin.h'
--- plugins/Ubuntu/Settings/Fingerprint/plugin.h 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/plugin.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 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
17#ifndef UBUNTUSETTINGSFINGERPRINT_PLUGIN_H
18#define UBUNTUSETTINGSFINGERPRINT_PLUGIN_H
19
20#include <QtQml/QQmlExtensionPlugin>
21
22class UbuntuSettingsFingerprintPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26public:
27 void registerTypes(const char *uri);
28};
29
30#endif // UBUNTUSETTINGSFINGERPRINT_PLUGIN_H
031
=== added file 'plugins/Ubuntu/Settings/Fingerprint/qmldir'
--- plugins/Ubuntu/Settings/Fingerprint/qmldir 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/qmldir 2016-06-15 10:46:42 +0000
@@ -0,0 +1,7 @@
1module Ubuntu.Settings.Fingerprint
2plugin UbuntuSettingsFingerprintQml
3
4Fingerprint 0.1 Fingerprint.qml
5Fingerprints 0.1 Fingerprints.qml
6FingerprintVisual 0.1 FingerprintVisual.qml
7Setup 0.1 Setup.qml
08
=== added file 'plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp'
--- plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 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#include <unistd.h>
19#include <sys/types.h>
20#include <QProcessEnvironment>
21
22#include "ubuntusettingsfingerprint.h"
23
24UbuntuSettingsFingerprint::UbuntuSettingsFingerprint(QObject* parent)
25 : QObject(parent)
26{
27}
28
29qlonglong UbuntuSettingsFingerprint::uid() const
30{
31 return qlonglong(getuid());
32}
33
34bool UbuntuSettingsFingerprint::debug() const
35{
36 return QProcessEnvironment::systemEnvironment().contains(
37 QLatin1String("USC_FINGERPRINT_DEBUG")
38 );
39}
040
=== added file 'plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h'
--- plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 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#ifndef UBUNTUSETTINGSFINGERPRINT_H
20#define UBUNTUSETTINGSFINGERPRINT_H
21
22#include <QObject>
23
24class UbuntuSettingsFingerprint : public QObject
25{
26 Q_OBJECT
27public:
28 explicit UbuntuSettingsFingerprint(QObject* parent = 0);
29
30 Q_PROPERTY(qlonglong uid READ uid CONSTANT)
31 Q_PROPERTY(bool debug READ debug CONSTANT)
32
33 qlonglong uid() const;
34 bool debug() const;
35};
36
37#endif // UBUNTUSETTINGSFINGERPRINT_H
038
=== added directory 'plugins/Ubuntu/Settings/Fingerprint/utils'
=== added file 'plugins/Ubuntu/Settings/Fingerprint/utils/segment.py'
--- plugins/Ubuntu/Settings/Fingerprint/utils/segment.py 1970-01-01 00:00:00 +0000
+++ plugins/Ubuntu/Settings/Fingerprint/utils/segment.py 2016-06-15 10:46:42 +0000
@@ -0,0 +1,84 @@
1#!/usr/bin/python2
2"""
3 * Copyright 2016 Canonical Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by Florian Boucault <florian.boucault@canonical.com>
18 */
19"""
20
21import os.path
22import argparse
23import json
24import cv2
25
26parser = argparse.ArgumentParser(
27 description='Generates segmented version of img and extracts bbs.'
28)
29parser.add_argument('input_image', type=str,
30 help='path to the image to segment')
31args = parser.parse_args()
32
33input_image = os.path.abspath(args.input_image)
34print("Segmenting %s..." % input_image)
35filename, _ = os.path.splitext(os.path.basename(input_image))
36split = filename.split('@')
37if len(split) != 1:
38 output_image = "%s_segmented@%s.png" % (split[0], split[1])
39 output_boxes = "%s_boxes.json" % split[0]
40else:
41 output_image = "%s_segmented.png" % filename
42 output_boxes = "%s_boxes.json" % filename
43
44img = cv2.imread(input_image, -1)
45img_boxes = img.copy()
46gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
47ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY)
48contours, hierarchy = cv2.findContours(
49 thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE
50)
51
52print("Detected %d segments." % len(contours))
53
54bounding_boxes = []
55for index, contour in enumerate(contours):
56 x, y, w, h = cv2.boundingRect(contour)
57 bounding_boxes.append((x, y, w, h))
58# print(x, y, w, h)
59 cv2.rectangle(img_boxes,
60 (x, y),
61 (x + w, y + h),
62 (255, 20, 20, 255), 1)
63 cv2.drawContours(thresh, contours, index, (index + 1),
64 cv2.cv.CV_FILLED)
65 cv2.drawContours(thresh, contours, index, (index + 1), 2)
66
67b, g, r, a = cv2.split(img)
68img = cv2.merge([a, g, thresh])
69
70cv2.imwrite(output_image, img)
71print("Written segmented version of '%s' to '%s'" % (
72 args.input_image, output_image)
73)
74
75description = {"width": img.shape[1],
76 "height": img.shape[0],
77 "boxes": bounding_boxes}
78with open(output_boxes, 'w') as outfile:
79 json.dump(description, outfile)
80print("Written bounding boxes to '%s'" % output_boxes)
81
82cv2.imshow('image', img_boxes)
83cv2.waitKey(0)
84cv2.destroyAllWindows()
085
=== modified file 'po/ubuntu-settings-components.pot'
--- po/ubuntu-settings-components.pot 2016-05-19 17:52:21 +0000
+++ po/ubuntu-settings-components.pot 2016-06-15 10:46:42 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: ubuntu-settings-components\n"9"Project-Id-Version: ubuntu-settings-components\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2016-04-25 15:44+0200\n"11"POT-Creation-Date: 2016-06-15 12:46+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,6 +21,105 @@
21msgid "Quick reply with:"21msgid "Quick reply with:"
22msgstr ""22msgstr ""
2323
24#: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:80
25msgid "Fingerprint Name"
26msgstr ""
27
28#: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:107
29msgid "Delete Fingerprint"
30msgstr ""
31
32#: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:124
33msgid "Sorry, the fingerprint could not be deleted."
34msgstr ""
35
36#: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:129
37#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:338
38#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:138
39#: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:148
40msgid "OK"
41msgstr ""
42
43#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:32
44msgid "Fingerprint ID"
45msgstr ""
46
47#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:93
48#, qt-format
49msgid "Finger %1"
50msgstr ""
51
52#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:188
53msgid "Passcode required"
54msgstr ""
55
56#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:192
57msgid "You must set a passcode to use fingerprint ID"
58msgstr ""
59
60#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:199
61msgid "Set Passcode…"
62msgstr ""
63
64#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:275
65msgid "Add fingerprint"
66msgstr ""
67
68#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:288
69msgid "Remove All…"
70msgstr ""
71
72#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:303
73msgid "Are you sure you want to forget all stored fingerprints?"
74msgstr ""
75
76#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:312
77#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:358
78#: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:161
79#: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:135
80#: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:104
81msgid "Cancel"
82msgstr ""
83
84#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:319
85#: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:84
86msgid "Remove"
87msgstr ""
88
89#: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:333
90#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:103
91msgid "Sorry, the reader doesn’t seem to be working."
92msgstr ""
93
94#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:61
95msgid "Lift and press your finger again."
96msgstr ""
97
98#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:78
99msgid "Keep your finger on the reader for longer."
100msgstr ""
101
102#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:94
103msgid "Back"
104msgstr ""
105
106#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:131
107msgid "All done!"
108msgstr ""
109
110#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:297
111msgid "Place your finger on the home button."
112msgstr ""
113
114#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:311
115#, qt-format
116msgid "%1%"
117msgstr ""
118
119#: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:383
120msgid "Next"
121msgstr ""
122
24#: plugins/Ubuntu/Settings/Menus/CalendarMenu.qml:57123#: plugins/Ubuntu/Settings/Menus/CalendarMenu.qml:57
25#, qt-format124#, qt-format
26msgctxt "%1=month name, %2=4-digit year"125msgctxt "%1=month name, %2=4-digit year"
@@ -48,12 +147,6 @@
48msgid "Message"147msgid "Message"
49msgstr ""148msgstr ""
50149
51#: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:161
52#: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:134
53#: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:104
54msgid "Cancel"
55msgstr ""
56
57#: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:170150#: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:170
58msgid "Accept"151msgid "Accept"
59msgstr ""152msgstr ""
@@ -358,14 +451,10 @@
358msgid "Your Wi-Fi/mobile provider can track your use of any other services. "451msgid "Your Wi-Fi/mobile provider can track your use of any other services. "
359msgstr ""452msgstr ""
360453
361#: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:26454#: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:25
362msgid "Set up VPN"455msgid "Set up VPN"
363msgstr ""456msgstr ""
364457
365#: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:147
366msgid "OK"
367msgstr ""
368
369#: plugins/Ubuntu/Settings/Vpn/VpnList.qml:62458#: plugins/Ubuntu/Settings/Vpn/VpnList.qml:62
370msgid "Delete configuration"459msgid "Delete configuration"
371msgstr ""460msgstr ""
@@ -380,10 +469,6 @@
380msgid "VPN"469msgid "VPN"
381msgstr ""470msgstr ""
382471
383#: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:84
384msgid "Remove"
385msgstr ""
386
387#: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:96472#: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:96
388msgid "Change"473msgid "Change"
389msgstr ""474msgstr ""
390475
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2016-03-09 14:04:14 +0000
+++ tests/qmltests/CMakeLists.txt 2016-06-15 10:46:42 +0000
@@ -1,6 +1,8 @@
1# add_qml_test macro1# add_qml_test macro
2include(QmlTest)2include(QmlTest)
33
4add_subdirectory(mocks)
5
4set(qmltest_DEFAULT_TARGETS qmluitests)6set(qmltest_DEFAULT_TARGETS qmluitests)
5set(qmltest_DEFAULT_NO_ADD_TEST TRUE)7set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
6set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")8set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")
@@ -40,3 +42,8 @@
40add_qml_test(Vpn VpnPptpEditor)42add_qml_test(Vpn VpnPptpEditor)
41add_qml_test(Vpn VpnPreviewDialogCertificateChecks)43add_qml_test(Vpn VpnPreviewDialogCertificateChecks)
42add_qml_test(Vpn VpnPreviewDialog ENVIRONMENT NO_SSL_CERTIFICATE_CHECK=1)44add_qml_test(Vpn VpnPreviewDialog ENVIRONMENT NO_SSL_CERTIFICATE_CHECK=1)
45
46add_qml_test(Fingerprint Fingerprints IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/mocks)
47add_qml_test(Fingerprint FingerprintNames IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/mocks)
48add_qml_test(Fingerprint FingerprintSetup IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/mocks)
49add_qml_test(Fingerprint FingerprintVisual)
4350
=== added directory 'tests/qmltests/Fingerprint'
=== added file 'tests/qmltests/Fingerprint/tst_FingerprintNames.qml'
--- tests/qmltests/Fingerprint/tst_FingerprintNames.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Fingerprint/tst_FingerprintNames.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,364 @@
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
19import QtQuick 2.4
20import QtTest 1.0
21import Ubuntu.Test 0.1
22import Ubuntu.Settings.Fingerprint 0.1
23import Ubuntu.Components 1.3
24import Biometryd 0.0
25import GSettings 1.0
26
27Item {
28 id: testRoot
29 width: units.gu(50)
30 height: units.gu(90)
31
32 PageStack {
33 id: pageStack
34 }
35
36 Component {
37 id: fingerprintsComponent
38
39 Fingerprints {
40 anchors.fill: parent
41 visible: false
42 }
43 }
44
45 Component {
46 id: fingerprintComponent
47
48 Fingerprint {
49 anchors.fill: parent
50 visible: false
51 }
52 }
53
54 Component {
55 id: gsettingsComponent
56
57 GSettings {
58 schema.id: "com.ubuntu.touch.system"
59 }
60 }
61
62 UbuntuTestCase {
63 name: "TestOverview"
64 when: windowShown
65
66 property var pageInstance: null
67 property var gsettingsInstance: null
68
69 function getTemplateEntry(i) {
70 var id = "fingerprintInstance-" + i;
71 return findChild(pageInstance, id);
72 }
73
74 function getListObserver() {
75 return findInvisibleChild(pageInstance, "listObserver");
76 }
77
78 function getRemovalObserver() {
79 return findInvisibleChild(pageInstance, "removalObserver");
80 }
81
82 function getClearanceObserver() {
83 return findInvisibleChild(pageInstance, "clearanceObserver");
84 }
85
86 function getEnrollmentObserver() {
87 return findInvisibleChild(pageInstance, "enrollmentObserver");
88 }
89
90 function initTestCase() {
91 Biometryd.setAvailable(true);
92 }
93
94 function init() {
95 gsettingsInstance = gsettingsComponent.createObject(testRoot);
96 pageInstance = fingerprintsComponent.createObject(testRoot, {
97 _settings: gsettingsInstance,
98 passcodeSet: true
99 });
100 pageStack.push(pageInstance);
101 }
102
103 function test_listSort() {
104 GSettingsController.setFingerprintNames({
105 "first": "A finger",
106 "second": "Big finger",
107 "last": "Zmall finger",
108 });
109 compare(getTemplateEntry(0).title.text, "A finger");
110 compare(getTemplateEntry(1).title.text, "Big finger");
111 compare(getTemplateEntry(2).title.text, "Zmall finger");
112 }
113
114 function test_remoteRemoval() {
115 GSettingsController.setFingerprintNames({
116 "tmplId": "name"
117 });
118 verify(getTemplateEntry(0));
119
120 GSettingsController.setFingerprintNames({});
121 verify(!getTemplateEntry(0));
122 }
123
124 function test_remoteAddition() {
125 GSettingsController.setFingerprintNames({
126 "tmplId": "name"
127 });
128 verify(getTemplateEntry(0));
129
130 GSettingsController.setFingerprintNames({
131 "tmplId": "name",
132 "tmplId2": "name2"
133 });
134 verify(getTemplateEntry(0));
135 verify(getTemplateEntry(1));
136 }
137
138 function test_remoteRename() {
139 GSettingsController.setFingerprintNames({
140 "tmplId": "My finger",
141 });
142 compare(getTemplateEntry(0).title.text, "My finger");
143 GSettingsController.setFingerprintNames({
144 "tmplId": "Your finger",
145 });
146 compare(getTemplateEntry(0).title.text, "Your finger");
147 }
148
149 function test_localRemoval() {
150 GSettingsController.setFingerprintNames({
151 "tmplId": "name"
152 });
153 verify(getTemplateEntry(0));
154 pageInstance.removeTemplate("tmplId");
155 verify(!getTemplateEntry(0));
156 }
157
158 function test_localAddition() {
159 pageInstance.addTemplate("tmplId", "My finger");
160 verify(getTemplateEntry(0));
161 compare(getTemplateEntry(0).title.text, "My finger");
162 }
163
164 function test_localRename() {
165 GSettingsController.setFingerprintNames({
166 "tmplId": "My finger"
167 });
168 pageInstance.renameTemplate("tmplId", "Your finger");
169 verify(getTemplateEntry(0));
170 compare(getTemplateEntry(0).title.text, "Your finger");
171 }
172
173 function test_createTemplateName() {
174 GSettingsController.setFingerprintNames({
175 "tmplId": i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1)
176 });
177 compare(pageInstance.createTemplateName(), i18n.dtr("ubuntu-settings-components", "Finger %1").arg(2));
178 pageInstance.renameTemplate("tmplId", i18n.dtr("ubuntu-settings-components", "Finger %1").arg(2));
179 compare(pageInstance.createTemplateName(), i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1));
180 }
181
182 function test_assignNames() {
183 var templateIds = ["tmplId0", "tmplId1", "tmplId2"];
184
185 // This name shouldn't be overwritten
186 GSettingsController.setFingerprintNames({
187 "tmplId1": "My finger"
188 });
189
190 getListObserver().mockList(templateIds, "");
191
192 verify(getTemplateEntry(0));
193 compare(getTemplateEntry(0).title.text, i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1));
194
195 verify(getTemplateEntry(1));
196 compare(getTemplateEntry(1).title.text, i18n.dtr("ubuntu-settings-components", "Finger %1").arg(2));
197
198 verify(getTemplateEntry(2));
199 compare(getTemplateEntry(2).title.text, "My finger");
200 }
201
202 function test_serviceRemoval() {
203 GSettingsController.setFingerprintNames({
204 "tmplId": "A finger"
205 });
206 getRemovalObserver().mockRemoval("tmplId", "");
207 verify(!getTemplateEntry(0));
208 compare(GSettingsController.fingerprintNames(), {});
209 }
210
211 function test_serviceEnrollment() {
212 GSettingsController.setFingerprintNames({
213 "tmplId1": "Existing finger"
214 });
215 getEnrollmentObserver().mockEnroll("tmplId2", "");
216
217 verify(getTemplateEntry(0));
218 compare(getTemplateEntry(0).title.text, "Existing finger");
219
220 verify(getTemplateEntry(1));
221 compare(getTemplateEntry(1).title.text, i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1));
222 }
223
224 function test_serviceEnrollmentFirstRun() {
225 var targetName = i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1);
226
227 // A test where the template id is 0.
228 getEnrollmentObserver().mockEnroll(0, "");
229
230 verify(getTemplateEntry(0));
231 compare(getTemplateEntry(0).title.text, targetName);
232 }
233
234 function test_serviceEnrollmentReusesId() {
235 // Test a case where enrollment processes re-uses the template id
236 // Hopefully this will never happen, but it currently does in testing,
237 // so test it.
238 var targetName = i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1);
239
240 getEnrollmentObserver().mockEnroll(0, "");
241 verify(getTemplateEntry(0));
242 compare(getTemplateEntry(0).title.text, targetName);
243
244 // Re-enroll same id, make sure it doesn't change the name
245 getEnrollmentObserver().mockEnroll(0, "");
246 verify(getTemplateEntry(0));
247 compare(getTemplateEntry(0).title.text, targetName);
248
249 }
250
251 function test_serviceClearance() {
252 GSettingsController.setFingerprintNames({
253 "tmplId1": "A finger",
254 "tmplId2": "My finger"
255 });
256 getClearanceObserver().mockClearance("");
257
258 verify(!getTemplateEntry(0));
259 compare(GSettingsController.fingerprintNames(), {});
260 }
261
262 function cleanup() {
263 pageStack.pop();
264 GSettingsController.setFingerprintNames({});
265 gsettingsInstance.destroy();
266 gsettingsInstance = null;
267 pageInstance.destroy();
268 pageInstance = null;
269 }
270 }
271
272 SignalSpy {
273 id: requestDeletionSpy
274 signalName: "requestDeletion"
275 }
276
277 SignalSpy {
278 id: requestRenameSpy
279 signalName: "requestRename"
280 }
281
282 UbuntuTestCase {
283 name: "TestTemplate"
284 when: windowShown
285
286 property var templateInstance: null
287
288 function getDeleteButton() {
289 return findChild(templateInstance, "templateDelete");
290 }
291
292 function getHeader() {
293 return findChild(templateInstance, "templateHeader");
294 }
295
296 function getNameInput() {
297 return findChild(templateInstance, "nameInput");
298 }
299
300 function getFailedDialog() {
301 return findChild(testRoot, "fingerprintDeletionFailedDialog");
302 }
303
304 function getFailedDialogOk() {
305 return findChild(testRoot, "fingerprintDeleteionFailedOk");
306 }
307
308 function init() {
309 templateInstance = fingerprintComponent.createObject(testRoot);
310 pageStack.push(templateInstance);
311 requestRenameSpy.target = templateInstance;
312 requestDeletionSpy.target = templateInstance;
313 }
314
315 function cleanup() {
316 requestRenameSpy.clear();
317 requestDeletionSpy.clear();
318 pageStack.pop();
319 templateInstance.destroy();
320 templateInstance = null;
321 }
322
323 function test_name() {
324 templateInstance.name = "My finger";
325 compare(getHeader().title, "My finger");
326 compare(getNameInput().text, "My finger");
327 }
328
329 function test_requestDeletion() {
330 templateInstance.templateId = "tmplId";
331 var button = getDeleteButton();
332 mouseClick(button, button.width / 2, button.height / 2);
333 requestDeletionSpy.wait();
334 compare(requestDeletionSpy.count, 1);
335 compare(requestDeletionSpy.signalArguments[0][0], "tmplId");
336 }
337
338 function test_requestRename() {
339 templateInstance.templateId = "tmplId";
340 templateInstance.name = "My finger";
341 requestRenameSpy.clear();
342
343 getNameInput().text = "Your finger";
344 requestRenameSpy.wait();
345 compare(requestRenameSpy.count, 1);
346 compare(requestRenameSpy.signalArguments[0][0], "tmplId");
347 compare(requestRenameSpy.signalArguments[0][1], "Your finger");
348 }
349
350 function test_deletionFailed() {
351 templateInstance.deletionFailed();
352 tryCompareFunction(function () {
353 return !!getFailedDialog();
354 }, true);
355
356 var button = getFailedDialogOk();
357 mouseClick(button, button.width / 2, button.height / 2);
358
359 tryCompareFunction(function () {
360 return !!getFailedDialog();
361 }, false);
362 }
363 }
364}
0365
=== added file 'tests/qmltests/Fingerprint/tst_FingerprintSetup.qml'
--- tests/qmltests/Fingerprint/tst_FingerprintSetup.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Fingerprint/tst_FingerprintSetup.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,236 @@
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
19import QtQuick 2.4
20import QtTest 1.0
21import Ubuntu.Components 1.3
22import Ubuntu.Settings.Fingerprint 0.1
23import Ubuntu.Test 0.1
24import Biometryd 0.0
25
26Item {
27 id: testRoot
28 width: units.gu(50)
29 height: units.gu(90)
30
31 Component {
32 id: setupComponent
33
34 Setup {
35 anchors.fill: parent
36 visible: false
37 }
38 }
39
40 PageStack {
41 id: pageStack
42 }
43
44 SignalSpy {
45 id: statusLabelSpy
46 signalName: "slideCompleted"
47 }
48
49 SignalSpy {
50 id: enrollmentObserverProgressedSpy
51 signalName: "progressed"
52 }
53
54 SignalSpy {
55 id: enrollmentObserverSucceededSpy
56 signalName: "succeeded"
57 }
58
59 SignalSpy {
60 id: enrollmentObserverFailedSpy
61 signalName: "failed"
62 }
63
64 UbuntuTestCase {
65 name: "SetupUI"
66 when: windowShown
67
68 property var setupInstance: null
69
70 function init() {
71 Biometryd.setAvailable(true);
72 setupInstance = setupComponent.createObject(testRoot);
73 pageStack.push(setupInstance);
74
75 statusLabelSpy.target = getStatusLabel();
76 }
77
78 function cleanup() {
79 statusLabelSpy.clear();
80
81 pageStack.pop();
82 setupInstance.destroy();
83 setupInstance = null
84 }
85
86 function getStatusLabel() {
87 return findChild(setupInstance, "fingerprintStatusLabel");
88 }
89
90 function getFailedVisual() {
91 return findChild(setupInstance, "fingerprintFailedVisual");
92 }
93
94 function getDefaultVisual() {
95 return findChild(setupInstance, "fingerprintDefaultVisual");
96 }
97
98 function getDoneVisual() {
99 return findChild(setupInstance, "fingerprintDoneVisual");
100 }
101
102 function getProgressLabel() {
103 return findChild(setupInstance, "fingerprintProgressLabel");
104 }
105
106 function test_initialState() {
107 var targetText = i18n.dtr("ubuntu-settings-components", "Place your finger on the home button.");
108 compare(getStatusLabel().text, targetText);
109
110 tryCompare(getDefaultVisual(), "opacity", 1);
111 tryCompare(getFailedVisual(), "opacity", 0);
112 tryCompare(getDoneVisual(), "opacity", 0);
113 }
114
115 function test_startedState() {
116 var targetText = i18n.dtr("ubuntu-settings-components", "Lift and press your finger again.");
117 setupInstance.enrollmentProgressed(0.5, {});
118 statusLabelSpy.wait();
119 compare(getStatusLabel().text, targetText);
120
121 tryCompare(getDefaultVisual(), "opacity", 1);
122 tryCompare(getFailedVisual(), "opacity", 0);
123 tryCompare(getDoneVisual(), "opacity", 0);
124 }
125
126 function test_failedStatus() {
127 var targetText = i18n.dtr("ubuntu-settings-components", "Sorry, the reader doesn’t seem to be working.");
128 setupInstance.enrollmentFailed("test failure");
129 compare(getStatusLabel().text, targetText);
130
131 tryCompare(getDefaultVisual(), "opacity", 0);
132 tryCompare(getFailedVisual(), "opacity", 1);
133 tryCompare(getDoneVisual(), "opacity", 0);
134 }
135
136 function test_successfulState() {
137 var targetText = i18n.dtr("ubuntu-settings-components", "All done!");
138
139 setupInstance.enrollmentCompleted();
140 compare(getStatusLabel().text, targetText);
141
142 tryCompare(getDefaultVisual(), "opacity", 0);
143 tryCompare(getFailedVisual(), "opacity", 0);
144 tryCompare(getDoneVisual(), "opacity", 1);
145
146 var button = findChild(pageStack, "fingerprintSetupDoneButton");
147 compare(button.enabled, true, "button was disabled when done");
148 }
149
150 function test_notDone() {
151 var button = findChild(pageStack, "fingerprintSetupDoneButton");
152 compare(button.enabled, false, "button was enabled initially");
153 }
154
155 function test_statusLabel() {
156 getStatusLabel().setText("foo");
157 statusLabelSpy.wait();
158 compare(getStatusLabel().text, "foo");
159 }
160
161 function test_direction_data() {
162 return [
163 { tag: "empty", visual: { visible: false, rotation: 0 }},
164 { tag: "not available", dir: FingerprintReader.NotAvailable, visual: { visible: false, rotation: 0 }},
165 { tag: "SouthWest", dir: FingerprintReader.SouthWest, visual: { visible: true, rotation: 225 }},
166 { tag: "South", dir: FingerprintReader.South, visual: { visible: true, rotation: 180 }},
167 { tag: "SouthEast", dir: FingerprintReader.SouthEast, visual: { visible: true, rotation: 135 }},
168 { tag: "NorthWest", dir: FingerprintReader.NorthWest, visual: { visible: true, rotation: 315 }},
169 { tag: "North", dir: FingerprintReader.North, visual: { visible: true, rotation: 0 }},
170 { tag: "NorthEast", dir: FingerprintReader.NorthEast, visual: { visible: true, rotation: 45 }},
171 { tag: "East", dir: FingerprintReader.East, visual: { visible: true, rotation: 90 }},
172 { tag: "West", dir: FingerprintReader.West, visual: { visible: true, rotation: 270 }}
173 ]
174 }
175
176 function test_direction(data) {
177 var vis = findChild(setupInstance, "fingerprintDirectionVisual");
178 var hints = {};
179 hints[FingerprintReader.suggestedNextDirection] = data.dir;
180
181 setupInstance.enrollmentProgressed(0.5, hints);
182
183 tryCompare(vis, "opacity", data.visual.visible ? 1 : 0)
184 compare(vis.opacity, data.visual.visible ? 1 : 0);
185 compare(vis.rotation, data.visual.rotation);
186 }
187
188 function test_progressHidden() {
189 var pl = getProgressLabel();
190 compare(pl.opacity, 0);
191 }
192
193 function test_progressVisible() {
194 var pl = getProgressLabel();
195 setupInstance.enrollmentProgressed(0.5, {});
196 tryCompare(pl, "opacity", 1);
197 tryCompare(pl, "text", i18n.dtr("ubuntu-settings-components", "%1%").arg(50));
198 }
199
200 function test_progressReadable() {
201 setupInstance.enrollmentProgressed(0.6666666667, {});
202 tryCompare(getProgressLabel(), "text", i18n.dtr("ubuntu-settings-components", "%1%").arg(66));
203 }
204
205 // This is a visual test where we can confirm that the arrow
206 // rotates using the orthodromic distance.
207 function test_directions() {
208 var hints = {};
209
210 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.North;
211 setupInstance.enrollmentProgressed(0.6666666667, hints);
212 wait(200)
213 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.East;
214 setupInstance.enrollmentProgressed(0.6666666667, hints);
215 wait(200)
216 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.South;
217 setupInstance.enrollmentProgressed(0.6666666667, hints);
218 wait(200)
219 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.West;
220 setupInstance.enrollmentProgressed(0.6666666667, hints);
221 wait(200)
222 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.SouthEast;
223 setupInstance.enrollmentProgressed(0.6666666667, hints);
224 wait(200)
225 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.NorthEast;
226 setupInstance.enrollmentProgressed(0.6666666667, hints);
227 wait(200)
228 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.NorthWest;
229 setupInstance.enrollmentProgressed(0.6666666667, hints);
230 wait(200)
231 hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.NorthEast;
232 setupInstance.enrollmentProgressed(0.6666666667, hints);
233 wait(200)
234 }
235 }
236}
0237
=== added file 'tests/qmltests/Fingerprint/tst_FingerprintVisual.qml'
--- tests/qmltests/Fingerprint/tst_FingerprintVisual.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Fingerprint/tst_FingerprintVisual.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,132 @@
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
19import QtQuick 2.4
20import QtTest 1.0
21import Ubuntu.Components 1.3
22import Ubuntu.Settings.Fingerprint 0.1
23import Ubuntu.Test 0.1
24
25Item {
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}
0133
=== added file 'tests/qmltests/Fingerprint/tst_Fingerprints.qml'
--- tests/qmltests/Fingerprint/tst_Fingerprints.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Fingerprint/tst_Fingerprints.qml 2016-06-15 10:46:42 +0000
@@ -0,0 +1,230 @@
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
19import QtQuick 2.4
20import QtTest 1.0
21import Ubuntu.Test 0.1
22import Ubuntu.Settings.Fingerprint 0.1
23import Biometryd 0.0
24import GSettings 1.0
25
26Item {
27 id: testRoot
28 width: units.gu(50)
29 height: units.gu(90)
30
31 Component {
32 id: fingerprintsComponent
33
34 Fingerprints {
35 anchors.fill: parent
36 }
37 }
38
39 SignalSpy {
40 id: spy
41 }
42
43 UbuntuTestCase {
44 name: "FingerprintPanel"
45 when: windowShown
46
47 property var fingerprintsInstance: null
48
49 function init() {
50 Biometryd.setAvailable(true);
51 fingerprintsInstance = fingerprintsComponent.createObject(testRoot);
52 }
53
54 function cleanup() {
55 spy.clear();
56 spy.target = null;
57 spy.signalName = "";
58 fingerprintsInstance.destroy();
59 GSettingsController.setFingerprintNames({});
60 }
61
62 function getClearanceObserver() {
63 return findInvisibleChild(fingerprintsInstance, "clearanceObserver");
64 }
65
66 function getListObserver() {
67 return findInvisibleChild(fingerprintsInstance, "listObserver");
68 }
69
70 function getEnrollmentObserver() {
71 return findInvisibleChild(fingerprintsInstance, "enrollmentObserver");
72 }
73
74 function getRemovalObserver() {
75 return findInvisibleChild(fingerprintsInstance, "removalObserver");
76 }
77
78 function getBrokenDialog() {
79 return findChild(testRoot, "fingerprintReaderBrokenDialog");
80 }
81
82 function getBrokenDialogOk() {
83 return findChild(testRoot, "fingerprintReaderBrokenDialogOK");
84 }
85
86 function getAddFingerprintItem() {
87 return findChild(fingerprintsInstance, "fingerprintAddListItemLayout");
88 }
89
90 function getRemoveAllButton() {
91 return findChild(fingerprintsInstance, "fingerprintRemoveAllButton");
92 }
93
94 function getFingerprintsList() {
95 return findChild(fingerprintsInstance, "fingerprintsList");
96 }
97
98 function getSetupEntry() {
99 return findChild(fingerprintsInstance, "fingerprintSetupEntry");
100 }
101
102 function test_failures_data() {
103 return [
104 { tag: "clearance", observer: getClearanceObserver, mock: "mockClearance", mockArgs: ["failed"] },
105 { tag: "list", observer: getListObserver, mock: "mockList", mockArgs: [[], "failed"] }
106 ]
107 }
108
109 function test_failures(data) {
110 var obs = data.observer();
111 spy.signalName = "failed";
112 spy.target = obs;
113 obs[data.mock].apply(null, data.mockArgs);
114 spy.wait();
115 var errorDiag = getBrokenDialog();
116 var ok = getBrokenDialogOk();
117 mouseClick(ok, ok.width / 2, ok.height / 2);
118
119 // Halt testing until dialog has been destroyed.
120 tryCompareFunction(function() {
121 return getBrokenDialog();
122 }, null);
123 }
124
125 function test_noPasscode() {
126 fingerprintsInstance.passcodeSet = false;
127 compare(fingerprintsInstance.state, "noPasscode");
128
129 var setButton = findChild(fingerprintsInstance, "fingerprintSetPasscodeButton");
130 compare(setButton.visible, true);
131
132 var setupEntry = getSetupEntry();
133 compare(setupEntry.enabled, false);
134
135 var fingerprintsList = getFingerprintsList();
136 compare(fingerprintsList.enabled, false);
137 }
138
139 function test_noScanner() {
140 fingerprintsInstance.passcodeSet = true;
141 Biometryd.setAvailable(false);
142 compare(fingerprintsInstance.state, "noScanner");
143
144 var addItem = getAddFingerprintItem();
145 compare(addItem.enabled, false);
146
147 var removeButton = getRemoveAllButton();
148 compare(removeButton.enabled, false);
149
150 var fingerprintsList = getFingerprintsList();
151 compare(fingerprintsList.visible, false);
152 }
153
154 function test_passcode() {
155 fingerprintsInstance.passcodeSet = true;
156 compare(fingerprintsInstance.state, "");
157 var setButton = findChild(fingerprintsInstance, "fingerprintSetPasscodeButton");
158 compare(setButton.visible, false);
159 var setupEntry = getSetupEntry();
160 compare(setupEntry.enabled, true);
161 }
162
163 function test_changePasscode() {
164 fingerprintsInstance.passcodeSet = false;
165 var setButton = findChild(fingerprintsInstance, "fingerprintSetPasscodeButton");
166
167 spy.signalName = "requestPasscode"
168 spy.target = fingerprintsInstance;
169 mouseClick(setButton, setButton.width / 2, setButton.height / 2);
170 spy.wait();
171
172 compare(spy.count, 1);
173 }
174
175 function test_setup() {
176 fingerprintsInstance.passcodeSet = false;
177 var add = getAddFingerprintItem();
178 var remove = getRemoveAllButton();
179 compare(add.enabled, false);
180 compare(remove.enabled, false);
181 }
182
183 function test_noRemove() {
184 fingerprintsInstance.passcodeSet = true;
185 GSettingsController.setFingerprintNames({});
186 var remove = getRemoveAllButton();
187 compare(remove.enabled, false);
188 }
189
190 function test_remove() {
191 fingerprintsInstance.passcodeSet = true;
192 GSettingsController.setFingerprintNames({"tmplId": "A Finger"});
193
194 var remove = getRemoveAllButton();
195 mouseClick(remove, remove.width / 2, remove.height / 2);
196 var diag = findChild(testRoot, "fingerprintRemoveAllDialog");
197 var confirm = findChild(diag, "fingerprintRemoveAllConfirmationButton");
198 compare(confirm.visible, true);
199 mouseClick(confirm, confirm.width / 2, confirm.height / 2);
200
201 var obs = getClearanceObserver();
202 spy.signalName = "succeeded";
203 spy.target = obs;
204 obs.mockClearance("");
205 spy.wait();
206 compare(spy.count, 1);
207
208 // Wait for dialog destruction (which is required for other tests)
209 // to function.
210 tryCompareFunction(function() {
211 return findChild(testRoot, "fingerprintRemoveAllDialog");
212 }, null);
213 }
214
215 function test_enrollmentSucceeded() {
216 var obs = getEnrollmentObserver();
217 var targetFingerprintName = i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1);
218 spy.signalName = "succeeded";
219 spy.target = obs;
220 obs.mockEnroll("tmplId", "");
221 spy.wait();
222 compare(spy.count, 1);
223 compare(spy.signalArguments[0][0], "tmplId");
224
225 tryCompareFunction(function() {
226 return GSettingsController.fingerprintNames()["tmplId"];
227 }, targetFingerprintName);
228 }
229 }
230}
0231
=== added directory 'tests/qmltests/mocks'
=== added directory 'tests/qmltests/mocks/Biometryd'
=== added file 'tests/qmltests/mocks/Biometryd/CMakeLists.txt'
--- tests/qmltests/mocks/Biometryd/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/CMakeLists.txt 2016-06-15 10:46:42 +0000
@@ -0,0 +1,20 @@
1include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}
3)
4
5set(MOCK_BIOMETRYD_SOURCES
6 plugin.cpp
7 MockDevice.cpp
8 MockFingerprintReader.cpp
9 MockObserver.cpp
10 MockOperation.cpp
11 MockService.cpp
12 MockTemplateStore.cpp
13 MockUser.cpp
14)
15
16add_library(MockBiometryd MODULE ${MOCK_BIOMETRYD_SOURCES})
17
18qt5_use_modules(MockBiometryd Qml Quick Core)
19
20add_usc_mock(Biometryd 0.0 Biometryd TARGETS MockBiometryd)
021
=== added file 'tests/qmltests/mocks/Biometryd/MockDevice.cpp'
--- tests/qmltests/mocks/Biometryd/MockDevice.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockDevice.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockDevice.h"
18
19MockDevice::MockDevice(QObject *parent)
20 : QObject(parent)
21 , m_ts(new MockTemplateStore(this))
22{
23}
24
25MockTemplateStore* MockDevice::templateStore()
26{
27 return m_ts;
28}
29
30#include "MockDevice.moc"
031
=== added file 'tests/qmltests/mocks/Biometryd/MockDevice.h'
--- tests/qmltests/mocks/Biometryd/MockDevice.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockDevice.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_DEVICE_H
18#define MOCK_DEVICE_H
19
20#include <QObject>
21#include "MockTemplateStore.h"
22
23class MockDevice : public QObject
24{
25 Q_OBJECT
26 Q_DISABLE_COPY(MockDevice)
27
28public:
29 explicit MockDevice(QObject *parent = 0);
30 Q_PROPERTY(MockTemplateStore* templateStore READ templateStore CONSTANT)
31
32 MockTemplateStore* templateStore();
33
34private:
35 MockTemplateStore* m_ts;
36};
37
38#endif // MOCK_DEVICE_H
039
=== added file 'tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp'
--- tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockFingerprintReader.h"
18
19MockFingerprintReader::MockFingerprintReader(QObject *parent)
20 : QObject(parent)
21{
22}
23
24QString MockFingerprintReader::isFingerPresent() const
25{
26 return "isFingerPresent";
27}
28
29QString MockFingerprintReader::hasMainClusterIdentified() const
30{
31 return "hasMainClusterIdentified";
32}
33
34QString MockFingerprintReader::suggestedNextDirection() const
35{
36 return "suggestedNextDirection";
37}
38
39QString MockFingerprintReader::estimatedFingerSize() const
40{
41 return "estimatedFingerSize";
42}
43
44QString MockFingerprintReader::masks() const
45{
46 return "masks";
47}
48
49#include "MockFingerprintReader.moc"
050
=== added file 'tests/qmltests/mocks/Biometryd/MockFingerprintReader.h'
--- tests/qmltests/mocks/Biometryd/MockFingerprintReader.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockFingerprintReader.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_FINGERPRINTREADER_H
18#define MOCK_FINGERPRINTREADER_H
19
20#include <QObject>
21#include <QString>
22#include <QVariant>
23#include <QList>
24#include <QRect>
25
26class MockFingerprintReader : public QObject
27
28{
29 Q_OBJECT
30 Q_DISABLE_COPY(MockFingerprintReader)
31 Q_ENUMS(Direction)
32 Q_PROPERTY(QString isFingerPresent READ isFingerPresent)
33 Q_PROPERTY(QString hasMainClusterIdentified READ hasMainClusterIdentified)
34 Q_PROPERTY(QString suggestedNextDirection READ suggestedNextDirection)
35 Q_PROPERTY(QString masks READ masks)
36
37public:
38 explicit MockFingerprintReader(QObject *parent = 0);
39
40 enum class Direction
41 {
42 NotAvailable,
43 SouthWest,
44 South,
45 SouthEast,
46 NorthWest,
47 North,
48 NorthEast,
49 East,
50 West
51 };
52
53 Q_INVOKABLE QString isFingerPresent() const;
54 Q_INVOKABLE QString hasMainClusterIdentified() const;
55 Q_INVOKABLE QString suggestedNextDirection() const;
56 Q_INVOKABLE QString estimatedFingerSize() const;
57 Q_INVOKABLE QString masks() const;
58
59
60Q_SIGNALS:
61 void succeeded(const QVariant &result);
62 void failed(const QString &reason);
63};
64
65#endif // MOCK_FINGERPRINTREADER_H
066
=== added file 'tests/qmltests/mocks/Biometryd/MockObserver.cpp'
--- tests/qmltests/mocks/Biometryd/MockObserver.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockObserver.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockObserver.h"
18
19class Result : public QObject
20{
21 Q_OBJECT
22 Q_PROPERTY(unsigned int uid READ uid CONSTANT)
23
24public:
25 explicit Result(unsigned int uid, QObject *parent = 0)
26 : QObject(parent), m_uid(uid)
27 {}
28
29 unsigned int uid() const { return m_uid; }
30
31private:
32 unsigned int m_uid;
33};
34
35MockObserver::MockObserver(QObject *parent)
36 : QObject(parent)
37{
38}
39
40void MockObserver::mockSize(int size, const QString &error)
41{
42 if (error.isEmpty())
43 Q_EMIT succeeded(QVariant::fromValue(size));
44 else
45 Q_EMIT failed(error);
46}
47
48void MockObserver::mockEnroll(const QString &templateId, const QString &error)
49{
50 if (error.isEmpty())
51 Q_EMIT succeeded(templateId);
52 else
53 Q_EMIT failed(error);
54}
55
56void MockObserver::mockEnrollProgress(double percent,
57 const QVariantMap& details)
58{
59 Q_EMIT progressed(percent, details);
60}
61
62void MockObserver::mockClearance(const QString &error)
63{
64 if (error.isEmpty())
65 Q_EMIT succeeded(QVariant());
66 else
67 Q_EMIT failed(error);
68}
69
70void MockObserver::mockRemoval(const QString &templateId,
71 const QString &error)
72{
73 if (error.isEmpty())
74 Q_EMIT succeeded(templateId);
75 else
76 Q_EMIT failed(error);
77}
78
79void MockObserver::mockList(const QStringList &templateIds,
80 const QString &error)
81{
82 if (error.isEmpty())
83 Q_EMIT succeeded(templateIds);
84 else
85 Q_EMIT failed(error);
86}
87
88#include "MockObserver.moc"
089
=== added file 'tests/qmltests/mocks/Biometryd/MockObserver.h'
--- tests/qmltests/mocks/Biometryd/MockObserver.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockObserver.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_OBSERVER_H
18#define MOCK_OBSERVER_H
19
20#include <QObject>
21#include <QString>
22#include <QVariant>
23
24class MockObserver : public QObject
25{
26 Q_OBJECT
27 Q_DISABLE_COPY(MockObserver)
28
29public:
30 explicit MockObserver(QObject *parent = 0);
31
32 Q_INVOKABLE void mockSize(int size, const QString &error); // only in mock
33 Q_INVOKABLE void mockEnroll(const QString &templateId,
34 const QString &error); // only in mock
35 Q_INVOKABLE void mockEnrollProgress(double percent,
36 const QVariantMap& details); // only in mock
37 Q_INVOKABLE void mockClearance(const QString &error); // only in mock
38 Q_INVOKABLE void mockRemoval(const QString &templateId,
39 const QString &error); // only in mock
40 Q_INVOKABLE void mockList(const QStringList &templateIds,
41 const QString &error); // only in mock
42
43
44Q_SIGNALS:
45 void progressed(double percent, const QVariantMap& details);
46 void succeeded(const QVariant &result);
47 void failed(const QString &reason);
48 void canceled(const QString& reason);
49 void started();
50};
51
52#endif // MOCK_OBSERVER_H
053
=== added file 'tests/qmltests/mocks/Biometryd/MockOperation.cpp'
--- tests/qmltests/mocks/Biometryd/MockOperation.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockOperation.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockOperation.h"
18
19MockOperation::MockOperation(QObject *parent) : QObject(parent)
20{
21}
22
23bool MockOperation::start(MockObserver *observer)
24{
25 Q_UNUSED(observer);
26 return true;
27}
28
29bool MockOperation::cancel()
30{
31 return true;
32}
33
34#include "MockOperation.moc"
035
=== added file 'tests/qmltests/mocks/Biometryd/MockOperation.h'
--- tests/qmltests/mocks/Biometryd/MockOperation.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockOperation.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_OPERATION_H
18#define MOCK_OPERATION_H
19
20#include <QObject>
21
22class MockObserver;
23
24class MockOperation : public QObject
25{
26 Q_OBJECT
27 Q_DISABLE_COPY(MockOperation)
28
29public:
30 explicit MockOperation(QObject *parent = 0);
31
32 Q_INVOKABLE bool start(MockObserver* observer);
33 Q_INVOKABLE bool cancel();
34};
35
36#endif // MOCK_OPERATION_H
037
=== added file 'tests/qmltests/mocks/Biometryd/MockService.cpp'
--- tests/qmltests/mocks/Biometryd/MockService.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockService.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockService.h"
18
19MockService::MockService(QObject *parent)
20 : QObject(parent)
21 , m_device(new MockDevice(this))
22 , m_available(false)
23{
24}
25
26MockDevice* MockService::defaultDevice()
27{
28 return m_device;
29}
30
31bool MockService::isAvailable() const
32{
33 return m_available;
34}
35
36void MockService::setAvailable(const bool available)
37{
38 m_available = available;
39 Q_EMIT (availableChanged(available));
40}
41
42#include "MockService.moc"
043
=== added file 'tests/qmltests/mocks/Biometryd/MockService.h'
--- tests/qmltests/mocks/Biometryd/MockService.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockService.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_SERVICE_H
18#define MOCK_SERVICE_H
19
20#include <QObject>
21
22#include "MockDevice.h"
23
24class MockService : public QObject
25{
26 Q_OBJECT
27 Q_DISABLE_COPY(MockService)
28
29public:
30 explicit MockService(QObject *parent = 0);
31 Q_PROPERTY(MockDevice* defaultDevice READ defaultDevice CONSTANT)
32 Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged)
33
34 MockDevice* defaultDevice();
35 bool isAvailable() const;
36 Q_INVOKABLE void setAvailable(const bool available); // mock only
37
38Q_SIGNALS:
39 void availableChanged(bool);
40
41private:
42 MockDevice* m_device;
43 bool m_available;
44};
45
46#endif // MOCK_SERVICE_H
047
=== added file 'tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp'
--- tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockTemplateStore.h"
18
19MockTemplateStore::MockTemplateStore(QObject *parent)
20{
21 Q_UNUSED(parent);
22}
23
24MockSizeQuery* MockTemplateStore::size(MockUser* user)
25{
26 Q_UNUSED(user);
27 return new MockSizeQuery(this);
28}
29
30MockEnrollment* MockTemplateStore::enroll(MockUser* user)
31{
32 Q_UNUSED(user);
33 return new MockEnrollment(this);
34}
35
36MockClearance* MockTemplateStore::clear(MockUser* user)
37{
38 Q_UNUSED(user);
39 return new MockClearance(this);
40}
41
42MockRemoval* MockTemplateStore::remove(MockUser* user,
43 const QString &templateId)
44{
45 Q_UNUSED(user);
46 Q_UNUSED(templateId);
47 return new MockRemoval(this);
48}
49
50MockList* MockTemplateStore::list(MockUser* user)
51{
52 Q_UNUSED(user);
53 return new MockList(this);
54}
55
56#include "MockTemplateStore.moc"
057
=== added file 'tests/qmltests/mocks/Biometryd/MockTemplateStore.h'
--- tests/qmltests/mocks/Biometryd/MockTemplateStore.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockTemplateStore.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_TEMPLATESTORE_H
18#define MOCK_TEMPLATESTORE_H
19
20#include <QObject>
21#include "MockOperation.h"
22
23class MockUser;
24
25class MockSizeQuery : public MockOperation
26{
27 Q_OBJECT
28public:
29 MockSizeQuery(QObject *parent) : MockOperation(parent)
30 {
31 }
32};
33
34class MockEnrollment : public MockOperation
35{
36 Q_OBJECT
37public:
38 MockEnrollment(QObject *parent) : MockOperation(parent)
39 {
40 }
41};
42
43class MockClearance : public MockOperation
44{
45 Q_OBJECT
46public:
47 MockClearance(QObject *parent) : MockOperation(parent)
48 {
49 }
50};
51
52class MockRemoval : public MockOperation
53{
54 Q_OBJECT
55public:
56 MockRemoval(QObject *parent) : MockOperation(parent)
57 {
58 }
59};
60
61class MockList : public MockOperation
62{
63 Q_OBJECT
64public:
65 MockList(QObject *parent) : MockOperation(parent)
66 {
67 }
68};
69
70class MockTemplateStore : public QObject
71{
72 Q_OBJECT
73 Q_DISABLE_COPY(MockTemplateStore)
74
75public:
76 explicit MockTemplateStore(QObject *parent = 0);
77
78 Q_INVOKABLE MockSizeQuery* size(MockUser* user);
79 Q_INVOKABLE MockEnrollment* enroll(MockUser* user);
80 Q_INVOKABLE MockClearance* clear(MockUser* user);
81 Q_INVOKABLE MockRemoval* remove(MockUser* user,
82 const QString &templateId);
83 Q_INVOKABLE MockList* list(MockUser* user);
84};
85
86#endif // MOCK_TEMPLATESTORE_H
087
=== added file 'tests/qmltests/mocks/Biometryd/MockUser.cpp'
--- tests/qmltests/mocks/Biometryd/MockUser.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockUser.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockUser.h"
18
19MockUser::MockUser(QObject *parent) : QObject(parent)
20{
21}
22
23int MockUser::uid() const
24{
25 return m_uid;
26}
27
28void MockUser::setUid(const int &uid)
29{
30 m_uid = uid;
31}
32
33#include "MockUser.moc"
034
=== added file 'tests/qmltests/mocks/Biometryd/MockUser.h'
--- tests/qmltests/mocks/Biometryd/MockUser.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/MockUser.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_USER_H
18#define MOCK_USER_H
19
20#include <QObject>
21
22class MockUser : public QObject
23{
24 Q_OBJECT
25 Q_DISABLE_COPY(MockUser)
26
27public:
28 explicit MockUser(QObject *parent = 0);
29 Q_PROPERTY(int uid READ uid WRITE setUid)
30
31 int uid() const;
32 void setUid(const int &uid);
33
34private:
35 int m_uid = 0;
36};
37
38#endif // MOCK_USER_H
039
=== added file 'tests/qmltests/mocks/Biometryd/plugin.cpp'
--- tests/qmltests/mocks/Biometryd/plugin.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/plugin.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "plugin.h"
18
19#include "MockDevice.h"
20#include "MockFingerprintReader.h"
21#include "MockObserver.h"
22#include "MockOperation.h"
23#include "MockService.h"
24#include "MockTemplateStore.h"
25#include "MockUser.h"
26
27#include <QtQml>
28
29void BackendPlugin::registerTypes(const char *uri)
30{
31 Q_ASSERT(uri == QLatin1String("Biometryd"));
32
33 qmlRegisterType<MockObserver>(uri, 0, 0, "Observer");
34 qmlRegisterType<MockUser>(uri, 0, 0, "User");
35
36 qmlRegisterUncreatableType<MockDevice>(uri, 0, 0, "Device", "Rely on Biometryd.instance");
37
38 qmlRegisterUncreatableType<MockOperation>(uri, 0, 0, "Operation", "Rely on Biometryd.instance");
39 qmlRegisterUncreatableType<MockSizeQuery>(uri, 0, 0, "SizeQuery", "Rely on Biometryd.instance");
40 qmlRegisterUncreatableType<MockEnrollment>(uri, 0, 0, "Enrollment", "Rely on Biometryd.instance");
41 qmlRegisterUncreatableType<MockClearance>(uri, 0, 0, "Clearance", "Rely on Biometryd.instance");
42 qmlRegisterUncreatableType<MockTemplateStore>(uri, 0, 0, "TemplateStore", "Rely on Biometryd.instance");
43 qmlRegisterUncreatableType<MockRemoval>(uri, 0, 0, "Removal", "Rely on Biometryd.instance");
44 qmlRegisterUncreatableType<MockList>(uri, 0, 0, "List", "Rely on Biometryd.instance");
45
46 qmlRegisterSingletonType<MockService>(
47 uri, 0, 0, "Biometryd",
48 [](QQmlEngine*, QJSEngine*) -> QObject*
49 {
50 return new MockService;
51 }
52 );
53 qmlRegisterSingletonType<MockFingerprintReader>(
54 uri, 0, 0, "FingerprintReader",
55 [](QQmlEngine*, QJSEngine*) -> QObject*
56 {
57 return new MockFingerprintReader;
58 }
59 );
60}
061
=== added file 'tests/qmltests/mocks/Biometryd/plugin.h'
--- tests/qmltests/mocks/Biometryd/plugin.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/plugin.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_BIOMETRYD_PLUGIN_H
18#define MOCK_BIOMETRYD_PLUGIN_H
19
20#include <QQmlExtensionPlugin>
21
22class BackendPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26
27public:
28 void registerTypes(const char *uri) override;
29};
30
31#endif // MOCK_BIOMETRYD_PLUGIN_H
032
=== added file 'tests/qmltests/mocks/Biometryd/qmldir'
--- tests/qmltests/mocks/Biometryd/qmldir 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/Biometryd/qmldir 2016-06-15 10:46:42 +0000
@@ -0,0 +1,2 @@
1module Biometryd
2plugin MockBiometryd
03
=== added file 'tests/qmltests/mocks/CMakeLists.txt'
--- tests/qmltests/mocks/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/CMakeLists.txt 2016-06-15 10:46:42 +0000
@@ -0,0 +1,32 @@
1include(QmlPlugins)
2
3# Set up and optionally install a mock plugin for ubuntu-settings-components.
4#
5# add_usc_mock(plugin version path
6# [PREFIX string] # Install the plugin to the specified prefix under unity8 private plugin directory
7# [...] # See export_qmlfiles and export_qmlplugin documentation for more options
8# )
9
10macro(add_usc_mock PLUGIN VERSION PATH)
11 set(single PREFIX)
12 cmake_parse_arguments(MOCK "" "${single}" "" ${ARGN})
13
14 if(MOCK_PREFIX)
15 export_qmlfiles(${PLUGIN} ${PATH}
16 DESTINATION ${SHELL_INSTALL_QML}/${MOCK_PREFIX}
17 TARGET_PREFIX ${MOCK_PREFIX}-Mock
18 ${MOCK_UNPARSED_ARGUMENTS}
19 )
20 export_qmlplugin(${PLUGIN} ${VERSION} ${PATH}
21 DESTINATION ${SHELL_INSTALL_QML}/${MOCK_PREFIX}
22 TARGET_PREFIX ${MOCK_PREFIX}-Mock
23 ${MOCK_UNPARSED_ARGUMENTS}
24 )
25 else()
26 export_qmlfiles(${PLUGIN} ${PATH} TARGET_PREFIX Mock ${MOCK_UNPARSED_ARGUMENTS})
27 export_qmlplugin(${PLUGIN} ${VERSION} ${PATH} TARGET_PREFIX Mock ${MOCK_UNPARSED_ARGUMENTS})
28 endif()
29endmacro()
30
31add_subdirectory(Biometryd)
32add_subdirectory(GSettings.1.0)
033
=== added directory 'tests/qmltests/mocks/GSettings.1.0'
=== added file 'tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt'
--- tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt 2016-06-15 10:46:42 +0000
@@ -0,0 +1,20 @@
1include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${Qt5Core_INCLUDE_DIRS}
4 ${Qt5Quick_INCLUDE_DIRS}
5)
6
7set(GSettingsQML_SOURCES
8 fake_gsettings.cpp
9 plugin.cpp
10)
11
12add_library(FakeGSettingsQml MODULE ${GSettingsQML_SOURCES})
13target_link_libraries(FakeGSettingsQml
14 ${Qt5Core_LIBRARIES}
15 ${Qt5Quick_LIBRARIES}
16)
17
18qt5_use_modules(FakeGSettingsQml Qml)
19
20add_usc_mock(GSettings 1.0 GSettings.1.0 TARGETS FakeGSettingsQml)
021
=== added file 'tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp'
--- tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,124 @@
1/*
2 * Copyright 2013 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
17#include "fake_gsettings.h"
18
19#include <QDebug>
20
21GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0;
22
23GSettingsControllerQml::GSettingsControllerQml()
24 : m_fingerprintNames()
25{
26}
27
28GSettingsControllerQml::~GSettingsControllerQml() {
29 s_controllerInstance = 0;
30}
31
32GSettingsControllerQml* GSettingsControllerQml::instance() {
33 if (!s_controllerInstance) {
34 s_controllerInstance = new GSettingsControllerQml();
35 }
36 return s_controllerInstance;
37}
38
39QVariantMap GSettingsControllerQml::fingerprintNames() const
40{
41 return m_fingerprintNames;
42}
43
44void GSettingsControllerQml::setFingerprintNames(QVariantMap map)
45{
46 if (map != m_fingerprintNames) {
47 m_fingerprintNames = map;
48 Q_EMIT fingerprintNamesChanged();
49 }
50}
51
52GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) {
53}
54
55QByteArray GSettingsSchemaQml::id() const {
56 return m_id;
57}
58
59void GSettingsSchemaQml::setId(const QByteArray &id) {
60 if (!m_id.isEmpty()) {
61 qWarning("GSettings.schema.id may only be set on construction");
62 return;
63 }
64
65 m_id = id;
66}
67
68QByteArray GSettingsSchemaQml::path() const {
69 return m_path;
70}
71
72void GSettingsSchemaQml::setPath(const QByteArray &path) {
73 if (!m_path.isEmpty()) {
74 qWarning("GSettings.schema.path may only be set on construction");
75 return;
76 }
77
78 m_path = path;
79}
80
81GSettingsQml::GSettingsQml(QObject *parent)
82 : QObject(parent),
83 m_valid(false)
84{
85 m_schema = new GSettingsSchemaQml(this);
86}
87
88void GSettingsQml::classBegin()
89{
90}
91
92void GSettingsQml::componentComplete()
93{
94 // Emulate what the real GSettings module does, and only return undefined
95 // values until we are completed loading.
96 m_valid = true;
97
98 // FIXME: We should make this dynamic, instead of hard-coding all possible
99 // properties in one object. We should create properties based on the schema.
100 connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::fingerprintNamesChanged,
101 this, &GSettingsQml::fingerprintNamesChanged);
102
103 Q_EMIT fingerprintNamesChanged();
104}
105
106GSettingsSchemaQml * GSettingsQml::schema() const {
107 return m_schema;
108}
109
110QVariantMap GSettingsQml::fingerprintNames() const
111{
112 if (m_valid && m_schema->id() == "com.ubuntu.touch.system") {
113 return GSettingsControllerQml::instance()->fingerprintNames();
114 } else {
115 return QVariantMap();
116 }
117}
118
119void GSettingsQml::setFingerprintNames(const QVariantMap &map)
120{
121 if (m_valid && m_schema->id() == "com.ubuntu.touch.system") {
122 GSettingsControllerQml::instance()->setFingerprintNames(map);
123 }
124}
0125
=== added file 'tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h'
--- tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,101 @@
1/*
2 * Copyright 2013 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
17#ifndef FAKE_GSETTINGS_H
18#define FAKE_GSETTINGS_H
19
20#include <QList>
21#include <QObject>
22#include <QQmlParserStatus>
23#include <QStringList>
24#include <QVariant>
25
26class GSettingsSchemaQml: public QObject
27{
28 Q_OBJECT
29
30 Q_PROPERTY(QByteArray id READ id WRITE setId)
31public:
32 GSettingsSchemaQml(QObject *parent = nullptr);
33
34 QByteArray id() const;
35 void setId(const QByteArray &id);
36
37 QByteArray path() const;
38 void setPath(const QByteArray &path);
39
40private:
41 QByteArray m_id;
42 QByteArray m_path;
43};
44
45class GSettingsQml: public QObject, public QQmlParserStatus
46{
47 Q_OBJECT
48 Q_INTERFACES(QQmlParserStatus)
49
50 Q_PROPERTY(GSettingsSchemaQml* schema READ schema NOTIFY schemaChanged)
51 Q_PROPERTY(QVariantMap fingerprintNames
52 READ fingerprintNames
53 WRITE setFingerprintNames
54 NOTIFY fingerprintNamesChanged)
55
56public:
57 GSettingsQml(QObject *parent = nullptr);
58
59 void classBegin() override;
60 void componentComplete() override;
61
62 GSettingsSchemaQml * schema() const;
63
64 QVariantMap fingerprintNames() const;
65 void setFingerprintNames(const QVariantMap &map);
66
67Q_SIGNALS:
68 void fingerprintNamesChanged();
69 void schemaChanged();
70
71private:
72 GSettingsSchemaQml* m_schema;
73 bool m_valid;
74
75 friend class GSettingsSchemaQml;
76};
77
78class GSettingsControllerQml: public QObject
79{
80 Q_OBJECT
81
82public:
83 static GSettingsControllerQml* instance();
84 ~GSettingsControllerQml();
85
86 Q_INVOKABLE QVariantMap fingerprintNames() const;
87 Q_INVOKABLE void setFingerprintNames(QVariantMap map);
88
89Q_SIGNALS:
90 void fingerprintNamesChanged();
91
92private:
93 GSettingsControllerQml();
94
95 QVariantMap m_fingerprintNames;
96
97 static GSettingsControllerQml* s_controllerInstance;
98 QList<GSettingsQml *> m_registeredGSettings;
99};
100
101#endif // FAKE_GSETTINGS_H
0102
=== added file 'tests/qmltests/mocks/GSettings.1.0/plugin.cpp'
--- tests/qmltests/mocks/GSettings.1.0/plugin.cpp 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/GSettings.1.0/plugin.cpp 2016-06-15 10:46:42 +0000
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "plugin.h"
18#include "fake_gsettings.h"
19
20#include <QtQml/qqml.h>
21
22static QObject* controllerProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
23{
24 return GSettingsControllerQml::instance();
25}
26
27void FakeGSettingsQmlPlugin::registerTypes(const char *uri)
28{
29 qmlRegisterSingletonType<GSettingsControllerQml>(uri, 1, 0, "GSettingsController", controllerProvider);
30 qmlRegisterType<GSettingsQml>(uri, 1, 0, "GSettings");
31 qmlRegisterUncreatableType<GSettingsSchemaQml>(uri, 1, 0, "GSettingsSchema",
32 "GSettingsSchema can only be used inside of a GSettings component");
33}
034
=== added file 'tests/qmltests/mocks/GSettings.1.0/plugin.h'
--- tests/qmltests/mocks/GSettings.1.0/plugin.h 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/GSettings.1.0/plugin.h 2016-06-15 10:46:42 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef PLUGIN_H
18#define PLUGIN_H
19
20#include <QtQml/QQmlExtensionPlugin>
21
22class FakeGSettingsQmlPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26
27public:
28 void registerTypes(const char *uri) override;
29};
30
31#endif // PLUGIN_H
032
=== added file 'tests/qmltests/mocks/GSettings.1.0/qmldir'
--- tests/qmltests/mocks/GSettings.1.0/qmldir 1970-01-01 00:00:00 +0000
+++ tests/qmltests/mocks/GSettings.1.0/qmldir 2016-06-15 10:46:42 +0000
@@ -0,0 +1,2 @@
1module GSettings
2plugin FakeGSettingsQml

Subscribers

People subscribed via source and target branches

to all changes: