Merge lp:~jonas-drange/ubuntu-settings-components/fingerprint into lp:~registry/ubuntu-settings-components/trunk
- fingerprint
- Merge into trunk
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 |
Related bugs: |
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:/
- 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
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
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
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2016-03-01 15:37:36 +0000 | |||
3 | +++ debian/control 2016-06-15 10:46:42 +0000 | |||
4 | @@ -27,7 +27,10 @@ | |||
5 | 27 | Architecture: any | 27 | Architecture: any |
6 | 28 | Multi-Arch: same | 28 | Multi-Arch: same |
7 | 29 | Pre-Depends: dpkg (>= 1.15.6~) | 29 | Pre-Depends: dpkg (>= 1.15.6~) |
9 | 30 | Depends: qml-module-qtquick-layouts, | 30 | Depends: gsettings-ubuntu-schemas (>= 0.0.7), |
10 | 31 | qml-module-biometryd, | ||
11 | 32 | qml-module-qtquick-layouts, | ||
12 | 33 | qtdeclarative5-gsettings1.0 (>=0.1+14.10.20140801.1), | ||
13 | 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), |
14 | 32 | suru-icon-theme, | 35 | suru-icon-theme, |
15 | 33 | ${misc:Depends}, | 36 | ${misc:Depends}, |
16 | @@ -35,4 +38,4 @@ | |||
17 | 35 | Breaks: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3), | 38 | Breaks: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3), |
18 | 36 | Replaces: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3), | 39 | Replaces: qtdeclarative5-ubuntu-settings-components-assets (<< 0.3), |
19 | 37 | Description: Ubuntu Settings Components | 40 | Description: Ubuntu Settings Components |
20 | 38 | Ubuntu settings components for Unity | ||
21 | 39 | \ No newline at end of file | 41 | \ No newline at end of file |
22 | 42 | Ubuntu settings components for Unity | ||
23 | 40 | 43 | ||
24 | === added file 'examples/Fingerprint.qml' | |||
25 | --- examples/Fingerprint.qml 1970-01-01 00:00:00 +0000 | |||
26 | +++ examples/Fingerprint.qml 2016-06-15 10:46:42 +0000 | |||
27 | @@ -0,0 +1,43 @@ | |||
28 | 1 | /* | ||
29 | 2 | * Copyright 2016 Canonical Ltd. | ||
30 | 3 | * | ||
31 | 4 | * This program is free software; you can redistribute it and/or modify | ||
32 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
33 | 6 | * the Free Software Foundation; version 3. | ||
34 | 7 | * | ||
35 | 8 | * This program is distributed in the hope that it will be useful, | ||
36 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
37 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
38 | 11 | * GNU Lesser General Public License for more details. | ||
39 | 12 | * | ||
40 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
41 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
42 | 15 | * | ||
43 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
44 | 17 | */ | ||
45 | 18 | |||
46 | 19 | import QtQuick 2.4 | ||
47 | 20 | import QtQuick.Layouts 1.2 | ||
48 | 21 | import Ubuntu.Components 1.3 | ||
49 | 22 | import Ubuntu.Components.Popups 1.3 | ||
50 | 23 | import Ubuntu.Components.ListItems 1.3 as ListItems | ||
51 | 24 | import Ubuntu.Settings.Components 0.1 | ||
52 | 25 | import Ubuntu.Settings.Fingerprint 0.1 | ||
53 | 26 | |||
54 | 27 | MainView { | ||
55 | 28 | width: units.gu(50) | ||
56 | 29 | height: units.gu(90) | ||
57 | 30 | |||
58 | 31 | PageStack { | ||
59 | 32 | id: pageStack | ||
60 | 33 | |||
61 | 34 | Component.onCompleted: push(fingerprintPage) | ||
62 | 35 | |||
63 | 36 | Component { | ||
64 | 37 | id: fingerprintPage | ||
65 | 38 | Fingerprints { | ||
66 | 39 | onRequestPasscode: passcodeSet = !passcodeSet | ||
67 | 40 | } | ||
68 | 41 | } | ||
69 | 42 | } | ||
70 | 43 | } | ||
71 | 0 | 44 | ||
72 | === modified file 'plugins/Ubuntu/Settings/CMakeLists.txt' | |||
73 | --- plugins/Ubuntu/Settings/CMakeLists.txt 2016-02-05 23:42:02 +0000 | |||
74 | +++ plugins/Ubuntu/Settings/CMakeLists.txt 2016-06-15 10:46:42 +0000 | |||
75 | @@ -1,3 +1,4 @@ | |||
76 | 1 | add_subdirectory(Components) | 1 | add_subdirectory(Components) |
77 | 2 | add_subdirectory(Fingerprint) | ||
78 | 2 | add_subdirectory(Menus) | 3 | add_subdirectory(Menus) |
79 | 3 | add_subdirectory(Vpn) | 4 | add_subdirectory(Vpn) |
80 | 4 | 5 | ||
81 | === added directory 'plugins/Ubuntu/Settings/Fingerprint' | |||
82 | === added file 'plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt' | |||
83 | --- plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
84 | +++ plugins/Ubuntu/Settings/Fingerprint/CMakeLists.txt 2016-06-15 10:46:42 +0000 | |||
85 | @@ -0,0 +1,15 @@ | |||
86 | 1 | project(UbuntuSettingsFingerprintQml) | ||
87 | 2 | |||
88 | 3 | include_directories( | ||
89 | 4 | ${CMAKE_CURRENT_SOURCE_DIR} | ||
90 | 5 | ${CMAKE_CURRENT_BINARY_DIR} | ||
91 | 6 | ) | ||
92 | 7 | add_definitions(-DUBUNTUSETTINGSFINGERPRINT_LIBRARY) | ||
93 | 8 | QT5_ADD_RESOURCES(assets assets.qrc) | ||
94 | 9 | add_library(UbuntuSettingsFingerprintQml MODULE | ||
95 | 10 | plugin.cpp | ||
96 | 11 | ubuntusettingsfingerprint.cpp | ||
97 | 12 | ${assets} | ||
98 | 13 | ) | ||
99 | 14 | qt5_use_modules(UbuntuSettingsFingerprintQml Core Qml Quick) | ||
100 | 15 | add_usc_plugin(Ubuntu.Settings.Fingerprint 0.1 Ubuntu/Settings/Fingerprint TARGETS UbuntuSettingsFingerprintQml) | ||
101 | 0 | 16 | ||
102 | === added file 'plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml' | |||
103 | --- plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml 1970-01-01 00:00:00 +0000 | |||
104 | +++ plugins/Ubuntu/Settings/Fingerprint/CircularSegment.qml 2016-06-15 10:46:42 +0000 | |||
105 | @@ -0,0 +1,64 @@ | |||
106 | 1 | /* | ||
107 | 2 | * Copyright 2016 Canonical Ltd. | ||
108 | 3 | * | ||
109 | 4 | * This program is free software; you can redistribute it and/or modify | ||
110 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
111 | 6 | * the Free Software Foundation; version 3. | ||
112 | 7 | * | ||
113 | 8 | * This program is distributed in the hope that it will be useful, | ||
114 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
115 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
116 | 11 | * GNU Lesser General Public License for more details. | ||
117 | 12 | * | ||
118 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
119 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
120 | 15 | * | ||
121 | 16 | * Authored by Florian Boucault <florian.boucault@canonical.com> | ||
122 | 17 | */ | ||
123 | 18 | |||
124 | 19 | import QtQuick 2.4 | ||
125 | 20 | import Ubuntu.Components 1.3 | ||
126 | 21 | |||
127 | 22 | ShaderEffect { | ||
128 | 23 | implicitWidth: units.gu(20) | ||
129 | 24 | implicitHeight: units.gu(20) | ||
130 | 25 | height: width | ||
131 | 26 | |||
132 | 27 | property color color: "#3EB34F" | ||
133 | 28 | property real thickness: units.dp(3) | ||
134 | 29 | property real angleStop: 90 | ||
135 | 30 | |||
136 | 31 | property real _texturePixel: 1/width | ||
137 | 32 | property real _thicknessTex: thickness/width | ||
138 | 33 | property real _angleStopRadians: angleStop * (Math.PI / 180) | ||
139 | 34 | |||
140 | 35 | fragmentShader: " | ||
141 | 36 | varying mediump vec2 qt_TexCoord0; | ||
142 | 37 | uniform lowp float qt_Opacity; | ||
143 | 38 | uniform lowp vec4 color; | ||
144 | 39 | uniform lowp float _texturePixel; | ||
145 | 40 | uniform lowp float _thicknessTex; | ||
146 | 41 | uniform lowp float _angleStopRadians; | ||
147 | 42 | |||
148 | 43 | void main() { | ||
149 | 44 | mediump vec2 center = vec2(0.5); | ||
150 | 45 | mediump float circleX = (qt_TexCoord0.x - center.x); | ||
151 | 46 | mediump float circleY = (qt_TexCoord0.y - center.y); | ||
152 | 47 | mediump float distanceToCenter = circleX*circleX + circleY*circleY; | ||
153 | 48 | const mediump float PI = 3.1415926535897932384626433832795; | ||
154 | 49 | mediump float angle = atan(-circleX, circleY) + PI; | ||
155 | 50 | |||
156 | 51 | mediump float radius = 0.5; | ||
157 | 52 | mediump float radiusSquare = radius * radius; | ||
158 | 53 | mediump float radiusInner = radius - _thicknessTex; | ||
159 | 54 | mediump float radiusInnerSquare = radiusInner * radiusInner; | ||
160 | 55 | |||
161 | 56 | lowp vec4 fillColor = mix(vec4(0), | ||
162 | 57 | mix(color, vec4(0), smoothstep(distanceToCenter-_texturePixel, distanceToCenter+_texturePixel, radiusInnerSquare)), | ||
163 | 58 | smoothstep(distanceToCenter-_texturePixel, distanceToCenter+_texturePixel, radiusSquare)); | ||
164 | 59 | fillColor = mix(fillColor, vec4(0), step(_angleStopRadians, angle)); | ||
165 | 60 | gl_FragColor = fillColor * qt_Opacity; | ||
166 | 61 | } | ||
167 | 62 | " | ||
168 | 63 | } | ||
169 | 64 | |||
170 | 0 | 65 | ||
171 | === added file 'plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml' | |||
172 | --- plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml 1970-01-01 00:00:00 +0000 | |||
173 | +++ plugins/Ubuntu/Settings/Fingerprint/DirectionVisual.qml 2016-06-15 10:46:42 +0000 | |||
174 | @@ -0,0 +1,103 @@ | |||
175 | 1 | /* | ||
176 | 2 | * Copyright 2016 Canonical Ltd. | ||
177 | 3 | * | ||
178 | 4 | * This program is free software; you can redistribute it and/or modify | ||
179 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
180 | 6 | * the Free Software Foundation; version 3. | ||
181 | 7 | * | ||
182 | 8 | * This program is distributed in the hope that it will be useful, | ||
183 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
184 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
185 | 11 | * GNU Lesser General Public License for more details. | ||
186 | 12 | * | ||
187 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
188 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
189 | 15 | * | ||
190 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
191 | 17 | */ | ||
192 | 18 | |||
193 | 19 | import Biometryd 0.0 | ||
194 | 20 | import QtQuick 2.4 | ||
195 | 21 | import Ubuntu.Components 1.3 | ||
196 | 22 | import Ubuntu.Settings.Fingerprint 0.1 | ||
197 | 23 | |||
198 | 24 | Item { | ||
199 | 25 | property int direction: FingerprintReader.NotAvailable | ||
200 | 26 | opacity: direction !== FingerprintReader.NotAvailable ? 1 : 0 | ||
201 | 27 | Behavior on opacity { UbuntuNumberAnimation {} } | ||
202 | 28 | |||
203 | 29 | UbuntuNumberAnimation { | ||
204 | 30 | id: rotationAnimation | ||
205 | 31 | alwaysRunToEnd: true | ||
206 | 32 | |||
207 | 33 | target: directionContainer | ||
208 | 34 | property: "rotation" | ||
209 | 35 | |||
210 | 36 | function normalizeAngle(v) { | ||
211 | 37 | if (v < 0) | ||
212 | 38 | return 360 + v; | ||
213 | 39 | else | ||
214 | 40 | return v % 360; | ||
215 | 41 | } | ||
216 | 42 | |||
217 | 43 | onStopped: { | ||
218 | 44 | directionContainer.rotation = normalizeAngle(directionContainer.rotation); | ||
219 | 45 | } | ||
220 | 46 | } | ||
221 | 47 | |||
222 | 48 | onDirectionChanged: { | ||
223 | 49 | var v1 = rotation; | ||
224 | 50 | var v2; | ||
225 | 51 | var length; | ||
226 | 52 | |||
227 | 53 | switch (direction) { | ||
228 | 54 | case FingerprintReader.North: | ||
229 | 55 | v2 = 0; break; | ||
230 | 56 | case FingerprintReader.NorthEast: | ||
231 | 57 | v2 = 45; break; | ||
232 | 58 | case FingerprintReader.East: | ||
233 | 59 | v2 = 90; break; | ||
234 | 60 | case FingerprintReader.SouthEast: | ||
235 | 61 | v2 = 135; break; | ||
236 | 62 | case FingerprintReader.South: | ||
237 | 63 | v2 = 180; break; | ||
238 | 64 | case FingerprintReader.SouthWest: | ||
239 | 65 | v2 = 225; break; | ||
240 | 66 | case FingerprintReader.West: | ||
241 | 67 | v2 = 270; break; | ||
242 | 68 | case FingerprintReader.NorthWest: | ||
243 | 69 | v2 = 315; break; | ||
244 | 70 | } | ||
245 | 71 | |||
246 | 72 | length = Math.min(Math.abs(v1 - v2), | ||
247 | 73 | Math.abs(v1 - 360 - v2), | ||
248 | 74 | Math.abs(v1 + 360 - v2)); | ||
249 | 75 | |||
250 | 76 | if (length !== 180) | ||
251 | 77 | length = length % 180; | ||
252 | 78 | |||
253 | 79 | if (((length + v1) % 360) === v2) | ||
254 | 80 | v1 = v1 + length; | ||
255 | 81 | else | ||
256 | 82 | v1 = v1 -length; | ||
257 | 83 | |||
258 | 84 | rotationAnimation.from = rotation; | ||
259 | 85 | rotationAnimation.to = v1; | ||
260 | 86 | rotationAnimation.start(); | ||
261 | 87 | } | ||
262 | 88 | |||
263 | 89 | Icon { | ||
264 | 90 | id: directionArrow | ||
265 | 91 | objectName: "fingerprintDirectionLabel" | ||
266 | 92 | anchors { | ||
267 | 93 | top: parent.top | ||
268 | 94 | topMargin: -units.gu(2) | ||
269 | 95 | horizontalCenter: parent.horizontalCenter | ||
270 | 96 | } | ||
271 | 97 | width: units.gu(5) | ||
272 | 98 | height: width | ||
273 | 99 | |||
274 | 100 | name: "down" | ||
275 | 101 | color: theme.palette.normal.activity | ||
276 | 102 | } | ||
277 | 103 | } | ||
278 | 0 | 104 | ||
279 | === added file 'plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml' | |||
280 | --- plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml 1970-01-01 00:00:00 +0000 | |||
281 | +++ plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml 2016-06-15 10:46:42 +0000 | |||
282 | @@ -0,0 +1,133 @@ | |||
283 | 1 | /* | ||
284 | 2 | * Copyright 2016 Canonical Ltd. | ||
285 | 3 | * | ||
286 | 4 | * This program is free software; you can redistribute it and/or modify | ||
287 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
288 | 6 | * the Free Software Foundation; version 3. | ||
289 | 7 | * | ||
290 | 8 | * This program is distributed in the hope that it will be useful, | ||
291 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
292 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
293 | 11 | * GNU Lesser General Public License for more details. | ||
294 | 12 | * | ||
295 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
296 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
297 | 15 | * | ||
298 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
299 | 17 | */ | ||
300 | 18 | |||
301 | 19 | import QtQuick 2.4 | ||
302 | 20 | import Ubuntu.Components 1.3 | ||
303 | 21 | import Ubuntu.Components.Popups 1.3 | ||
304 | 22 | import Ubuntu.Components.Themes.Ambiance 1.3 | ||
305 | 23 | |||
306 | 24 | Page { | ||
307 | 25 | id: root | ||
308 | 26 | property string name | ||
309 | 27 | property string templateId | ||
310 | 28 | |||
311 | 29 | signal requestDeletion(string templateId) | ||
312 | 30 | signal requestRename(string templateId, string name) | ||
313 | 31 | |||
314 | 32 | function deletionFailed() { | ||
315 | 33 | PopupUtils.open(deletionFailed); | ||
316 | 34 | state = ""; | ||
317 | 35 | } | ||
318 | 36 | |||
319 | 37 | header: PageHeader { | ||
320 | 38 | objectName: "templateHeader" | ||
321 | 39 | title: nameInput.text.length > 0 ? nameInput.text : name | ||
322 | 40 | flickable: flickable | ||
323 | 41 | } | ||
324 | 42 | |||
325 | 43 | states: [ | ||
326 | 44 | State { | ||
327 | 45 | name: "deleting" | ||
328 | 46 | PropertyChanges { | ||
329 | 47 | target: nameInput | ||
330 | 48 | enabled: false | ||
331 | 49 | } | ||
332 | 50 | PropertyChanges { | ||
333 | 51 | target: deleteButton | ||
334 | 52 | enabled: false | ||
335 | 53 | } | ||
336 | 54 | } | ||
337 | 55 | ] | ||
338 | 56 | |||
339 | 57 | Flickable { | ||
340 | 58 | id: flickable | ||
341 | 59 | anchors { | ||
342 | 60 | fill: parent | ||
343 | 61 | topMargin: units.gu(2) | ||
344 | 62 | } | ||
345 | 63 | boundsBehavior: (contentHeight > root.height) ? | ||
346 | 64 | Flickable.DragAndOvershootBounds : | ||
347 | 65 | Flickable.StopAtBounds | ||
348 | 66 | contentHeight: contentItem.childrenRect.height | ||
349 | 67 | |||
350 | 68 | Column { | ||
351 | 69 | spacing: units.gu(2) | ||
352 | 70 | anchors { | ||
353 | 71 | left: parent.left | ||
354 | 72 | right: parent.right | ||
355 | 73 | margins: units.gu(3) | ||
356 | 74 | } | ||
357 | 75 | |||
358 | 76 | Label { | ||
359 | 77 | id: nameLabel | ||
360 | 78 | anchors.left: parent.left | ||
361 | 79 | anchors.right: parent.right | ||
362 | 80 | text: i18n.dtr("ubuntu-settings-components", "Fingerprint Name") | ||
363 | 81 | font.weight: Font.Light | ||
364 | 82 | } | ||
365 | 83 | |||
366 | 84 | TextField { | ||
367 | 85 | id: nameInput | ||
368 | 86 | objectName: "nameInput" | ||
369 | 87 | anchors.left: parent.left | ||
370 | 88 | anchors.right: parent.right | ||
371 | 89 | inputMethodHints: Qt.ImhNoPredictiveText | ||
372 | 90 | style: TextFieldStyle {} | ||
373 | 91 | text: name | ||
374 | 92 | onTextChanged: { | ||
375 | 93 | if (text) | ||
376 | 94 | requestRename(templateId, text) | ||
377 | 95 | } | ||
378 | 96 | onAccepted: { | ||
379 | 97 | if (text) { | ||
380 | 98 | requestRename(templateId, text); | ||
381 | 99 | pageStack.pop(); | ||
382 | 100 | } | ||
383 | 101 | } | ||
384 | 102 | } | ||
385 | 103 | |||
386 | 104 | Button { | ||
387 | 105 | id: deleteButton | ||
388 | 106 | objectName: "templateDelete" | ||
389 | 107 | text: i18n.dtr("ubuntu-settings-components", "Delete Fingerprint") | ||
390 | 108 | onClicked: { | ||
391 | 109 | root.state = "deleting"; | ||
392 | 110 | requestDeletion(templateId) | ||
393 | 111 | } | ||
394 | 112 | width: parent.width | ||
395 | 113 | } | ||
396 | 114 | } | ||
397 | 115 | } | ||
398 | 116 | |||
399 | 117 | Component { | ||
400 | 118 | id: deletionFailed | ||
401 | 119 | |||
402 | 120 | Dialog { | ||
403 | 121 | id: deletionFailedDialog | ||
404 | 122 | objectName: "fingerprintDeletionFailedDialog" | ||
405 | 123 | text: i18n.dtr("ubuntu-settings-components", | ||
406 | 124 | "Sorry, the fingerprint could not be deleted.") | ||
407 | 125 | |||
408 | 126 | Button { | ||
409 | 127 | objectName: "fingerprintDeleteionFailedOk" | ||
410 | 128 | onClicked: PopupUtils.close(deletionFailedDialog) | ||
411 | 129 | text: i18n.dtr("ubuntu-settings-components", "OK") | ||
412 | 130 | } | ||
413 | 131 | } | ||
414 | 132 | } | ||
415 | 133 | } | ||
416 | 0 | 134 | ||
417 | === added file 'plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml' | |||
418 | --- plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml 1970-01-01 00:00:00 +0000 | |||
419 | +++ plugins/Ubuntu/Settings/Fingerprint/FingerprintVisual.qml 2016-06-15 10:46:42 +0000 | |||
420 | @@ -0,0 +1,72 @@ | |||
421 | 1 | /* | ||
422 | 2 | * Copyright 2016 Canonical Ltd. | ||
423 | 3 | * | ||
424 | 4 | * This program is free software; you can redistribute it and/or modify | ||
425 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
426 | 6 | * the Free Software Foundation; version 3. | ||
427 | 7 | * | ||
428 | 8 | * This program is distributed in the hope that it will be useful, | ||
429 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
430 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
431 | 11 | * GNU Lesser General Public License for more details. | ||
432 | 12 | * | ||
433 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
434 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
435 | 15 | * | ||
436 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
437 | 17 | * Florian Boucault <florian.boucault@canonical.com> | ||
438 | 18 | */ | ||
439 | 19 | |||
440 | 20 | import QtQuick 2.4 | ||
441 | 21 | import Ubuntu.Settings.Fingerprint 0.1 | ||
442 | 22 | |||
443 | 23 | SegmentedImage { | ||
444 | 24 | id: segmentedImage | ||
445 | 25 | |||
446 | 26 | property var masks: [] | ||
447 | 27 | |||
448 | 28 | // http://stackoverflow.com/a/1830844/538866 | ||
449 | 29 | function isNumeric (n) { | ||
450 | 30 | return !isNaN(parseFloat(n)) && isFinite(n); | ||
451 | 31 | } | ||
452 | 32 | |||
453 | 33 | function getMasksToEnroll () { | ||
454 | 34 | var outMasks = []; | ||
455 | 35 | if (masks && masks.length) { | ||
456 | 36 | masks.forEach(function (mask, i) { | ||
457 | 37 | // Format is "<source>/[x1,y1,w1,h1],…,[xn,yn,wn,hn]" | ||
458 | 38 | // If any value is non-numeric, we drop the mask. | ||
459 | 39 | if (!isNumeric(mask.x) || !isNumeric(mask.y) || !isNumeric(mask.width) | ||
460 | 40 | || !isNumeric(mask.height)) | ||
461 | 41 | return; | ||
462 | 42 | |||
463 | 43 | // Translate the box so as to mirror the mask | ||
464 | 44 | mask.x = (1 - (mask.x + mask.width)); | ||
465 | 45 | |||
466 | 46 | outMasks.push(mask); | ||
467 | 47 | }); | ||
468 | 48 | } | ||
469 | 49 | return outMasks; | ||
470 | 50 | } | ||
471 | 51 | |||
472 | 52 | onMasksChanged: segmentedImage.enrollMasks(getMasksToEnroll()) | ||
473 | 53 | |||
474 | 54 | textureSource: "qrc:/assets/fingerprint_segmented.png" | ||
475 | 55 | boxesSource: "qrc:/assets/fingerprint_boxes.json" | ||
476 | 56 | |||
477 | 57 | Repeater { | ||
478 | 58 | model: segmentedImage.masks | ||
479 | 59 | |||
480 | 60 | Rectangle { | ||
481 | 61 | visible: UbuntuSettingsFingerprint.debug | ||
482 | 62 | color: "red" | ||
483 | 63 | opacity: 0.25 | ||
484 | 64 | x: modelData.x * segmentedImage.implicitWidth | ||
485 | 65 | y: modelData.y * segmentedImage.implicitHeight | ||
486 | 66 | width: modelData.width * segmentedImage.implicitWidth | ||
487 | 67 | height: modelData.height * segmentedImage.implicitHeight | ||
488 | 68 | |||
489 | 69 | Component.onCompleted: console.log('Scanner mask (x, y, w, h):', x, y, width, height) | ||
490 | 70 | } | ||
491 | 71 | } | ||
492 | 72 | } | ||
493 | 0 | 73 | ||
494 | === added file 'plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml' | |||
495 | --- plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml 1970-01-01 00:00:00 +0000 | |||
496 | +++ plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml 2016-06-15 10:46:42 +0000 | |||
497 | @@ -0,0 +1,440 @@ | |||
498 | 1 | /* | ||
499 | 2 | * Copyright 2016 Canonical Ltd. | ||
500 | 3 | * | ||
501 | 4 | * This program is free software; you can redistribute it and/or modify | ||
502 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
503 | 6 | * the Free Software Foundation; version 3. | ||
504 | 7 | * | ||
505 | 8 | * This program is distributed in the hope that it will be useful, | ||
506 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
507 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
508 | 11 | * GNU Lesser General Public License for more details. | ||
509 | 12 | * | ||
510 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
511 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
512 | 15 | * | ||
513 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
514 | 17 | */ | ||
515 | 18 | |||
516 | 19 | import QtQuick 2.4 | ||
517 | 20 | import QtQuick.Layouts 1.1 | ||
518 | 21 | import Biometryd 0.0 | ||
519 | 22 | import GSettings 1.0 | ||
520 | 23 | import Ubuntu.Components 1.3 | ||
521 | 24 | import Ubuntu.Components.Popups 1.3 | ||
522 | 25 | import Ubuntu.Settings.Fingerprint 0.1 | ||
523 | 26 | |||
524 | 27 | Page { | ||
525 | 28 | id: root | ||
526 | 29 | objectName: "fingerprintPage" | ||
527 | 30 | |||
528 | 31 | header: PageHeader { | ||
529 | 32 | title: i18n.dtr("ubuntu-settings-components", "Fingerprint ID") | ||
530 | 33 | flickable: content | ||
531 | 34 | } | ||
532 | 35 | |||
533 | 36 | property var _ts: Biometryd.defaultDevice.templateStore | ||
534 | 37 | property var _enrollmentOperation: null | ||
535 | 38 | property var _clearanceOperation: null | ||
536 | 39 | property var _removalOperation: null | ||
537 | 40 | property var _listOperation: null | ||
538 | 41 | property var _setupPage: null | ||
539 | 42 | property var _fpInstancePage: null | ||
540 | 43 | property var _settings: sysSettings | ||
541 | 44 | |||
542 | 45 | property Dialog _diag: null | ||
543 | 46 | property bool passcodeSet: false | ||
544 | 47 | |||
545 | 48 | function enroll () { | ||
546 | 49 | _enrollmentOperation = _ts.enroll(user); | ||
547 | 50 | _enrollmentOperation.start(enrollmentObserver); | ||
548 | 51 | } | ||
549 | 52 | |||
550 | 53 | function cancel () { | ||
551 | 54 | if (_enrollmentOperation !== null) | ||
552 | 55 | _enrollmentOperation.cancel(); | ||
553 | 56 | } | ||
554 | 57 | |||
555 | 58 | function clear() { | ||
556 | 59 | _clearanceOperation = _ts.clear(user); | ||
557 | 60 | _clearanceOperation.start(clearanceObserver); | ||
558 | 61 | } | ||
559 | 62 | |||
560 | 63 | function removeTemplate(templateId) { | ||
561 | 64 | var names = sysSettings.fingerprintNames; | ||
562 | 65 | delete names[templateId]; | ||
563 | 66 | sysSettings.fingerprintNames = names; | ||
564 | 67 | } | ||
565 | 68 | |||
566 | 69 | function renameTemplate(templateId, newName) { | ||
567 | 70 | var names = sysSettings.fingerprintNames; | ||
568 | 71 | names[templateId] = newName; | ||
569 | 72 | sysSettings.fingerprintNames = names; | ||
570 | 73 | } | ||
571 | 74 | |||
572 | 75 | function addTemplate(templateId, name) { | ||
573 | 76 | var names = sysSettings.fingerprintNames; | ||
574 | 77 | names[templateId] = name; | ||
575 | 78 | sysSettings.fingerprintNames = names; | ||
576 | 79 | } | ||
577 | 80 | |||
578 | 81 | function createTemplateName() { | ||
579 | 82 | var map = sysSettings.fingerprintNames; | ||
580 | 83 | var currentNames = []; | ||
581 | 84 | var newName; | ||
582 | 85 | for (var k in map) { | ||
583 | 86 | if (map.hasOwnProperty(k)) | ||
584 | 87 | currentNames.push(map[k]); | ||
585 | 88 | } | ||
586 | 89 | |||
587 | 90 | var i = 0; | ||
588 | 91 | do { | ||
589 | 92 | newName = i18n.dtr("ubuntu-settings-components", | ||
590 | 93 | "Finger %1").arg(++i); // Start at 1 | ||
591 | 94 | } while (currentNames.indexOf(newName) >= 0); | ||
592 | 95 | return newName; | ||
593 | 96 | } | ||
594 | 97 | |||
595 | 98 | // Assign names to unnamed fingerprints. This exist because we can't | ||
596 | 99 | // guarantee that all fingerprints get names (i.e. enrollment can complete | ||
597 | 100 | // after System Settings closes). | ||
598 | 101 | function assignNames(templateIds) { | ||
599 | 102 | var names = sysSettings.fingerprintNames; | ||
600 | 103 | for (var i = 0; i < templateIds.length; i++) { | ||
601 | 104 | if ( !(templateIds[i] in names) || !names[templateIds[i]]) | ||
602 | 105 | names[templateIds[i]] = createTemplateName(); | ||
603 | 106 | sysSettings.fingerprintNames = names; | ||
604 | 107 | } | ||
605 | 108 | } | ||
606 | 109 | |||
607 | 110 | signal requestPasscode() | ||
608 | 111 | |||
609 | 112 | Component.onCompleted: { | ||
610 | 113 | // Start a list operation immediately. | ||
611 | 114 | if (Biometryd.available) { | ||
612 | 115 | _listOperation = _ts.list(user); | ||
613 | 116 | _listOperation.start(listObserver); | ||
614 | 117 | } | ||
615 | 118 | } | ||
616 | 119 | |||
617 | 120 | Component.onDestruction: { | ||
618 | 121 | if (_enrollmentOperation !== null) | ||
619 | 122 | _enrollmentOperation.cancel(); | ||
620 | 123 | |||
621 | 124 | if (_clearanceOperation !== null) | ||
622 | 125 | _clearanceOperation.cancel(); | ||
623 | 126 | |||
624 | 127 | if (_removalOperation !== null) | ||
625 | 128 | _removalOperation.cancel(); | ||
626 | 129 | |||
627 | 130 | if (_listOperation !== null) | ||
628 | 131 | _listOperation.cancel(); | ||
629 | 132 | } | ||
630 | 133 | |||
631 | 134 | states: [ | ||
632 | 135 | State { | ||
633 | 136 | name: "noPasscode" | ||
634 | 137 | PropertyChanges { | ||
635 | 138 | target: setupPasscode | ||
636 | 139 | visible: true | ||
637 | 140 | } | ||
638 | 141 | PropertyChanges { | ||
639 | 142 | target: setupFingerprint | ||
640 | 143 | enabled: false | ||
641 | 144 | } | ||
642 | 145 | PropertyChanges { | ||
643 | 146 | target: fingerprintsList | ||
644 | 147 | enabled: false | ||
645 | 148 | } | ||
646 | 149 | when: !passcodeSet | ||
647 | 150 | }, | ||
648 | 151 | State { | ||
649 | 152 | name: "noScanner" | ||
650 | 153 | PropertyChanges { | ||
651 | 154 | target: setupFingerprint | ||
652 | 155 | enabled: false | ||
653 | 156 | } | ||
654 | 157 | PropertyChanges { | ||
655 | 158 | target: fingerprintsList | ||
656 | 159 | visible: false | ||
657 | 160 | } | ||
658 | 161 | when: !Biometryd.available | ||
659 | 162 | } | ||
660 | 163 | ] | ||
661 | 164 | |||
662 | 165 | Flickable { | ||
663 | 166 | id: content | ||
664 | 167 | anchors.fill: parent | ||
665 | 168 | boundsBehavior: (contentHeight > root.height) ? | ||
666 | 169 | Flickable.DragAndOvershootBounds : | ||
667 | 170 | Flickable.StopAtBounds | ||
668 | 171 | contentHeight: contentItem.childrenRect.height | ||
669 | 172 | |||
670 | 173 | Column { | ||
671 | 174 | anchors { left: parent.left; right: parent.right } | ||
672 | 175 | // spacing: units.gu(3) | ||
673 | 176 | |||
674 | 177 | Column { | ||
675 | 178 | id: setupPasscode | ||
676 | 179 | anchors { left: parent.left; right: parent.right } | ||
677 | 180 | visible: false | ||
678 | 181 | |||
679 | 182 | ListItem { | ||
680 | 183 | height: setPcodeLayout.height + (divider.visible ? divider.height : 0) | ||
681 | 184 | ListItemLayout { | ||
682 | 185 | id: setPcodeLayout | ||
683 | 186 | title.text: i18n.dtr( | ||
684 | 187 | "ubuntu-settings-components", | ||
685 | 188 | "Passcode required" | ||
686 | 189 | ) | ||
687 | 190 | subtitle.text: i18n.dtr( | ||
688 | 191 | "ubuntu-settings-components", | ||
689 | 192 | "You must set a passcode to use fingerprint ID" | ||
690 | 193 | ) | ||
691 | 194 | Button { | ||
692 | 195 | objectName: "fingerprintSetPasscodeButton" | ||
693 | 196 | onClicked: root.requestPasscode() | ||
694 | 197 | text: i18n.dtr( | ||
695 | 198 | "ubuntu-settings-components", | ||
696 | 199 | "Set Passcode…" | ||
697 | 200 | ) | ||
698 | 201 | } | ||
699 | 202 | } | ||
700 | 203 | } | ||
701 | 204 | } | ||
702 | 205 | |||
703 | 206 | Column { | ||
704 | 207 | id: fingerprints | ||
705 | 208 | anchors { left: parent.left; right: parent.right } | ||
706 | 209 | |||
707 | 210 | Repeater { | ||
708 | 211 | id: fingerprintsList | ||
709 | 212 | property bool enabled: true | ||
710 | 213 | objectName: "fingerprintsList" | ||
711 | 214 | model: { | ||
712 | 215 | var map = sysSettings.fingerprintNames; | ||
713 | 216 | var m = []; | ||
714 | 217 | for (var k in map) { | ||
715 | 218 | if (map.hasOwnProperty(k)) { | ||
716 | 219 | m.push({ | ||
717 | 220 | templateId: k, | ||
718 | 221 | name: map[k] | ||
719 | 222 | }); | ||
720 | 223 | } | ||
721 | 224 | } | ||
722 | 225 | m.sort(function (a, b) { | ||
723 | 226 | if (a.name < b.name) return -1; | ||
724 | 227 | if (a.name > b.name) return 1; | ||
725 | 228 | if (a.name == b.name) return 0; | ||
726 | 229 | }); | ||
727 | 230 | return m; | ||
728 | 231 | } | ||
729 | 232 | |||
730 | 233 | ListItem { | ||
731 | 234 | height: fpLayout.height + (divider.visible ? divider.height : 0) | ||
732 | 235 | onClicked: _fpInstancePage = pageStack.push( | ||
733 | 236 | Qt.resolvedUrl("Fingerprint.qml"), { | ||
734 | 237 | name: modelData.name, | ||
735 | 238 | templateId: modelData.templateId | ||
736 | 239 | } | ||
737 | 240 | ) | ||
738 | 241 | enabled: fingerprintsList.enabled | ||
739 | 242 | |||
740 | 243 | ListItemLayout { | ||
741 | 244 | id: fpLayout | ||
742 | 245 | objectName: "fingerprintInstance-" + index | ||
743 | 246 | title.text: modelData.name | ||
744 | 247 | |||
745 | 248 | ProgressionSlot {} | ||
746 | 249 | } | ||
747 | 250 | } | ||
748 | 251 | } | ||
749 | 252 | } | ||
750 | 253 | |||
751 | 254 | Column { | ||
752 | 255 | id: setupFingerprint | ||
753 | 256 | |||
754 | 257 | anchors { left: parent.left; right: parent.right } | ||
755 | 258 | objectName: "fingerprintSetupEntry" | ||
756 | 259 | property bool enabled: true | ||
757 | 260 | spacing: units.gu(2) | ||
758 | 261 | |||
759 | 262 | ListItem { | ||
760 | 263 | height: addFpLayout.height + (divider.visible ? divider.height : 0) | ||
761 | 264 | onClicked: { | ||
762 | 265 | _setupPage = pageStack.push(Qt.resolvedUrl("Setup.qml")); | ||
763 | 266 | root.enroll(); | ||
764 | 267 | } | ||
765 | 268 | enabled: parent.enabled | ||
766 | 269 | |||
767 | 270 | ListItemLayout { | ||
768 | 271 | id: addFpLayout | ||
769 | 272 | objectName: "fingerprintAddListItemLayout" | ||
770 | 273 | title.text: i18n.dtr( | ||
771 | 274 | "ubuntu-settings-components", | ||
772 | 275 | "Add fingerprint" | ||
773 | 276 | ) | ||
774 | 277 | |||
775 | 278 | ProgressionSlot {} | ||
776 | 279 | } | ||
777 | 280 | } | ||
778 | 281 | |||
779 | 282 | Button { | ||
780 | 283 | anchors.horizontalCenter: parent.horizontalCenter | ||
781 | 284 | enabled: fingerprintsList.model.length > 0 | ||
782 | 285 | objectName: "fingerprintRemoveAllButton" | ||
783 | 286 | onClicked: _diag = PopupUtils.open(removeAllAlert) | ||
784 | 287 | text: i18n.dtr("ubuntu-settings-components", | ||
785 | 288 | "Remove All…") | ||
786 | 289 | } | ||
787 | 290 | } | ||
788 | 291 | } | ||
789 | 292 | } | ||
790 | 293 | |||
791 | 294 | Component { | ||
792 | 295 | id: removeAllAlert | ||
793 | 296 | |||
794 | 297 | Dialog { | ||
795 | 298 | id: removeAllAlertDialog | ||
796 | 299 | |||
797 | 300 | objectName: "fingerprintRemoveAllDialog" | ||
798 | 301 | text: i18n.dtr( | ||
799 | 302 | "ubuntu-settings-components", | ||
800 | 303 | "Are you sure you want to forget all stored fingerprints?" | ||
801 | 304 | ) | ||
802 | 305 | |||
803 | 306 | RowLayout { | ||
804 | 307 | anchors { left: parent.left; right: parent.right } | ||
805 | 308 | spacing: units.gu(2) | ||
806 | 309 | |||
807 | 310 | Button { | ||
808 | 311 | onClicked: PopupUtils.close(removeAllAlertDialog) | ||
809 | 312 | text: i18n.dtr("ubuntu-settings-components", "Cancel") | ||
810 | 313 | Layout.fillWidth: true | ||
811 | 314 | } | ||
812 | 315 | |||
813 | 316 | Button { | ||
814 | 317 | objectName: "fingerprintRemoveAllConfirmationButton" | ||
815 | 318 | onClicked: root.clear() | ||
816 | 319 | text: i18n.dtr("ubuntu-settings-components", "Remove") | ||
817 | 320 | Layout.fillWidth: true | ||
818 | 321 | } | ||
819 | 322 | } | ||
820 | 323 | } | ||
821 | 324 | } | ||
822 | 325 | |||
823 | 326 | Component { | ||
824 | 327 | id: fingerprintReaderBroken | ||
825 | 328 | |||
826 | 329 | Dialog { | ||
827 | 330 | id: fingerprintReaderBrokenDialog | ||
828 | 331 | objectName: "fingerprintReaderBrokenDialog" | ||
829 | 332 | text: i18n.dtr("ubuntu-settings-components", | ||
830 | 333 | "Sorry, the reader doesn’t seem to be working.") | ||
831 | 334 | |||
832 | 335 | Button { | ||
833 | 336 | objectName: "fingerprintReaderBrokenDialogOK" | ||
834 | 337 | onClicked: PopupUtils.close(fingerprintReaderBrokenDialog) | ||
835 | 338 | text: i18n.dtr("ubuntu-settings-components", "OK") | ||
836 | 339 | } | ||
837 | 340 | } | ||
838 | 341 | } | ||
839 | 342 | |||
840 | 343 | Connections { | ||
841 | 344 | target: _setupPage | ||
842 | 345 | onEnroll: root.enroll() | ||
843 | 346 | onCancel: root.cancel() | ||
844 | 347 | } | ||
845 | 348 | |||
846 | 349 | Connections { | ||
847 | 350 | target: _fpInstancePage | ||
848 | 351 | |||
849 | 352 | onRequestDeletion: { | ||
850 | 353 | _removalOperation = _ts.remove(user, templateId); | ||
851 | 354 | _removalOperation.start(removalObserver); | ||
852 | 355 | } | ||
853 | 356 | onRequestRename: renameTemplate(templateId, name) | ||
854 | 357 | } | ||
855 | 358 | |||
856 | 359 | Observer { | ||
857 | 360 | id: enrollmentObserver | ||
858 | 361 | objectName: "enrollmentObserver" | ||
859 | 362 | onFailed: { | ||
860 | 363 | if (_setupPage) | ||
861 | 364 | _setupPage.enrollmentFailed(reason); | ||
862 | 365 | _enrollmentOperation = null; | ||
863 | 366 | console.error("Enrollment failed", reason); | ||
864 | 367 | } | ||
865 | 368 | onProgressed: _setupPage.enrollmentProgressed(percent, details) | ||
866 | 369 | onSucceeded: { | ||
867 | 370 | if (!(result in sysSettings.fingerprintNames)) | ||
868 | 371 | root.addTemplate(result, root.createTemplateName()); | ||
869 | 372 | if (_setupPage) | ||
870 | 373 | _setupPage.enrollmentCompleted(); | ||
871 | 374 | _enrollmentOperation = null; | ||
872 | 375 | } | ||
873 | 376 | onCanceled: _enrollmentOperation = null | ||
874 | 377 | } | ||
875 | 378 | |||
876 | 379 | Observer { | ||
877 | 380 | id: clearanceObserver | ||
878 | 381 | objectName: "clearanceObserver" | ||
879 | 382 | onFailed: { | ||
880 | 383 | _clearanceOperation = null; | ||
881 | 384 | if (_diag) PopupUtils.close(_diag); | ||
882 | 385 | _diag = PopupUtils.open(fingerprintReaderBroken); | ||
883 | 386 | console.error("Biometry clearance failed:", reason); | ||
884 | 387 | } | ||
885 | 388 | onSucceeded: { | ||
886 | 389 | _clearanceOperation = null; | ||
887 | 390 | if (_diag) PopupUtils.close(_diag); | ||
888 | 391 | sysSettings.fingerprintNames = {}; | ||
889 | 392 | } | ||
890 | 393 | onCanceled: _clearanceOperation = null | ||
891 | 394 | } | ||
892 | 395 | |||
893 | 396 | Observer { | ||
894 | 397 | id: removalObserver | ||
895 | 398 | objectName: "removalObserver" | ||
896 | 399 | onFailed: { | ||
897 | 400 | _removalOperation = null; | ||
898 | 401 | if (_fpInstancePage) | ||
899 | 402 | _fpInstancePage.deletionFailed() | ||
900 | 403 | console.error("Biometryd template deletion failed:", reason); | ||
901 | 404 | } | ||
902 | 405 | onSucceeded: { | ||
903 | 406 | _removalOperation = null; | ||
904 | 407 | if (pageStack.currentPage === _fpInstancePage) | ||
905 | 408 | pageStack.pop(); | ||
906 | 409 | root.removeTemplate(result); | ||
907 | 410 | } | ||
908 | 411 | onCanceled: _removalOperation = null | ||
909 | 412 | } | ||
910 | 413 | |||
911 | 414 | Observer { | ||
912 | 415 | id: listObserver | ||
913 | 416 | objectName: "listObserver" | ||
914 | 417 | onFailed: { | ||
915 | 418 | _listOperation = null; | ||
916 | 419 | if (_diag) PopupUtils.close(_diag); | ||
917 | 420 | _diag = PopupUtils.open(fingerprintReaderBroken); | ||
918 | 421 | console.error("Biometryd list failed:", reason); | ||
919 | 422 | } | ||
920 | 423 | onSucceeded: { | ||
921 | 424 | _listOperation = null; | ||
922 | 425 | root.assignNames(result); | ||
923 | 426 | } | ||
924 | 427 | onCanceled: _listOperation = null | ||
925 | 428 | } | ||
926 | 429 | |||
927 | 430 | User { | ||
928 | 431 | id: user | ||
929 | 432 | uid: UbuntuSettingsFingerprint.uid | ||
930 | 433 | } | ||
931 | 434 | |||
932 | 435 | GSettings { | ||
933 | 436 | id: sysSettings | ||
934 | 437 | objectName: "systemSettings" | ||
935 | 438 | schema.id: "com.ubuntu.touch.system" | ||
936 | 439 | } | ||
937 | 440 | } | ||
938 | 0 | 441 | ||
939 | === added file 'plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml' | |||
940 | --- plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml 1970-01-01 00:00:00 +0000 | |||
941 | +++ plugins/Ubuntu/Settings/Fingerprint/SegmentBoundingBoxes.qml 2016-06-15 10:46:42 +0000 | |||
942 | @@ -0,0 +1,81 @@ | |||
943 | 1 | /* | ||
944 | 2 | * Copyright 2016 Canonical Ltd. | ||
945 | 3 | * | ||
946 | 4 | * This program is free software; you can redistribute it and/or modify | ||
947 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
948 | 6 | * the Free Software Foundation; version 3. | ||
949 | 7 | * | ||
950 | 8 | * This program is distributed in the hope that it will be useful, | ||
951 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
952 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
953 | 11 | * GNU Lesser General Public License for more details. | ||
954 | 12 | * | ||
955 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
956 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
957 | 15 | * | ||
958 | 16 | * Authored by Florian Boucault <florian.boucault@canonical.com> | ||
959 | 17 | */ | ||
960 | 18 | |||
961 | 19 | import QtQuick 2.4 | ||
962 | 20 | |||
963 | 21 | QtObject { | ||
964 | 22 | id: segmentBoundingBoxes | ||
965 | 23 | |||
966 | 24 | property string source | ||
967 | 25 | onSourceChanged: parseBoundingBoxes(source) | ||
968 | 26 | |||
969 | 27 | property var boundingBoxes: [] | ||
970 | 28 | property real width | ||
971 | 29 | property real height | ||
972 | 30 | property int count: boundingBoxes.length | ||
973 | 31 | |||
974 | 32 | // The API cannot be used reliably before this signal has been emitted. | ||
975 | 33 | signal ready() | ||
976 | 34 | |||
977 | 35 | function parseBoundingBoxes(source) { | ||
978 | 36 | var xhr = new XMLHttpRequest; | ||
979 | 37 | xhr.open("GET", source); | ||
980 | 38 | xhr.onreadystatechange = function() { | ||
981 | 39 | if (xhr.readyState == XMLHttpRequest.DONE) { | ||
982 | 40 | var b = []; | ||
983 | 41 | var json = JSON.parse(xhr.responseText); | ||
984 | 42 | boundingBoxes = json["boxes"]; | ||
985 | 43 | width = json["width"]; | ||
986 | 44 | height = json["height"]; | ||
987 | 45 | ready(); | ||
988 | 46 | } | ||
989 | 47 | } | ||
990 | 48 | xhr.send(); | ||
991 | 49 | } | ||
992 | 50 | |||
993 | 51 | function intersects(box1, box2) { | ||
994 | 52 | // TODO: optimize | ||
995 | 53 | var x11 = box1[0]; | ||
996 | 54 | var y11 = box1[1]; | ||
997 | 55 | var x12 = box1[0] + box1[2]; | ||
998 | 56 | var y12 = box1[1] + box1[3]; | ||
999 | 57 | var x21 = box2[0]; | ||
1000 | 58 | var y21 = box2[1]; | ||
1001 | 59 | var x22 = box2[0] + box2[2]; | ||
1002 | 60 | var y22 = box2[1] + box2[3]; | ||
1003 | 61 | var x_overlap = Math.max(0, Math.min(x12,x22) - Math.max(x11,x21)); | ||
1004 | 62 | var y_overlap = Math.max(0, Math.min(y12,y22) - Math.max(y11,y21)); | ||
1005 | 63 | return (x_overlap / Math.min(box1[2], box2[2]) > 0.25 | ||
1006 | 64 | && y_overlap / Math.min(box1[3], box2[3]) > 0.25); | ||
1007 | 65 | } | ||
1008 | 66 | |||
1009 | 67 | function computeIntersections(hitBox) { | ||
1010 | 68 | var absoluteHitBox = [hitBox[0] * width, hitBox[1] * height, | ||
1011 | 69 | hitBox[2] * width, hitBox[3] * height]; | ||
1012 | 70 | |||
1013 | 71 | var intersections = []; | ||
1014 | 72 | for (var i in boundingBoxes) { | ||
1015 | 73 | var boundingBox = boundingBoxes[i]; | ||
1016 | 74 | if (intersects(absoluteHitBox, boundingBox)) { | ||
1017 | 75 | intersections.push(i); | ||
1018 | 76 | } | ||
1019 | 77 | } | ||
1020 | 78 | |||
1021 | 79 | return intersections; | ||
1022 | 80 | } | ||
1023 | 81 | } | ||
1024 | 0 | 82 | ||
1025 | === added file 'plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml' | |||
1026 | --- plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml 1970-01-01 00:00:00 +0000 | |||
1027 | +++ plugins/Ubuntu/Settings/Fingerprint/SegmentRenderer.qml 2016-06-15 10:46:42 +0000 | |||
1028 | @@ -0,0 +1,95 @@ | |||
1029 | 1 | /* | ||
1030 | 2 | * Copyright 2016 Canonical Ltd. | ||
1031 | 3 | * | ||
1032 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1033 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1034 | 6 | * the Free Software Foundation; version 3. | ||
1035 | 7 | * | ||
1036 | 8 | * This program is distributed in the hope that it will be useful, | ||
1037 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1038 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1039 | 11 | * GNU Lesser General Public License for more details. | ||
1040 | 12 | * | ||
1041 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1042 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1043 | 15 | * | ||
1044 | 16 | * Authored by Florian Boucault <florian.boucault@canonical.com> | ||
1045 | 17 | */ | ||
1046 | 18 | |||
1047 | 19 | import QtQuick 2.4 | ||
1048 | 20 | import Ubuntu.Components 1.3 | ||
1049 | 21 | |||
1050 | 22 | ShaderEffect { | ||
1051 | 23 | id: segmentRenderer | ||
1052 | 24 | |||
1053 | 25 | implicitWidth: texture.width | ||
1054 | 26 | implicitHeight: texture.height | ||
1055 | 27 | |||
1056 | 28 | function animate(segments) { | ||
1057 | 29 | for (var i in segments) { | ||
1058 | 30 | var progressPixel = progressTexture.children[segments[i]]; | ||
1059 | 31 | if (progressPixel.progress == 0.0) { | ||
1060 | 32 | progressPixel.animation.start(); | ||
1061 | 33 | } | ||
1062 | 34 | } | ||
1063 | 35 | } | ||
1064 | 36 | |||
1065 | 37 | property string source | ||
1066 | 38 | property int segmentsCount | ||
1067 | 39 | property color backgroundColor: theme.palette.normal.base | ||
1068 | 40 | property color fillColor: theme.palette.normal.activity | ||
1069 | 41 | property Image texture: Image { | ||
1070 | 42 | source: segmentRenderer.source | ||
1071 | 43 | } | ||
1072 | 44 | property var progressTexture: progressTexture | ||
1073 | 45 | property int progressTextureSize: progressTexture.size | ||
1074 | 46 | |||
1075 | 47 | fragmentShader: " | ||
1076 | 48 | varying mediump vec2 qt_TexCoord0; | ||
1077 | 49 | uniform lowp float qt_Opacity; | ||
1078 | 50 | uniform lowp vec4 backgroundColor; | ||
1079 | 51 | uniform lowp vec4 fillColor; | ||
1080 | 52 | uniform lowp sampler2D texture; | ||
1081 | 53 | uniform lowp sampler2D progressTexture; | ||
1082 | 54 | uniform lowp int progressTextureSize; | ||
1083 | 55 | |||
1084 | 56 | void main() { | ||
1085 | 57 | lowp vec4 p = texture2D(texture, qt_TexCoord0); | ||
1086 | 58 | lowp float segment = p.r * 255.0; | ||
1087 | 59 | lowp vec4 segmentProgress = step(0.9, segment) * texture2D(progressTexture, vec2((segment - 1.0 + 0.5) / float(progressTextureSize), 0.5)); | ||
1088 | 60 | lowp vec4 color = mix(fillColor, backgroundColor, step(segmentProgress.r, p.g)); | ||
1089 | 61 | gl_FragColor = vec4(color.rgb, 1.0) * p.b * qt_Opacity; | ||
1090 | 62 | } | ||
1091 | 63 | " | ||
1092 | 64 | |||
1093 | 65 | // TODO: not the most efficient; could be replaced with an image provider | ||
1094 | 66 | Row { | ||
1095 | 67 | id: progressTexture | ||
1096 | 68 | |||
1097 | 69 | property int size: 128 | ||
1098 | 70 | layer.enabled: true | ||
1099 | 71 | layer.sourceRect: Qt.rect(0, 0, size, 1) | ||
1100 | 72 | layer.textureSize: Qt.size(size, 1) | ||
1101 | 73 | layer.wrapMode: ShaderEffectSource.ClampToEdge | ||
1102 | 74 | visible: false | ||
1103 | 75 | |||
1104 | 76 | Repeater { | ||
1105 | 77 | model: segmentRenderer.segmentsCount | ||
1106 | 78 | Rectangle { | ||
1107 | 79 | id: progressPixel | ||
1108 | 80 | width: 1 | ||
1109 | 81 | height: 1 | ||
1110 | 82 | color: Qt.rgba(progress, progress, progress, 1.0) | ||
1111 | 83 | property real progress | ||
1112 | 84 | property NumberAnimation animation: NumberAnimation { | ||
1113 | 85 | target: progressPixel | ||
1114 | 86 | property: "progress" | ||
1115 | 87 | from: 0.0 | ||
1116 | 88 | to: 1.0 | ||
1117 | 89 | duration: UbuntuAnimation.SleepyDuration | ||
1118 | 90 | easing: UbuntuAnimation.StandardEasing | ||
1119 | 91 | } | ||
1120 | 92 | } | ||
1121 | 93 | } | ||
1122 | 94 | } | ||
1123 | 95 | } | ||
1124 | 0 | 96 | ||
1125 | === added file 'plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml' | |||
1126 | --- plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml 1970-01-01 00:00:00 +0000 | |||
1127 | +++ plugins/Ubuntu/Settings/Fingerprint/SegmentedImage.qml 2016-06-15 10:46:42 +0000 | |||
1128 | @@ -0,0 +1,52 @@ | |||
1129 | 1 | /* | ||
1130 | 2 | * Copyright 2016 Canonical Ltd. | ||
1131 | 3 | * | ||
1132 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1133 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1134 | 6 | * the Free Software Foundation; version 3. | ||
1135 | 7 | * | ||
1136 | 8 | * This program is distributed in the hope that it will be useful, | ||
1137 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1138 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1139 | 11 | * GNU Lesser General Public License for more details. | ||
1140 | 12 | * | ||
1141 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1142 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1143 | 15 | * | ||
1144 | 16 | * Authored by Florian Boucault <florian.boucault@canonical.com> | ||
1145 | 17 | */ | ||
1146 | 18 | |||
1147 | 19 | import QtQuick 2.4 | ||
1148 | 20 | |||
1149 | 21 | Item { | ||
1150 | 22 | id: segImg | ||
1151 | 23 | property alias textureSource: segmentRenderer.source | ||
1152 | 24 | property alias boxesSource: segmentBoundingBoxes.source | ||
1153 | 25 | |||
1154 | 26 | implicitWidth: segmentRenderer.implicitWidth | ||
1155 | 27 | implicitHeight: segmentRenderer.implicitHeight | ||
1156 | 28 | |||
1157 | 29 | // Ready to enroll. | ||
1158 | 30 | signal ready() | ||
1159 | 31 | |||
1160 | 32 | function enrollMasks(masks) { | ||
1161 | 33 | if (masks && masks.length) { | ||
1162 | 34 | var segments = []; | ||
1163 | 35 | masks.forEach(function (mask, i) { | ||
1164 | 36 | var hitBox = [mask.x, mask.y, mask.width, mask.height]; | ||
1165 | 37 | segments = segments.concat(segmentBoundingBoxes.computeIntersections(hitBox)); | ||
1166 | 38 | }); | ||
1167 | 39 | segmentRenderer.animate(segments); | ||
1168 | 40 | } | ||
1169 | 41 | } | ||
1170 | 42 | |||
1171 | 43 | SegmentRenderer { | ||
1172 | 44 | id: segmentRenderer | ||
1173 | 45 | segmentsCount: segmentBoundingBoxes.count | ||
1174 | 46 | } | ||
1175 | 47 | |||
1176 | 48 | SegmentBoundingBoxes { | ||
1177 | 49 | id: segmentBoundingBoxes | ||
1178 | 50 | onReady: segImg.ready() | ||
1179 | 51 | } | ||
1180 | 52 | } | ||
1181 | 0 | 53 | ||
1182 | === added file 'plugins/Ubuntu/Settings/Fingerprint/Setup.qml' | |||
1183 | --- plugins/Ubuntu/Settings/Fingerprint/Setup.qml 1970-01-01 00:00:00 +0000 | |||
1184 | +++ plugins/Ubuntu/Settings/Fingerprint/Setup.qml 2016-06-15 10:46:42 +0000 | |||
1185 | @@ -0,0 +1,388 @@ | |||
1186 | 1 | /* | ||
1187 | 2 | * Copyright 2016 Canonical Ltd. | ||
1188 | 3 | * | ||
1189 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1190 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1191 | 6 | * the Free Software Foundation; version 3. | ||
1192 | 7 | * | ||
1193 | 8 | * This program is distributed in the hope that it will be useful, | ||
1194 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1195 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1196 | 11 | * GNU Lesser General Public License for more details. | ||
1197 | 12 | * | ||
1198 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1199 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1200 | 15 | * | ||
1201 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
1202 | 17 | */ | ||
1203 | 18 | |||
1204 | 19 | import Biometryd 0.0 | ||
1205 | 20 | import QtGraphicalEffects 1.0 | ||
1206 | 21 | import QtQuick 2.4 | ||
1207 | 22 | import QtQuick.Layouts 1.1 | ||
1208 | 23 | import Ubuntu.Components 1.3 | ||
1209 | 24 | import Ubuntu.Settings.Fingerprint 0.1 | ||
1210 | 25 | |||
1211 | 26 | Page { | ||
1212 | 27 | id: root | ||
1213 | 28 | |||
1214 | 29 | objectName: "fingerprintSetupPage" | ||
1215 | 30 | |||
1216 | 31 | signal enroll() | ||
1217 | 32 | signal cancel() | ||
1218 | 33 | |||
1219 | 34 | function enrollmentFailed(error) { | ||
1220 | 35 | root.state = "failed"; | ||
1221 | 36 | } | ||
1222 | 37 | |||
1223 | 38 | function enrollmentCompleted() { | ||
1224 | 39 | root.state = "done"; | ||
1225 | 40 | } | ||
1226 | 41 | |||
1227 | 42 | function enrollmentProgressed(progress, hints) { | ||
1228 | 43 | root.state = "reading"; | ||
1229 | 44 | imageDefault.masks = hints[FingerprintReader.masks]; | ||
1230 | 45 | progressLabel.progress = 100 * progress; | ||
1231 | 46 | directionContainer.direction = hints[FingerprintReader.suggestedNextDirection] || FingerprintReader.NotAvailable; | ||
1232 | 47 | } | ||
1233 | 48 | |||
1234 | 49 | states: [ | ||
1235 | 50 | State { | ||
1236 | 51 | name: "" | ||
1237 | 52 | StateChangeScript { | ||
1238 | 53 | script: statusLabel.setText(statusLabel.initialText) | ||
1239 | 54 | } | ||
1240 | 55 | }, | ||
1241 | 56 | State { | ||
1242 | 57 | name: "reading" | ||
1243 | 58 | StateChangeScript { | ||
1244 | 59 | script: statusLabel.setText( | ||
1245 | 60 | i18n.dtr("ubuntu-settings-components", | ||
1246 | 61 | "Lift and press your finger again.") | ||
1247 | 62 | ) | ||
1248 | 63 | } | ||
1249 | 64 | PropertyChanges { | ||
1250 | 65 | target: imageDefault | ||
1251 | 66 | opacity: 1 | ||
1252 | 67 | } | ||
1253 | 68 | PropertyChanges { | ||
1254 | 69 | target: progressLabel | ||
1255 | 70 | opacity: 1 | ||
1256 | 71 | } | ||
1257 | 72 | }, | ||
1258 | 73 | State { | ||
1259 | 74 | name: "longer" | ||
1260 | 75 | StateChangeScript { | ||
1261 | 76 | script: statusLabel.setText( | ||
1262 | 77 | i18n.dtr("ubuntu-settings-components", | ||
1263 | 78 | "Keep your finger on the reader for longer.") | ||
1264 | 79 | ) | ||
1265 | 80 | } | ||
1266 | 81 | }, | ||
1267 | 82 | State { | ||
1268 | 83 | name: "failed" | ||
1269 | 84 | PropertyChanges { | ||
1270 | 85 | target: imageDefault | ||
1271 | 86 | opacity: 0 | ||
1272 | 87 | } | ||
1273 | 88 | PropertyChanges { | ||
1274 | 89 | target: imageFailed | ||
1275 | 90 | opacity: 1 | ||
1276 | 91 | } | ||
1277 | 92 | PropertyChanges { | ||
1278 | 93 | target: cancelButton | ||
1279 | 94 | text: i18n.dtr("ubuntu-settings-components", "Back"); | ||
1280 | 95 | } | ||
1281 | 96 | PropertyChanges { | ||
1282 | 97 | target: doneButton | ||
1283 | 98 | visible: false | ||
1284 | 99 | } | ||
1285 | 100 | StateChangeScript { | ||
1286 | 101 | script: statusLabel.setText( | ||
1287 | 102 | i18n.dtr("ubuntu-settings-components", | ||
1288 | 103 | "Sorry, the reader doesn’t seem to be working."), | ||
1289 | 104 | true // No animation | ||
1290 | 105 | ) | ||
1291 | 106 | } | ||
1292 | 107 | StateChangeScript { | ||
1293 | 108 | script: imageFailed.start() | ||
1294 | 109 | } | ||
1295 | 110 | PropertyChanges { | ||
1296 | 111 | target: directionContainer | ||
1297 | 112 | opacity: 0 | ||
1298 | 113 | } | ||
1299 | 114 | }, | ||
1300 | 115 | State { | ||
1301 | 116 | name: "done" | ||
1302 | 117 | PropertyChanges { | ||
1303 | 118 | target: imageDefault | ||
1304 | 119 | opacity: 0 | ||
1305 | 120 | } | ||
1306 | 121 | PropertyChanges { | ||
1307 | 122 | target: imageDone | ||
1308 | 123 | opacity: 1 | ||
1309 | 124 | } | ||
1310 | 125 | PropertyChanges { | ||
1311 | 126 | target: cancelButton | ||
1312 | 127 | visible: false | ||
1313 | 128 | } | ||
1314 | 129 | StateChangeScript { | ||
1315 | 130 | script: statusLabel.setText( | ||
1316 | 131 | i18n.dtr("ubuntu-settings-components", "All done!"), | ||
1317 | 132 | true // No animation | ||
1318 | 133 | ) | ||
1319 | 134 | } | ||
1320 | 135 | PropertyChanges { | ||
1321 | 136 | target: doneButton | ||
1322 | 137 | enabled: true | ||
1323 | 138 | text: i18n.dtr("ubuntu-settings-components", "OK") | ||
1324 | 139 | } | ||
1325 | 140 | StateChangeScript { | ||
1326 | 141 | script: imageDone.start() | ||
1327 | 142 | } | ||
1328 | 143 | PropertyChanges { | ||
1329 | 144 | target: directionContainer | ||
1330 | 145 | opacity: 0 | ||
1331 | 146 | } | ||
1332 | 147 | } | ||
1333 | 148 | ] | ||
1334 | 149 | |||
1335 | 150 | header: PageHeader { | ||
1336 | 151 | visible: false | ||
1337 | 152 | } | ||
1338 | 153 | |||
1339 | 154 | Item { | ||
1340 | 155 | anchors.fill: parent | ||
1341 | 156 | |||
1342 | 157 | Item { | ||
1343 | 158 | id: fingerprintBox | ||
1344 | 159 | anchors.centerIn: parent | ||
1345 | 160 | width: units.gu(26) | ||
1346 | 161 | height: units.gu(29) | ||
1347 | 162 | |||
1348 | 163 | Item { | ||
1349 | 164 | id: imageContainer | ||
1350 | 165 | anchors.centerIn: parent | ||
1351 | 166 | width: imageDefault.implicitWidth | ||
1352 | 167 | height: imageDefault.implicitHeight | ||
1353 | 168 | |||
1354 | 169 | // Default image. | ||
1355 | 170 | FingerprintVisual { | ||
1356 | 171 | id: imageDefault | ||
1357 | 172 | objectName: "fingerprintDefaultVisual" | ||
1358 | 173 | anchors.centerIn: parent | ||
1359 | 174 | |||
1360 | 175 | Behavior on opacity { UbuntuNumberAnimation { | ||
1361 | 176 | duration: UbuntuAnimation.SlowDuration | ||
1362 | 177 | easing: UbuntuAnimation.StandardEasing | ||
1363 | 178 | }} | ||
1364 | 179 | } | ||
1365 | 180 | |||
1366 | 181 | // Failed image. | ||
1367 | 182 | CircularSegment { | ||
1368 | 183 | id: imageFailed | ||
1369 | 184 | objectName: "fingerprintFailedVisual" | ||
1370 | 185 | opacity: 0 | ||
1371 | 186 | color: "#ED3146" | ||
1372 | 187 | width: directionContainer.width - units.dp(3) | ||
1373 | 188 | |||
1374 | 189 | anchors.centerIn: parent | ||
1375 | 190 | |||
1376 | 191 | function start () { | ||
1377 | 192 | failAngstopAnim.start(); | ||
1378 | 193 | failThichAnim.start(); | ||
1379 | 194 | } | ||
1380 | 195 | |||
1381 | 196 | NumberAnimation on angleStop { | ||
1382 | 197 | id: failAngstopAnim | ||
1383 | 198 | running: false | ||
1384 | 199 | from: 0 | ||
1385 | 200 | to: 360 | ||
1386 | 201 | duration: UbuntuAnimation.SlowDuration | ||
1387 | 202 | easing: UbuntuAnimation.StandardEasing | ||
1388 | 203 | } | ||
1389 | 204 | |||
1390 | 205 | NumberAnimation on thickness { | ||
1391 | 206 | id: failThichAnim | ||
1392 | 207 | running: false | ||
1393 | 208 | from: 0 | ||
1394 | 209 | to: units.dp(3) | ||
1395 | 210 | duration: UbuntuAnimation.SlowDuration | ||
1396 | 211 | easing: UbuntuAnimation.StandardEasing | ||
1397 | 212 | } | ||
1398 | 213 | |||
1399 | 214 | Icon { | ||
1400 | 215 | name: "close" | ||
1401 | 216 | color: "#ED3146" | ||
1402 | 217 | width: units.gu(18) | ||
1403 | 218 | anchors.centerIn: parent | ||
1404 | 219 | } | ||
1405 | 220 | |||
1406 | 221 | Behavior on opacity { UbuntuNumberAnimation { | ||
1407 | 222 | duration: UbuntuAnimation.SlowDuration | ||
1408 | 223 | easing: UbuntuAnimation.StandardEasing | ||
1409 | 224 | }} | ||
1410 | 225 | } | ||
1411 | 226 | |||
1412 | 227 | // Done image. | ||
1413 | 228 | CircularSegment { | ||
1414 | 229 | id: imageDone | ||
1415 | 230 | objectName: "fingerprintDoneVisual" | ||
1416 | 231 | opacity: 0 | ||
1417 | 232 | width: directionContainer.width - units.dp(3) | ||
1418 | 233 | |||
1419 | 234 | anchors.centerIn: parent | ||
1420 | 235 | |||
1421 | 236 | function start () { | ||
1422 | 237 | angstopAnim.start(); | ||
1423 | 238 | thickAnim.start(); | ||
1424 | 239 | } | ||
1425 | 240 | |||
1426 | 241 | NumberAnimation on angleStop { | ||
1427 | 242 | id: angstopAnim | ||
1428 | 243 | running: false | ||
1429 | 244 | from: 0 | ||
1430 | 245 | to: 360 | ||
1431 | 246 | duration: UbuntuAnimation.SlowDuration | ||
1432 | 247 | easing: UbuntuAnimation.StandardEasing | ||
1433 | 248 | } | ||
1434 | 249 | |||
1435 | 250 | NumberAnimation on thickness { | ||
1436 | 251 | id: thickAnim | ||
1437 | 252 | running: false | ||
1438 | 253 | from: 0 | ||
1439 | 254 | to: units.dp(3) | ||
1440 | 255 | duration: UbuntuAnimation.SlowDuration | ||
1441 | 256 | easing: UbuntuAnimation.StandardEasing | ||
1442 | 257 | } | ||
1443 | 258 | |||
1444 | 259 | Icon { | ||
1445 | 260 | name: "tick" | ||
1446 | 261 | color: "#3EB34F" | ||
1447 | 262 | width: units.gu(18) | ||
1448 | 263 | anchors.centerIn: parent | ||
1449 | 264 | } | ||
1450 | 265 | |||
1451 | 266 | Behavior on opacity { UbuntuNumberAnimation { | ||
1452 | 267 | duration: UbuntuAnimation.SlowDuration | ||
1453 | 268 | easing: UbuntuAnimation.StandardEasing | ||
1454 | 269 | }} | ||
1455 | 270 | } | ||
1456 | 271 | |||
1457 | 272 | DirectionVisual { | ||
1458 | 273 | id: directionContainer | ||
1459 | 274 | objectName: "fingerprintDirectionVisual" | ||
1460 | 275 | anchors.centerIn: parent | ||
1461 | 276 | |||
1462 | 277 | width: Math.sqrt( | ||
1463 | 278 | imageContainer.width*imageContainer.width | ||
1464 | 279 | + imageContainer.height*imageContainer.height | ||
1465 | 280 | ) | ||
1466 | 281 | height: width | ||
1467 | 282 | } | ||
1468 | 283 | } | ||
1469 | 284 | } | ||
1470 | 285 | |||
1471 | 286 | StatusLabel { | ||
1472 | 287 | id: statusLabel | ||
1473 | 288 | anchors { | ||
1474 | 289 | left: parent.left | ||
1475 | 290 | leftMargin: units.gu(2.9) | ||
1476 | 291 | right: parent.right | ||
1477 | 292 | rightMargin: units.gu(2.9) | ||
1478 | 293 | top: parent.top | ||
1479 | 294 | topMargin: units.gu(5) | ||
1480 | 295 | } | ||
1481 | 296 | initialText: i18n.dtr("ubuntu-settings-components", | ||
1482 | 297 | "Place your finger on the home button.") | ||
1483 | 298 | objectName: "fingerprintStatusLabel" | ||
1484 | 299 | } | ||
1485 | 300 | |||
1486 | 301 | |||
1487 | 302 | Label { | ||
1488 | 303 | id: progressLabel | ||
1489 | 304 | objectName: "fingerprintProgressLabel" | ||
1490 | 305 | property int progress: 0 | ||
1491 | 306 | anchors { | ||
1492 | 307 | top: fingerprintBox.bottom | ||
1493 | 308 | topMargin: units.gu(1.5) | ||
1494 | 309 | horizontalCenter: parent.horizontalCenter | ||
1495 | 310 | } | ||
1496 | 311 | text: i18n.dtr("ubuntu-settings-components", "%1%").arg((progress).toFixed()); | ||
1497 | 312 | opacity: 0 | ||
1498 | 313 | horizontalAlignment: Text.AlignHCenter | ||
1499 | 314 | fontSize: "large" | ||
1500 | 315 | color: theme.palette.normal.backgroundTertiaryText | ||
1501 | 316 | |||
1502 | 317 | Behavior on opacity { UbuntuNumberAnimation {} } | ||
1503 | 318 | Behavior on progress { | ||
1504 | 319 | NumberAnimation { | ||
1505 | 320 | duration: UbuntuAnimation.SlowDuration | ||
1506 | 321 | easing: UbuntuAnimation.StandardEasing | ||
1507 | 322 | } | ||
1508 | 323 | } | ||
1509 | 324 | } | ||
1510 | 325 | |||
1511 | 326 | Rectangle { | ||
1512 | 327 | id: actions | ||
1513 | 328 | |||
1514 | 329 | anchors { | ||
1515 | 330 | left: parent.left | ||
1516 | 331 | right: parent.right | ||
1517 | 332 | bottom: parent.bottom | ||
1518 | 333 | } | ||
1519 | 334 | |||
1520 | 335 | // Color and height values are copied from the Wizard. | ||
1521 | 336 | color: "#f5f5f5" | ||
1522 | 337 | height: units.gu(5) | ||
1523 | 338 | |||
1524 | 339 | AbstractButton { | ||
1525 | 340 | id: cancelButton | ||
1526 | 341 | property alias text: cancelButtonText.text | ||
1527 | 342 | objectName: "fingerprintSetupCancelButton" | ||
1528 | 343 | anchors { | ||
1529 | 344 | left: parent.left | ||
1530 | 345 | leftMargin: units.gu(3) | ||
1531 | 346 | verticalCenter: parent.verticalCenter | ||
1532 | 347 | } | ||
1533 | 348 | height: parent.height | ||
1534 | 349 | width: units.gu(10) | ||
1535 | 350 | onClicked: { | ||
1536 | 351 | root.cancel(); | ||
1537 | 352 | pageStack.pop(); | ||
1538 | 353 | } | ||
1539 | 354 | |||
1540 | 355 | Label { | ||
1541 | 356 | id: cancelButtonText | ||
1542 | 357 | anchors.verticalCenter: parent.verticalCenter | ||
1543 | 358 | text: i18n.dtr("ubuntu-settings-components", "Cancel") | ||
1544 | 359 | } | ||
1545 | 360 | } | ||
1546 | 361 | |||
1547 | 362 | AbstractButton { | ||
1548 | 363 | id: doneButton | ||
1549 | 364 | property alias text: doneButtonText.text | ||
1550 | 365 | objectName: "fingerprintSetupDoneButton" | ||
1551 | 366 | anchors { | ||
1552 | 367 | right: parent.right | ||
1553 | 368 | rightMargin: units.gu(3) | ||
1554 | 369 | verticalCenter: parent.verticalCenter | ||
1555 | 370 | } | ||
1556 | 371 | enabled: false | ||
1557 | 372 | height: parent.height | ||
1558 | 373 | width: units.gu(10) | ||
1559 | 374 | onClicked: pageStack.pop() | ||
1560 | 375 | |||
1561 | 376 | Label { | ||
1562 | 377 | id: doneButtonText | ||
1563 | 378 | anchors { | ||
1564 | 379 | verticalCenter: parent.verticalCenter | ||
1565 | 380 | right: parent.right | ||
1566 | 381 | } | ||
1567 | 382 | font.bold: parent.enabled | ||
1568 | 383 | text: i18n.dtr("ubuntu-settings-components", "Next") | ||
1569 | 384 | } | ||
1570 | 385 | } | ||
1571 | 386 | } | ||
1572 | 387 | } | ||
1573 | 388 | } | ||
1574 | 0 | 389 | ||
1575 | === added file 'plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml' | |||
1576 | --- plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml 1970-01-01 00:00:00 +0000 | |||
1577 | +++ plugins/Ubuntu/Settings/Fingerprint/StatusLabel.qml 2016-06-15 10:46:42 +0000 | |||
1578 | @@ -0,0 +1,84 @@ | |||
1579 | 1 | /* | ||
1580 | 2 | * Copyright 2016 Canonical Ltd. | ||
1581 | 3 | * | ||
1582 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1583 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1584 | 6 | * the Free Software Foundation; version 3. | ||
1585 | 7 | * | ||
1586 | 8 | * This program is distributed in the hope that it will be useful, | ||
1587 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1588 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1589 | 11 | * GNU Lesser General Public License for more details. | ||
1590 | 12 | * | ||
1591 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1592 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1593 | 15 | * | ||
1594 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
1595 | 17 | */ | ||
1596 | 18 | |||
1597 | 19 | import QtQuick 2.4 | ||
1598 | 20 | import Ubuntu.Components 1.3 | ||
1599 | 21 | |||
1600 | 22 | Item { | ||
1601 | 23 | id: root | ||
1602 | 24 | |||
1603 | 25 | property string initialText | ||
1604 | 26 | property int origX: 0 | ||
1605 | 27 | readonly property alias text: label.text | ||
1606 | 28 | |||
1607 | 29 | signal slideStarted() | ||
1608 | 30 | signal slideCompleted() | ||
1609 | 31 | |||
1610 | 32 | Component.onCompleted: origX = label.x | ||
1611 | 33 | |||
1612 | 34 | function setText(text, noAnimation) { | ||
1613 | 35 | if (noAnimation === true) { | ||
1614 | 36 | label.text = text; | ||
1615 | 37 | return; | ||
1616 | 38 | } | ||
1617 | 39 | |||
1618 | 40 | function outStoppedHandler () { | ||
1619 | 41 | label.text = text; | ||
1620 | 42 | label.x = units.gu(50) | ||
1621 | 43 | inAnim.start(); | ||
1622 | 44 | outAnim.stopped.disconnect(outStoppedHandler); | ||
1623 | 45 | } | ||
1624 | 46 | outAnim.stopped.connect(outStoppedHandler); | ||
1625 | 47 | outAnim.start(); | ||
1626 | 48 | } | ||
1627 | 49 | |||
1628 | 50 | Label { | ||
1629 | 51 | id: label | ||
1630 | 52 | |||
1631 | 53 | font.pixelSize: units.gu(3.3) | ||
1632 | 54 | horizontalAlignment: Text.AlignHCenter | ||
1633 | 55 | height: units.gu(4) | ||
1634 | 56 | text: initialText | ||
1635 | 57 | width: parent.width | ||
1636 | 58 | wrapMode: Text.WordWrap | ||
1637 | 59 | } | ||
1638 | 60 | |||
1639 | 61 | NumberAnimation { | ||
1640 | 62 | id: outAnim | ||
1641 | 63 | |||
1642 | 64 | alwaysRunToEnd: true | ||
1643 | 65 | duration: UbuntuAnimation.FastDuration | ||
1644 | 66 | easing: UbuntuAnimation.StandardEasing | ||
1645 | 67 | onStarted: root.slideStarted() | ||
1646 | 68 | property: "x" | ||
1647 | 69 | target: label | ||
1648 | 70 | to: -units.gu(50) | ||
1649 | 71 | } | ||
1650 | 72 | |||
1651 | 73 | NumberAnimation { | ||
1652 | 74 | id: inAnim | ||
1653 | 75 | |||
1654 | 76 | alwaysRunToEnd: true | ||
1655 | 77 | duration: UbuntuAnimation.FastDuration | ||
1656 | 78 | easing: UbuntuAnimation.StandardEasing | ||
1657 | 79 | onStopped: root.slideCompleted() | ||
1658 | 80 | property: "x" | ||
1659 | 81 | target: label | ||
1660 | 82 | to: root.origX | ||
1661 | 83 | } | ||
1662 | 84 | } | ||
1663 | 0 | 85 | ||
1664 | === added directory 'plugins/Ubuntu/Settings/Fingerprint/assets' | |||
1665 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets.qrc' | |||
1666 | --- plugins/Ubuntu/Settings/Fingerprint/assets.qrc 1970-01-01 00:00:00 +0000 | |||
1667 | +++ plugins/Ubuntu/Settings/Fingerprint/assets.qrc 2016-06-15 10:46:42 +0000 | |||
1668 | @@ -0,0 +1,11 @@ | |||
1669 | 1 | <!DOCTYPE RCC><RCC version="1.0"> | ||
1670 | 2 | <qresource> | ||
1671 | 3 | <file>assets/shape-up@27.png</file> | ||
1672 | 4 | <file>assets/shape-up@27.sci</file> | ||
1673 | 5 | <file>assets/shape-down@27.png</file> | ||
1674 | 6 | <file>assets/shape-down@27.sci</file> | ||
1675 | 7 | |||
1676 | 8 | <file>assets/fingerprint_segmented@27.png</file> | ||
1677 | 9 | <file>assets/fingerprint_boxes.json</file> | ||
1678 | 10 | </qresource> | ||
1679 | 11 | </RCC> | ||
1680 | 0 | 12 | ||
1681 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json' | |||
1682 | --- plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json 1970-01-01 00:00:00 +0000 | |||
1683 | +++ plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_boxes.json 2016-06-15 10:46:42 +0000 | |||
1684 | @@ -0,0 +1,1 @@ | |||
1685 | 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} | ||
1686 | 0 | 2 | ||
1687 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets/fingerprint_segmented@27.png' | |||
1688 | 1 | Binary 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 | 3 | Binary 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 |
1689 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.png' | |||
1690 | 2 | Binary 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 | 4 | Binary 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 |
1691 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci' | |||
1692 | --- plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci 1970-01-01 00:00:00 +0000 | |||
1693 | +++ plugins/Ubuntu/Settings/Fingerprint/assets/shape-down@27.sci 2016-06-15 10:46:42 +0000 | |||
1694 | @@ -0,0 +1,7 @@ | |||
1695 | 1 | border.top: 222 | ||
1696 | 2 | border.right: 222 | ||
1697 | 3 | border.bottom: 222 | ||
1698 | 4 | border.left: 222 | ||
1699 | 5 | horizontalTileMode: Round | ||
1700 | 6 | verticalTileMode: Round | ||
1701 | 7 | source: "shape-down@27.png" | ||
1702 | 0 | 8 | ||
1703 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.png' | |||
1704 | 1 | Binary 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 | 9 | Binary 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 |
1705 | === added file 'plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci' | |||
1706 | --- plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci 1970-01-01 00:00:00 +0000 | |||
1707 | +++ plugins/Ubuntu/Settings/Fingerprint/assets/shape-up@27.sci 2016-06-15 10:46:42 +0000 | |||
1708 | @@ -0,0 +1,7 @@ | |||
1709 | 1 | border.top: 260 | ||
1710 | 2 | border.right: 260 | ||
1711 | 3 | border.bottom: 260 | ||
1712 | 4 | border.left: 260 | ||
1713 | 5 | horizontalTileMode: Round | ||
1714 | 6 | verticalTileMode: Round | ||
1715 | 7 | source: "shape-up@27.png" | ||
1716 | 0 | 8 | ||
1717 | === added file 'plugins/Ubuntu/Settings/Fingerprint/plugin.cpp' | |||
1718 | --- plugins/Ubuntu/Settings/Fingerprint/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
1719 | +++ plugins/Ubuntu/Settings/Fingerprint/plugin.cpp 2016-06-15 10:46:42 +0000 | |||
1720 | @@ -0,0 +1,35 @@ | |||
1721 | 1 | /* | ||
1722 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1723 | 3 | * | ||
1724 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1725 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1726 | 6 | * the Free Software Foundation; version 3. | ||
1727 | 7 | * | ||
1728 | 8 | * This program is distributed in the hope that it will be useful, | ||
1729 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1730 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1731 | 11 | * GNU Lesser General Public License for more details. | ||
1732 | 12 | * | ||
1733 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1734 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1735 | 15 | */ | ||
1736 | 16 | |||
1737 | 17 | #include "plugin.h" | ||
1738 | 18 | #include "ubuntusettingsfingerprint.h" | ||
1739 | 19 | |||
1740 | 20 | #include <QtQml/qqml.h> | ||
1741 | 21 | |||
1742 | 22 | static QObject* fp_singletonprovider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1743 | 23 | { | ||
1744 | 24 | Q_UNUSED(engine) | ||
1745 | 25 | Q_UNUSED(scriptEngine) | ||
1746 | 26 | |||
1747 | 27 | return new UbuntuSettingsFingerprint; | ||
1748 | 28 | } | ||
1749 | 29 | |||
1750 | 30 | void UbuntuSettingsFingerprintPlugin::registerTypes(const char *uri) | ||
1751 | 31 | { | ||
1752 | 32 | qmlRegisterSingletonType<UbuntuSettingsFingerprint>( | ||
1753 | 33 | uri, 0, 1, "UbuntuSettingsFingerprint", fp_singletonprovider | ||
1754 | 34 | ); | ||
1755 | 35 | } | ||
1756 | 0 | 36 | ||
1757 | === added file 'plugins/Ubuntu/Settings/Fingerprint/plugin.h' | |||
1758 | --- plugins/Ubuntu/Settings/Fingerprint/plugin.h 1970-01-01 00:00:00 +0000 | |||
1759 | +++ plugins/Ubuntu/Settings/Fingerprint/plugin.h 2016-06-15 10:46:42 +0000 | |||
1760 | @@ -0,0 +1,30 @@ | |||
1761 | 1 | /* | ||
1762 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1763 | 3 | * | ||
1764 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1765 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1766 | 6 | * the Free Software Foundation; version 3. | ||
1767 | 7 | * | ||
1768 | 8 | * This program is distributed in the hope that it will be useful, | ||
1769 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1770 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1771 | 11 | * GNU Lesser General Public License for more details. | ||
1772 | 12 | * | ||
1773 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1774 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1775 | 15 | */ | ||
1776 | 16 | |||
1777 | 17 | #ifndef UBUNTUSETTINGSFINGERPRINT_PLUGIN_H | ||
1778 | 18 | #define UBUNTUSETTINGSFINGERPRINT_PLUGIN_H | ||
1779 | 19 | |||
1780 | 20 | #include <QtQml/QQmlExtensionPlugin> | ||
1781 | 21 | |||
1782 | 22 | class UbuntuSettingsFingerprintPlugin : public QQmlExtensionPlugin | ||
1783 | 23 | { | ||
1784 | 24 | Q_OBJECT | ||
1785 | 25 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
1786 | 26 | public: | ||
1787 | 27 | void registerTypes(const char *uri); | ||
1788 | 28 | }; | ||
1789 | 29 | |||
1790 | 30 | #endif // UBUNTUSETTINGSFINGERPRINT_PLUGIN_H | ||
1791 | 0 | 31 | ||
1792 | === added file 'plugins/Ubuntu/Settings/Fingerprint/qmldir' | |||
1793 | --- plugins/Ubuntu/Settings/Fingerprint/qmldir 1970-01-01 00:00:00 +0000 | |||
1794 | +++ plugins/Ubuntu/Settings/Fingerprint/qmldir 2016-06-15 10:46:42 +0000 | |||
1795 | @@ -0,0 +1,7 @@ | |||
1796 | 1 | module Ubuntu.Settings.Fingerprint | ||
1797 | 2 | plugin UbuntuSettingsFingerprintQml | ||
1798 | 3 | |||
1799 | 4 | Fingerprint 0.1 Fingerprint.qml | ||
1800 | 5 | Fingerprints 0.1 Fingerprints.qml | ||
1801 | 6 | FingerprintVisual 0.1 FingerprintVisual.qml | ||
1802 | 7 | Setup 0.1 Setup.qml | ||
1803 | 0 | 8 | ||
1804 | === added file 'plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp' | |||
1805 | --- plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp 1970-01-01 00:00:00 +0000 | |||
1806 | +++ plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.cpp 2016-06-15 10:46:42 +0000 | |||
1807 | @@ -0,0 +1,39 @@ | |||
1808 | 1 | /* | ||
1809 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1810 | 3 | * | ||
1811 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1812 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1813 | 6 | * the Free Software Foundation; version 3. | ||
1814 | 7 | * | ||
1815 | 8 | * This program is distributed in the hope that it will be useful, | ||
1816 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1817 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1818 | 11 | * GNU Lesser General Public License for more details. | ||
1819 | 12 | * | ||
1820 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1821 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1822 | 15 | * | ||
1823 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
1824 | 17 | */ | ||
1825 | 18 | #include <unistd.h> | ||
1826 | 19 | #include <sys/types.h> | ||
1827 | 20 | #include <QProcessEnvironment> | ||
1828 | 21 | |||
1829 | 22 | #include "ubuntusettingsfingerprint.h" | ||
1830 | 23 | |||
1831 | 24 | UbuntuSettingsFingerprint::UbuntuSettingsFingerprint(QObject* parent) | ||
1832 | 25 | : QObject(parent) | ||
1833 | 26 | { | ||
1834 | 27 | } | ||
1835 | 28 | |||
1836 | 29 | qlonglong UbuntuSettingsFingerprint::uid() const | ||
1837 | 30 | { | ||
1838 | 31 | return qlonglong(getuid()); | ||
1839 | 32 | } | ||
1840 | 33 | |||
1841 | 34 | bool UbuntuSettingsFingerprint::debug() const | ||
1842 | 35 | { | ||
1843 | 36 | return QProcessEnvironment::systemEnvironment().contains( | ||
1844 | 37 | QLatin1String("USC_FINGERPRINT_DEBUG") | ||
1845 | 38 | ); | ||
1846 | 39 | } | ||
1847 | 0 | 40 | ||
1848 | === added file 'plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h' | |||
1849 | --- plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h 1970-01-01 00:00:00 +0000 | |||
1850 | +++ plugins/Ubuntu/Settings/Fingerprint/ubuntusettingsfingerprint.h 2016-06-15 10:46:42 +0000 | |||
1851 | @@ -0,0 +1,37 @@ | |||
1852 | 1 | /* | ||
1853 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1854 | 3 | * | ||
1855 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1856 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1857 | 6 | * the Free Software Foundation; version 3. | ||
1858 | 7 | * | ||
1859 | 8 | * This program is distributed in the hope that it will be useful, | ||
1860 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1861 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1862 | 11 | * GNU Lesser General Public License for more details. | ||
1863 | 12 | * | ||
1864 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1865 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1866 | 15 | * | ||
1867 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
1868 | 17 | */ | ||
1869 | 18 | |||
1870 | 19 | #ifndef UBUNTUSETTINGSFINGERPRINT_H | ||
1871 | 20 | #define UBUNTUSETTINGSFINGERPRINT_H | ||
1872 | 21 | |||
1873 | 22 | #include <QObject> | ||
1874 | 23 | |||
1875 | 24 | class UbuntuSettingsFingerprint : public QObject | ||
1876 | 25 | { | ||
1877 | 26 | Q_OBJECT | ||
1878 | 27 | public: | ||
1879 | 28 | explicit UbuntuSettingsFingerprint(QObject* parent = 0); | ||
1880 | 29 | |||
1881 | 30 | Q_PROPERTY(qlonglong uid READ uid CONSTANT) | ||
1882 | 31 | Q_PROPERTY(bool debug READ debug CONSTANT) | ||
1883 | 32 | |||
1884 | 33 | qlonglong uid() const; | ||
1885 | 34 | bool debug() const; | ||
1886 | 35 | }; | ||
1887 | 36 | |||
1888 | 37 | #endif // UBUNTUSETTINGSFINGERPRINT_H | ||
1889 | 0 | 38 | ||
1890 | === added directory 'plugins/Ubuntu/Settings/Fingerprint/utils' | |||
1891 | === added file 'plugins/Ubuntu/Settings/Fingerprint/utils/segment.py' | |||
1892 | --- plugins/Ubuntu/Settings/Fingerprint/utils/segment.py 1970-01-01 00:00:00 +0000 | |||
1893 | +++ plugins/Ubuntu/Settings/Fingerprint/utils/segment.py 2016-06-15 10:46:42 +0000 | |||
1894 | @@ -0,0 +1,84 @@ | |||
1895 | 1 | #!/usr/bin/python2 | ||
1896 | 2 | """ | ||
1897 | 3 | * Copyright 2016 Canonical Ltd. | ||
1898 | 4 | * | ||
1899 | 5 | * This program is free software; you can redistribute it and/or modify | ||
1900 | 6 | * it under the terms of the GNU Lesser General Public License as published by | ||
1901 | 7 | * the Free Software Foundation; version 3. | ||
1902 | 8 | * | ||
1903 | 9 | * This program is distributed in the hope that it will be useful, | ||
1904 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1905 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1906 | 12 | * GNU Lesser General Public License for more details. | ||
1907 | 13 | * | ||
1908 | 14 | * You should have received a copy of the GNU Lesser General Public License | ||
1909 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1910 | 16 | * | ||
1911 | 17 | * Authored by Florian Boucault <florian.boucault@canonical.com> | ||
1912 | 18 | */ | ||
1913 | 19 | """ | ||
1914 | 20 | |||
1915 | 21 | import os.path | ||
1916 | 22 | import argparse | ||
1917 | 23 | import json | ||
1918 | 24 | import cv2 | ||
1919 | 25 | |||
1920 | 26 | parser = argparse.ArgumentParser( | ||
1921 | 27 | description='Generates segmented version of img and extracts bbs.' | ||
1922 | 28 | ) | ||
1923 | 29 | parser.add_argument('input_image', type=str, | ||
1924 | 30 | help='path to the image to segment') | ||
1925 | 31 | args = parser.parse_args() | ||
1926 | 32 | |||
1927 | 33 | input_image = os.path.abspath(args.input_image) | ||
1928 | 34 | print("Segmenting %s..." % input_image) | ||
1929 | 35 | filename, _ = os.path.splitext(os.path.basename(input_image)) | ||
1930 | 36 | split = filename.split('@') | ||
1931 | 37 | if len(split) != 1: | ||
1932 | 38 | output_image = "%s_segmented@%s.png" % (split[0], split[1]) | ||
1933 | 39 | output_boxes = "%s_boxes.json" % split[0] | ||
1934 | 40 | else: | ||
1935 | 41 | output_image = "%s_segmented.png" % filename | ||
1936 | 42 | output_boxes = "%s_boxes.json" % filename | ||
1937 | 43 | |||
1938 | 44 | img = cv2.imread(input_image, -1) | ||
1939 | 45 | img_boxes = img.copy() | ||
1940 | 46 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | ||
1941 | 47 | ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY) | ||
1942 | 48 | contours, hierarchy = cv2.findContours( | ||
1943 | 49 | thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE | ||
1944 | 50 | ) | ||
1945 | 51 | |||
1946 | 52 | print("Detected %d segments." % len(contours)) | ||
1947 | 53 | |||
1948 | 54 | bounding_boxes = [] | ||
1949 | 55 | for index, contour in enumerate(contours): | ||
1950 | 56 | x, y, w, h = cv2.boundingRect(contour) | ||
1951 | 57 | bounding_boxes.append((x, y, w, h)) | ||
1952 | 58 | # print(x, y, w, h) | ||
1953 | 59 | cv2.rectangle(img_boxes, | ||
1954 | 60 | (x, y), | ||
1955 | 61 | (x + w, y + h), | ||
1956 | 62 | (255, 20, 20, 255), 1) | ||
1957 | 63 | cv2.drawContours(thresh, contours, index, (index + 1), | ||
1958 | 64 | cv2.cv.CV_FILLED) | ||
1959 | 65 | cv2.drawContours(thresh, contours, index, (index + 1), 2) | ||
1960 | 66 | |||
1961 | 67 | b, g, r, a = cv2.split(img) | ||
1962 | 68 | img = cv2.merge([a, g, thresh]) | ||
1963 | 69 | |||
1964 | 70 | cv2.imwrite(output_image, img) | ||
1965 | 71 | print("Written segmented version of '%s' to '%s'" % ( | ||
1966 | 72 | args.input_image, output_image) | ||
1967 | 73 | ) | ||
1968 | 74 | |||
1969 | 75 | description = {"width": img.shape[1], | ||
1970 | 76 | "height": img.shape[0], | ||
1971 | 77 | "boxes": bounding_boxes} | ||
1972 | 78 | with open(output_boxes, 'w') as outfile: | ||
1973 | 79 | json.dump(description, outfile) | ||
1974 | 80 | print("Written bounding boxes to '%s'" % output_boxes) | ||
1975 | 81 | |||
1976 | 82 | cv2.imshow('image', img_boxes) | ||
1977 | 83 | cv2.waitKey(0) | ||
1978 | 84 | cv2.destroyAllWindows() | ||
1979 | 0 | 85 | ||
1980 | === modified file 'po/ubuntu-settings-components.pot' | |||
1981 | --- po/ubuntu-settings-components.pot 2016-05-19 17:52:21 +0000 | |||
1982 | +++ po/ubuntu-settings-components.pot 2016-06-15 10:46:42 +0000 | |||
1983 | @@ -8,7 +8,7 @@ | |||
1984 | 8 | msgstr "" | 8 | msgstr "" |
1985 | 9 | "Project-Id-Version: ubuntu-settings-components\n" | 9 | "Project-Id-Version: ubuntu-settings-components\n" |
1986 | 10 | "Report-Msgid-Bugs-To: \n" | 10 | "Report-Msgid-Bugs-To: \n" |
1988 | 11 | "POT-Creation-Date: 2016-04-25 15:44+0200\n" | 11 | "POT-Creation-Date: 2016-06-15 12:46+0200\n" |
1989 | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
1990 | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
1991 | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
1992 | @@ -21,6 +21,105 @@ | |||
1993 | 21 | msgid "Quick reply with:" | 21 | msgid "Quick reply with:" |
1994 | 22 | msgstr "" | 22 | msgstr "" |
1995 | 23 | 23 | ||
1996 | 24 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:80 | ||
1997 | 25 | msgid "Fingerprint Name" | ||
1998 | 26 | msgstr "" | ||
1999 | 27 | |||
2000 | 28 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:107 | ||
2001 | 29 | msgid "Delete Fingerprint" | ||
2002 | 30 | msgstr "" | ||
2003 | 31 | |||
2004 | 32 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:124 | ||
2005 | 33 | msgid "Sorry, the fingerprint could not be deleted." | ||
2006 | 34 | msgstr "" | ||
2007 | 35 | |||
2008 | 36 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprint.qml:129 | ||
2009 | 37 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:338 | ||
2010 | 38 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:138 | ||
2011 | 39 | #: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:148 | ||
2012 | 40 | msgid "OK" | ||
2013 | 41 | msgstr "" | ||
2014 | 42 | |||
2015 | 43 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:32 | ||
2016 | 44 | msgid "Fingerprint ID" | ||
2017 | 45 | msgstr "" | ||
2018 | 46 | |||
2019 | 47 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:93 | ||
2020 | 48 | #, qt-format | ||
2021 | 49 | msgid "Finger %1" | ||
2022 | 50 | msgstr "" | ||
2023 | 51 | |||
2024 | 52 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:188 | ||
2025 | 53 | msgid "Passcode required" | ||
2026 | 54 | msgstr "" | ||
2027 | 55 | |||
2028 | 56 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:192 | ||
2029 | 57 | msgid "You must set a passcode to use fingerprint ID" | ||
2030 | 58 | msgstr "" | ||
2031 | 59 | |||
2032 | 60 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:199 | ||
2033 | 61 | msgid "Set Passcode…" | ||
2034 | 62 | msgstr "" | ||
2035 | 63 | |||
2036 | 64 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:275 | ||
2037 | 65 | msgid "Add fingerprint" | ||
2038 | 66 | msgstr "" | ||
2039 | 67 | |||
2040 | 68 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:288 | ||
2041 | 69 | msgid "Remove All…" | ||
2042 | 70 | msgstr "" | ||
2043 | 71 | |||
2044 | 72 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:303 | ||
2045 | 73 | msgid "Are you sure you want to forget all stored fingerprints?" | ||
2046 | 74 | msgstr "" | ||
2047 | 75 | |||
2048 | 76 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:312 | ||
2049 | 77 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:358 | ||
2050 | 78 | #: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:161 | ||
2051 | 79 | #: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:135 | ||
2052 | 80 | #: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:104 | ||
2053 | 81 | msgid "Cancel" | ||
2054 | 82 | msgstr "" | ||
2055 | 83 | |||
2056 | 84 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:319 | ||
2057 | 85 | #: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:84 | ||
2058 | 86 | msgid "Remove" | ||
2059 | 87 | msgstr "" | ||
2060 | 88 | |||
2061 | 89 | #: plugins/Ubuntu/Settings/Fingerprint/Fingerprints.qml:333 | ||
2062 | 90 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:103 | ||
2063 | 91 | msgid "Sorry, the reader doesn’t seem to be working." | ||
2064 | 92 | msgstr "" | ||
2065 | 93 | |||
2066 | 94 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:61 | ||
2067 | 95 | msgid "Lift and press your finger again." | ||
2068 | 96 | msgstr "" | ||
2069 | 97 | |||
2070 | 98 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:78 | ||
2071 | 99 | msgid "Keep your finger on the reader for longer." | ||
2072 | 100 | msgstr "" | ||
2073 | 101 | |||
2074 | 102 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:94 | ||
2075 | 103 | msgid "Back" | ||
2076 | 104 | msgstr "" | ||
2077 | 105 | |||
2078 | 106 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:131 | ||
2079 | 107 | msgid "All done!" | ||
2080 | 108 | msgstr "" | ||
2081 | 109 | |||
2082 | 110 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:297 | ||
2083 | 111 | msgid "Place your finger on the home button." | ||
2084 | 112 | msgstr "" | ||
2085 | 113 | |||
2086 | 114 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:311 | ||
2087 | 115 | #, qt-format | ||
2088 | 116 | msgid "%1%" | ||
2089 | 117 | msgstr "" | ||
2090 | 118 | |||
2091 | 119 | #: plugins/Ubuntu/Settings/Fingerprint/Setup.qml:383 | ||
2092 | 120 | msgid "Next" | ||
2093 | 121 | msgstr "" | ||
2094 | 122 | |||
2095 | 24 | #: plugins/Ubuntu/Settings/Menus/CalendarMenu.qml:57 | 123 | #: plugins/Ubuntu/Settings/Menus/CalendarMenu.qml:57 |
2096 | 25 | #, qt-format | 124 | #, qt-format |
2097 | 26 | msgctxt "%1=month name, %2=4-digit year" | 125 | msgctxt "%1=month name, %2=4-digit year" |
2098 | @@ -48,12 +147,6 @@ | |||
2099 | 48 | msgid "Message" | 147 | msgid "Message" |
2100 | 49 | msgstr "" | 148 | msgstr "" |
2101 | 50 | 149 | ||
2102 | 51 | #: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:161 | ||
2103 | 52 | #: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:134 | ||
2104 | 53 | #: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:104 | ||
2105 | 54 | msgid "Cancel" | ||
2106 | 55 | msgstr "" | ||
2107 | 56 | |||
2108 | 57 | #: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:170 | 150 | #: plugins/Ubuntu/Settings/Vpn/DialogFile.qml:170 |
2109 | 58 | msgid "Accept" | 151 | msgid "Accept" |
2110 | 59 | msgstr "" | 152 | msgstr "" |
2111 | @@ -358,14 +451,10 @@ | |||
2112 | 358 | msgid "Your Wi-Fi/mobile provider can track your use of any other services. " | 451 | msgid "Your Wi-Fi/mobile provider can track your use of any other services. " |
2113 | 359 | msgstr "" | 452 | msgstr "" |
2114 | 360 | 453 | ||
2116 | 361 | #: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:26 | 454 | #: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:25 |
2117 | 362 | msgid "Set up VPN" | 455 | msgid "Set up VPN" |
2118 | 363 | msgstr "" | 456 | msgstr "" |
2119 | 364 | 457 | ||
2120 | 365 | #: plugins/Ubuntu/Settings/Vpn/VpnEditor.qml:147 | ||
2121 | 366 | msgid "OK" | ||
2122 | 367 | msgstr "" | ||
2123 | 368 | |||
2124 | 369 | #: plugins/Ubuntu/Settings/Vpn/VpnList.qml:62 | 458 | #: plugins/Ubuntu/Settings/Vpn/VpnList.qml:62 |
2125 | 370 | msgid "Delete configuration" | 459 | msgid "Delete configuration" |
2126 | 371 | msgstr "" | 460 | msgstr "" |
2127 | @@ -380,10 +469,6 @@ | |||
2128 | 380 | msgid "VPN" | 469 | msgid "VPN" |
2129 | 381 | msgstr "" | 470 | msgstr "" |
2130 | 382 | 471 | ||
2131 | 383 | #: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:84 | ||
2132 | 384 | msgid "Remove" | ||
2133 | 385 | msgstr "" | ||
2134 | 386 | |||
2135 | 387 | #: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:96 | 472 | #: plugins/Ubuntu/Settings/Vpn/VpnPreviewDialog.qml:96 |
2136 | 388 | msgid "Change" | 473 | msgid "Change" |
2137 | 389 | msgstr "" | 474 | msgstr "" |
2138 | 390 | 475 | ||
2139 | === modified file 'tests/qmltests/CMakeLists.txt' | |||
2140 | --- tests/qmltests/CMakeLists.txt 2016-03-09 14:04:14 +0000 | |||
2141 | +++ tests/qmltests/CMakeLists.txt 2016-06-15 10:46:42 +0000 | |||
2142 | @@ -1,6 +1,8 @@ | |||
2143 | 1 | # add_qml_test macro | 1 | # add_qml_test macro |
2144 | 2 | include(QmlTest) | 2 | include(QmlTest) |
2145 | 3 | 3 | ||
2146 | 4 | add_subdirectory(mocks) | ||
2147 | 5 | |||
2148 | 4 | set(qmltest_DEFAULT_TARGETS qmluitests) | 6 | set(qmltest_DEFAULT_TARGETS qmluitests) |
2149 | 5 | set(qmltest_DEFAULT_NO_ADD_TEST TRUE) | 7 | set(qmltest_DEFAULT_NO_ADD_TEST TRUE) |
2150 | 6 | set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C") | 8 | set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C") |
2151 | @@ -40,3 +42,8 @@ | |||
2152 | 40 | add_qml_test(Vpn VpnPptpEditor) | 42 | add_qml_test(Vpn VpnPptpEditor) |
2153 | 41 | add_qml_test(Vpn VpnPreviewDialogCertificateChecks) | 43 | add_qml_test(Vpn VpnPreviewDialogCertificateChecks) |
2154 | 42 | add_qml_test(Vpn VpnPreviewDialog ENVIRONMENT NO_SSL_CERTIFICATE_CHECK=1) | 44 | add_qml_test(Vpn VpnPreviewDialog ENVIRONMENT NO_SSL_CERTIFICATE_CHECK=1) |
2155 | 45 | |||
2156 | 46 | add_qml_test(Fingerprint Fingerprints IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/mocks) | ||
2157 | 47 | add_qml_test(Fingerprint FingerprintNames IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/mocks) | ||
2158 | 48 | add_qml_test(Fingerprint FingerprintSetup IMPORT_PATHS ${CMAKE_CURRENT_BINARY_DIR}/mocks) | ||
2159 | 49 | add_qml_test(Fingerprint FingerprintVisual) | ||
2160 | 43 | 50 | ||
2161 | === added directory 'tests/qmltests/Fingerprint' | |||
2162 | === added file 'tests/qmltests/Fingerprint/tst_FingerprintNames.qml' | |||
2163 | --- tests/qmltests/Fingerprint/tst_FingerprintNames.qml 1970-01-01 00:00:00 +0000 | |||
2164 | +++ tests/qmltests/Fingerprint/tst_FingerprintNames.qml 2016-06-15 10:46:42 +0000 | |||
2165 | @@ -0,0 +1,364 @@ | |||
2166 | 1 | /* | ||
2167 | 2 | * Copyright 2016 Canonical Ltd. | ||
2168 | 3 | * | ||
2169 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2170 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2171 | 6 | * the Free Software Foundation; version 3. | ||
2172 | 7 | * | ||
2173 | 8 | * This program is distributed in the hope that it will be useful, | ||
2174 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2175 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2176 | 11 | * GNU Lesser General Public License for more details. | ||
2177 | 12 | * | ||
2178 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2179 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2180 | 15 | * | ||
2181 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
2182 | 17 | */ | ||
2183 | 18 | |||
2184 | 19 | import QtQuick 2.4 | ||
2185 | 20 | import QtTest 1.0 | ||
2186 | 21 | import Ubuntu.Test 0.1 | ||
2187 | 22 | import Ubuntu.Settings.Fingerprint 0.1 | ||
2188 | 23 | import Ubuntu.Components 1.3 | ||
2189 | 24 | import Biometryd 0.0 | ||
2190 | 25 | import GSettings 1.0 | ||
2191 | 26 | |||
2192 | 27 | Item { | ||
2193 | 28 | id: testRoot | ||
2194 | 29 | width: units.gu(50) | ||
2195 | 30 | height: units.gu(90) | ||
2196 | 31 | |||
2197 | 32 | PageStack { | ||
2198 | 33 | id: pageStack | ||
2199 | 34 | } | ||
2200 | 35 | |||
2201 | 36 | Component { | ||
2202 | 37 | id: fingerprintsComponent | ||
2203 | 38 | |||
2204 | 39 | Fingerprints { | ||
2205 | 40 | anchors.fill: parent | ||
2206 | 41 | visible: false | ||
2207 | 42 | } | ||
2208 | 43 | } | ||
2209 | 44 | |||
2210 | 45 | Component { | ||
2211 | 46 | id: fingerprintComponent | ||
2212 | 47 | |||
2213 | 48 | Fingerprint { | ||
2214 | 49 | anchors.fill: parent | ||
2215 | 50 | visible: false | ||
2216 | 51 | } | ||
2217 | 52 | } | ||
2218 | 53 | |||
2219 | 54 | Component { | ||
2220 | 55 | id: gsettingsComponent | ||
2221 | 56 | |||
2222 | 57 | GSettings { | ||
2223 | 58 | schema.id: "com.ubuntu.touch.system" | ||
2224 | 59 | } | ||
2225 | 60 | } | ||
2226 | 61 | |||
2227 | 62 | UbuntuTestCase { | ||
2228 | 63 | name: "TestOverview" | ||
2229 | 64 | when: windowShown | ||
2230 | 65 | |||
2231 | 66 | property var pageInstance: null | ||
2232 | 67 | property var gsettingsInstance: null | ||
2233 | 68 | |||
2234 | 69 | function getTemplateEntry(i) { | ||
2235 | 70 | var id = "fingerprintInstance-" + i; | ||
2236 | 71 | return findChild(pageInstance, id); | ||
2237 | 72 | } | ||
2238 | 73 | |||
2239 | 74 | function getListObserver() { | ||
2240 | 75 | return findInvisibleChild(pageInstance, "listObserver"); | ||
2241 | 76 | } | ||
2242 | 77 | |||
2243 | 78 | function getRemovalObserver() { | ||
2244 | 79 | return findInvisibleChild(pageInstance, "removalObserver"); | ||
2245 | 80 | } | ||
2246 | 81 | |||
2247 | 82 | function getClearanceObserver() { | ||
2248 | 83 | return findInvisibleChild(pageInstance, "clearanceObserver"); | ||
2249 | 84 | } | ||
2250 | 85 | |||
2251 | 86 | function getEnrollmentObserver() { | ||
2252 | 87 | return findInvisibleChild(pageInstance, "enrollmentObserver"); | ||
2253 | 88 | } | ||
2254 | 89 | |||
2255 | 90 | function initTestCase() { | ||
2256 | 91 | Biometryd.setAvailable(true); | ||
2257 | 92 | } | ||
2258 | 93 | |||
2259 | 94 | function init() { | ||
2260 | 95 | gsettingsInstance = gsettingsComponent.createObject(testRoot); | ||
2261 | 96 | pageInstance = fingerprintsComponent.createObject(testRoot, { | ||
2262 | 97 | _settings: gsettingsInstance, | ||
2263 | 98 | passcodeSet: true | ||
2264 | 99 | }); | ||
2265 | 100 | pageStack.push(pageInstance); | ||
2266 | 101 | } | ||
2267 | 102 | |||
2268 | 103 | function test_listSort() { | ||
2269 | 104 | GSettingsController.setFingerprintNames({ | ||
2270 | 105 | "first": "A finger", | ||
2271 | 106 | "second": "Big finger", | ||
2272 | 107 | "last": "Zmall finger", | ||
2273 | 108 | }); | ||
2274 | 109 | compare(getTemplateEntry(0).title.text, "A finger"); | ||
2275 | 110 | compare(getTemplateEntry(1).title.text, "Big finger"); | ||
2276 | 111 | compare(getTemplateEntry(2).title.text, "Zmall finger"); | ||
2277 | 112 | } | ||
2278 | 113 | |||
2279 | 114 | function test_remoteRemoval() { | ||
2280 | 115 | GSettingsController.setFingerprintNames({ | ||
2281 | 116 | "tmplId": "name" | ||
2282 | 117 | }); | ||
2283 | 118 | verify(getTemplateEntry(0)); | ||
2284 | 119 | |||
2285 | 120 | GSettingsController.setFingerprintNames({}); | ||
2286 | 121 | verify(!getTemplateEntry(0)); | ||
2287 | 122 | } | ||
2288 | 123 | |||
2289 | 124 | function test_remoteAddition() { | ||
2290 | 125 | GSettingsController.setFingerprintNames({ | ||
2291 | 126 | "tmplId": "name" | ||
2292 | 127 | }); | ||
2293 | 128 | verify(getTemplateEntry(0)); | ||
2294 | 129 | |||
2295 | 130 | GSettingsController.setFingerprintNames({ | ||
2296 | 131 | "tmplId": "name", | ||
2297 | 132 | "tmplId2": "name2" | ||
2298 | 133 | }); | ||
2299 | 134 | verify(getTemplateEntry(0)); | ||
2300 | 135 | verify(getTemplateEntry(1)); | ||
2301 | 136 | } | ||
2302 | 137 | |||
2303 | 138 | function test_remoteRename() { | ||
2304 | 139 | GSettingsController.setFingerprintNames({ | ||
2305 | 140 | "tmplId": "My finger", | ||
2306 | 141 | }); | ||
2307 | 142 | compare(getTemplateEntry(0).title.text, "My finger"); | ||
2308 | 143 | GSettingsController.setFingerprintNames({ | ||
2309 | 144 | "tmplId": "Your finger", | ||
2310 | 145 | }); | ||
2311 | 146 | compare(getTemplateEntry(0).title.text, "Your finger"); | ||
2312 | 147 | } | ||
2313 | 148 | |||
2314 | 149 | function test_localRemoval() { | ||
2315 | 150 | GSettingsController.setFingerprintNames({ | ||
2316 | 151 | "tmplId": "name" | ||
2317 | 152 | }); | ||
2318 | 153 | verify(getTemplateEntry(0)); | ||
2319 | 154 | pageInstance.removeTemplate("tmplId"); | ||
2320 | 155 | verify(!getTemplateEntry(0)); | ||
2321 | 156 | } | ||
2322 | 157 | |||
2323 | 158 | function test_localAddition() { | ||
2324 | 159 | pageInstance.addTemplate("tmplId", "My finger"); | ||
2325 | 160 | verify(getTemplateEntry(0)); | ||
2326 | 161 | compare(getTemplateEntry(0).title.text, "My finger"); | ||
2327 | 162 | } | ||
2328 | 163 | |||
2329 | 164 | function test_localRename() { | ||
2330 | 165 | GSettingsController.setFingerprintNames({ | ||
2331 | 166 | "tmplId": "My finger" | ||
2332 | 167 | }); | ||
2333 | 168 | pageInstance.renameTemplate("tmplId", "Your finger"); | ||
2334 | 169 | verify(getTemplateEntry(0)); | ||
2335 | 170 | compare(getTemplateEntry(0).title.text, "Your finger"); | ||
2336 | 171 | } | ||
2337 | 172 | |||
2338 | 173 | function test_createTemplateName() { | ||
2339 | 174 | GSettingsController.setFingerprintNames({ | ||
2340 | 175 | "tmplId": i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1) | ||
2341 | 176 | }); | ||
2342 | 177 | compare(pageInstance.createTemplateName(), i18n.dtr("ubuntu-settings-components", "Finger %1").arg(2)); | ||
2343 | 178 | pageInstance.renameTemplate("tmplId", i18n.dtr("ubuntu-settings-components", "Finger %1").arg(2)); | ||
2344 | 179 | compare(pageInstance.createTemplateName(), i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1)); | ||
2345 | 180 | } | ||
2346 | 181 | |||
2347 | 182 | function test_assignNames() { | ||
2348 | 183 | var templateIds = ["tmplId0", "tmplId1", "tmplId2"]; | ||
2349 | 184 | |||
2350 | 185 | // This name shouldn't be overwritten | ||
2351 | 186 | GSettingsController.setFingerprintNames({ | ||
2352 | 187 | "tmplId1": "My finger" | ||
2353 | 188 | }); | ||
2354 | 189 | |||
2355 | 190 | getListObserver().mockList(templateIds, ""); | ||
2356 | 191 | |||
2357 | 192 | verify(getTemplateEntry(0)); | ||
2358 | 193 | compare(getTemplateEntry(0).title.text, i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1)); | ||
2359 | 194 | |||
2360 | 195 | verify(getTemplateEntry(1)); | ||
2361 | 196 | compare(getTemplateEntry(1).title.text, i18n.dtr("ubuntu-settings-components", "Finger %1").arg(2)); | ||
2362 | 197 | |||
2363 | 198 | verify(getTemplateEntry(2)); | ||
2364 | 199 | compare(getTemplateEntry(2).title.text, "My finger"); | ||
2365 | 200 | } | ||
2366 | 201 | |||
2367 | 202 | function test_serviceRemoval() { | ||
2368 | 203 | GSettingsController.setFingerprintNames({ | ||
2369 | 204 | "tmplId": "A finger" | ||
2370 | 205 | }); | ||
2371 | 206 | getRemovalObserver().mockRemoval("tmplId", ""); | ||
2372 | 207 | verify(!getTemplateEntry(0)); | ||
2373 | 208 | compare(GSettingsController.fingerprintNames(), {}); | ||
2374 | 209 | } | ||
2375 | 210 | |||
2376 | 211 | function test_serviceEnrollment() { | ||
2377 | 212 | GSettingsController.setFingerprintNames({ | ||
2378 | 213 | "tmplId1": "Existing finger" | ||
2379 | 214 | }); | ||
2380 | 215 | getEnrollmentObserver().mockEnroll("tmplId2", ""); | ||
2381 | 216 | |||
2382 | 217 | verify(getTemplateEntry(0)); | ||
2383 | 218 | compare(getTemplateEntry(0).title.text, "Existing finger"); | ||
2384 | 219 | |||
2385 | 220 | verify(getTemplateEntry(1)); | ||
2386 | 221 | compare(getTemplateEntry(1).title.text, i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1)); | ||
2387 | 222 | } | ||
2388 | 223 | |||
2389 | 224 | function test_serviceEnrollmentFirstRun() { | ||
2390 | 225 | var targetName = i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1); | ||
2391 | 226 | |||
2392 | 227 | // A test where the template id is 0. | ||
2393 | 228 | getEnrollmentObserver().mockEnroll(0, ""); | ||
2394 | 229 | |||
2395 | 230 | verify(getTemplateEntry(0)); | ||
2396 | 231 | compare(getTemplateEntry(0).title.text, targetName); | ||
2397 | 232 | } | ||
2398 | 233 | |||
2399 | 234 | function test_serviceEnrollmentReusesId() { | ||
2400 | 235 | // Test a case where enrollment processes re-uses the template id | ||
2401 | 236 | // Hopefully this will never happen, but it currently does in testing, | ||
2402 | 237 | // so test it. | ||
2403 | 238 | var targetName = i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1); | ||
2404 | 239 | |||
2405 | 240 | getEnrollmentObserver().mockEnroll(0, ""); | ||
2406 | 241 | verify(getTemplateEntry(0)); | ||
2407 | 242 | compare(getTemplateEntry(0).title.text, targetName); | ||
2408 | 243 | |||
2409 | 244 | // Re-enroll same id, make sure it doesn't change the name | ||
2410 | 245 | getEnrollmentObserver().mockEnroll(0, ""); | ||
2411 | 246 | verify(getTemplateEntry(0)); | ||
2412 | 247 | compare(getTemplateEntry(0).title.text, targetName); | ||
2413 | 248 | |||
2414 | 249 | } | ||
2415 | 250 | |||
2416 | 251 | function test_serviceClearance() { | ||
2417 | 252 | GSettingsController.setFingerprintNames({ | ||
2418 | 253 | "tmplId1": "A finger", | ||
2419 | 254 | "tmplId2": "My finger" | ||
2420 | 255 | }); | ||
2421 | 256 | getClearanceObserver().mockClearance(""); | ||
2422 | 257 | |||
2423 | 258 | verify(!getTemplateEntry(0)); | ||
2424 | 259 | compare(GSettingsController.fingerprintNames(), {}); | ||
2425 | 260 | } | ||
2426 | 261 | |||
2427 | 262 | function cleanup() { | ||
2428 | 263 | pageStack.pop(); | ||
2429 | 264 | GSettingsController.setFingerprintNames({}); | ||
2430 | 265 | gsettingsInstance.destroy(); | ||
2431 | 266 | gsettingsInstance = null; | ||
2432 | 267 | pageInstance.destroy(); | ||
2433 | 268 | pageInstance = null; | ||
2434 | 269 | } | ||
2435 | 270 | } | ||
2436 | 271 | |||
2437 | 272 | SignalSpy { | ||
2438 | 273 | id: requestDeletionSpy | ||
2439 | 274 | signalName: "requestDeletion" | ||
2440 | 275 | } | ||
2441 | 276 | |||
2442 | 277 | SignalSpy { | ||
2443 | 278 | id: requestRenameSpy | ||
2444 | 279 | signalName: "requestRename" | ||
2445 | 280 | } | ||
2446 | 281 | |||
2447 | 282 | UbuntuTestCase { | ||
2448 | 283 | name: "TestTemplate" | ||
2449 | 284 | when: windowShown | ||
2450 | 285 | |||
2451 | 286 | property var templateInstance: null | ||
2452 | 287 | |||
2453 | 288 | function getDeleteButton() { | ||
2454 | 289 | return findChild(templateInstance, "templateDelete"); | ||
2455 | 290 | } | ||
2456 | 291 | |||
2457 | 292 | function getHeader() { | ||
2458 | 293 | return findChild(templateInstance, "templateHeader"); | ||
2459 | 294 | } | ||
2460 | 295 | |||
2461 | 296 | function getNameInput() { | ||
2462 | 297 | return findChild(templateInstance, "nameInput"); | ||
2463 | 298 | } | ||
2464 | 299 | |||
2465 | 300 | function getFailedDialog() { | ||
2466 | 301 | return findChild(testRoot, "fingerprintDeletionFailedDialog"); | ||
2467 | 302 | } | ||
2468 | 303 | |||
2469 | 304 | function getFailedDialogOk() { | ||
2470 | 305 | return findChild(testRoot, "fingerprintDeleteionFailedOk"); | ||
2471 | 306 | } | ||
2472 | 307 | |||
2473 | 308 | function init() { | ||
2474 | 309 | templateInstance = fingerprintComponent.createObject(testRoot); | ||
2475 | 310 | pageStack.push(templateInstance); | ||
2476 | 311 | requestRenameSpy.target = templateInstance; | ||
2477 | 312 | requestDeletionSpy.target = templateInstance; | ||
2478 | 313 | } | ||
2479 | 314 | |||
2480 | 315 | function cleanup() { | ||
2481 | 316 | requestRenameSpy.clear(); | ||
2482 | 317 | requestDeletionSpy.clear(); | ||
2483 | 318 | pageStack.pop(); | ||
2484 | 319 | templateInstance.destroy(); | ||
2485 | 320 | templateInstance = null; | ||
2486 | 321 | } | ||
2487 | 322 | |||
2488 | 323 | function test_name() { | ||
2489 | 324 | templateInstance.name = "My finger"; | ||
2490 | 325 | compare(getHeader().title, "My finger"); | ||
2491 | 326 | compare(getNameInput().text, "My finger"); | ||
2492 | 327 | } | ||
2493 | 328 | |||
2494 | 329 | function test_requestDeletion() { | ||
2495 | 330 | templateInstance.templateId = "tmplId"; | ||
2496 | 331 | var button = getDeleteButton(); | ||
2497 | 332 | mouseClick(button, button.width / 2, button.height / 2); | ||
2498 | 333 | requestDeletionSpy.wait(); | ||
2499 | 334 | compare(requestDeletionSpy.count, 1); | ||
2500 | 335 | compare(requestDeletionSpy.signalArguments[0][0], "tmplId"); | ||
2501 | 336 | } | ||
2502 | 337 | |||
2503 | 338 | function test_requestRename() { | ||
2504 | 339 | templateInstance.templateId = "tmplId"; | ||
2505 | 340 | templateInstance.name = "My finger"; | ||
2506 | 341 | requestRenameSpy.clear(); | ||
2507 | 342 | |||
2508 | 343 | getNameInput().text = "Your finger"; | ||
2509 | 344 | requestRenameSpy.wait(); | ||
2510 | 345 | compare(requestRenameSpy.count, 1); | ||
2511 | 346 | compare(requestRenameSpy.signalArguments[0][0], "tmplId"); | ||
2512 | 347 | compare(requestRenameSpy.signalArguments[0][1], "Your finger"); | ||
2513 | 348 | } | ||
2514 | 349 | |||
2515 | 350 | function test_deletionFailed() { | ||
2516 | 351 | templateInstance.deletionFailed(); | ||
2517 | 352 | tryCompareFunction(function () { | ||
2518 | 353 | return !!getFailedDialog(); | ||
2519 | 354 | }, true); | ||
2520 | 355 | |||
2521 | 356 | var button = getFailedDialogOk(); | ||
2522 | 357 | mouseClick(button, button.width / 2, button.height / 2); | ||
2523 | 358 | |||
2524 | 359 | tryCompareFunction(function () { | ||
2525 | 360 | return !!getFailedDialog(); | ||
2526 | 361 | }, false); | ||
2527 | 362 | } | ||
2528 | 363 | } | ||
2529 | 364 | } | ||
2530 | 0 | 365 | ||
2531 | === added file 'tests/qmltests/Fingerprint/tst_FingerprintSetup.qml' | |||
2532 | --- tests/qmltests/Fingerprint/tst_FingerprintSetup.qml 1970-01-01 00:00:00 +0000 | |||
2533 | +++ tests/qmltests/Fingerprint/tst_FingerprintSetup.qml 2016-06-15 10:46:42 +0000 | |||
2534 | @@ -0,0 +1,236 @@ | |||
2535 | 1 | /* | ||
2536 | 2 | * Copyright 2016 Canonical Ltd. | ||
2537 | 3 | * | ||
2538 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2539 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2540 | 6 | * the Free Software Foundation; version 3. | ||
2541 | 7 | * | ||
2542 | 8 | * This program is distributed in the hope that it will be useful, | ||
2543 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2544 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2545 | 11 | * GNU Lesser General Public License for more details. | ||
2546 | 12 | * | ||
2547 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2548 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2549 | 15 | * | ||
2550 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
2551 | 17 | */ | ||
2552 | 18 | |||
2553 | 19 | import QtQuick 2.4 | ||
2554 | 20 | import QtTest 1.0 | ||
2555 | 21 | import Ubuntu.Components 1.3 | ||
2556 | 22 | import Ubuntu.Settings.Fingerprint 0.1 | ||
2557 | 23 | import Ubuntu.Test 0.1 | ||
2558 | 24 | import Biometryd 0.0 | ||
2559 | 25 | |||
2560 | 26 | Item { | ||
2561 | 27 | id: testRoot | ||
2562 | 28 | width: units.gu(50) | ||
2563 | 29 | height: units.gu(90) | ||
2564 | 30 | |||
2565 | 31 | Component { | ||
2566 | 32 | id: setupComponent | ||
2567 | 33 | |||
2568 | 34 | Setup { | ||
2569 | 35 | anchors.fill: parent | ||
2570 | 36 | visible: false | ||
2571 | 37 | } | ||
2572 | 38 | } | ||
2573 | 39 | |||
2574 | 40 | PageStack { | ||
2575 | 41 | id: pageStack | ||
2576 | 42 | } | ||
2577 | 43 | |||
2578 | 44 | SignalSpy { | ||
2579 | 45 | id: statusLabelSpy | ||
2580 | 46 | signalName: "slideCompleted" | ||
2581 | 47 | } | ||
2582 | 48 | |||
2583 | 49 | SignalSpy { | ||
2584 | 50 | id: enrollmentObserverProgressedSpy | ||
2585 | 51 | signalName: "progressed" | ||
2586 | 52 | } | ||
2587 | 53 | |||
2588 | 54 | SignalSpy { | ||
2589 | 55 | id: enrollmentObserverSucceededSpy | ||
2590 | 56 | signalName: "succeeded" | ||
2591 | 57 | } | ||
2592 | 58 | |||
2593 | 59 | SignalSpy { | ||
2594 | 60 | id: enrollmentObserverFailedSpy | ||
2595 | 61 | signalName: "failed" | ||
2596 | 62 | } | ||
2597 | 63 | |||
2598 | 64 | UbuntuTestCase { | ||
2599 | 65 | name: "SetupUI" | ||
2600 | 66 | when: windowShown | ||
2601 | 67 | |||
2602 | 68 | property var setupInstance: null | ||
2603 | 69 | |||
2604 | 70 | function init() { | ||
2605 | 71 | Biometryd.setAvailable(true); | ||
2606 | 72 | setupInstance = setupComponent.createObject(testRoot); | ||
2607 | 73 | pageStack.push(setupInstance); | ||
2608 | 74 | |||
2609 | 75 | statusLabelSpy.target = getStatusLabel(); | ||
2610 | 76 | } | ||
2611 | 77 | |||
2612 | 78 | function cleanup() { | ||
2613 | 79 | statusLabelSpy.clear(); | ||
2614 | 80 | |||
2615 | 81 | pageStack.pop(); | ||
2616 | 82 | setupInstance.destroy(); | ||
2617 | 83 | setupInstance = null | ||
2618 | 84 | } | ||
2619 | 85 | |||
2620 | 86 | function getStatusLabel() { | ||
2621 | 87 | return findChild(setupInstance, "fingerprintStatusLabel"); | ||
2622 | 88 | } | ||
2623 | 89 | |||
2624 | 90 | function getFailedVisual() { | ||
2625 | 91 | return findChild(setupInstance, "fingerprintFailedVisual"); | ||
2626 | 92 | } | ||
2627 | 93 | |||
2628 | 94 | function getDefaultVisual() { | ||
2629 | 95 | return findChild(setupInstance, "fingerprintDefaultVisual"); | ||
2630 | 96 | } | ||
2631 | 97 | |||
2632 | 98 | function getDoneVisual() { | ||
2633 | 99 | return findChild(setupInstance, "fingerprintDoneVisual"); | ||
2634 | 100 | } | ||
2635 | 101 | |||
2636 | 102 | function getProgressLabel() { | ||
2637 | 103 | return findChild(setupInstance, "fingerprintProgressLabel"); | ||
2638 | 104 | } | ||
2639 | 105 | |||
2640 | 106 | function test_initialState() { | ||
2641 | 107 | var targetText = i18n.dtr("ubuntu-settings-components", "Place your finger on the home button."); | ||
2642 | 108 | compare(getStatusLabel().text, targetText); | ||
2643 | 109 | |||
2644 | 110 | tryCompare(getDefaultVisual(), "opacity", 1); | ||
2645 | 111 | tryCompare(getFailedVisual(), "opacity", 0); | ||
2646 | 112 | tryCompare(getDoneVisual(), "opacity", 0); | ||
2647 | 113 | } | ||
2648 | 114 | |||
2649 | 115 | function test_startedState() { | ||
2650 | 116 | var targetText = i18n.dtr("ubuntu-settings-components", "Lift and press your finger again."); | ||
2651 | 117 | setupInstance.enrollmentProgressed(0.5, {}); | ||
2652 | 118 | statusLabelSpy.wait(); | ||
2653 | 119 | compare(getStatusLabel().text, targetText); | ||
2654 | 120 | |||
2655 | 121 | tryCompare(getDefaultVisual(), "opacity", 1); | ||
2656 | 122 | tryCompare(getFailedVisual(), "opacity", 0); | ||
2657 | 123 | tryCompare(getDoneVisual(), "opacity", 0); | ||
2658 | 124 | } | ||
2659 | 125 | |||
2660 | 126 | function test_failedStatus() { | ||
2661 | 127 | var targetText = i18n.dtr("ubuntu-settings-components", "Sorry, the reader doesn’t seem to be working."); | ||
2662 | 128 | setupInstance.enrollmentFailed("test failure"); | ||
2663 | 129 | compare(getStatusLabel().text, targetText); | ||
2664 | 130 | |||
2665 | 131 | tryCompare(getDefaultVisual(), "opacity", 0); | ||
2666 | 132 | tryCompare(getFailedVisual(), "opacity", 1); | ||
2667 | 133 | tryCompare(getDoneVisual(), "opacity", 0); | ||
2668 | 134 | } | ||
2669 | 135 | |||
2670 | 136 | function test_successfulState() { | ||
2671 | 137 | var targetText = i18n.dtr("ubuntu-settings-components", "All done!"); | ||
2672 | 138 | |||
2673 | 139 | setupInstance.enrollmentCompleted(); | ||
2674 | 140 | compare(getStatusLabel().text, targetText); | ||
2675 | 141 | |||
2676 | 142 | tryCompare(getDefaultVisual(), "opacity", 0); | ||
2677 | 143 | tryCompare(getFailedVisual(), "opacity", 0); | ||
2678 | 144 | tryCompare(getDoneVisual(), "opacity", 1); | ||
2679 | 145 | |||
2680 | 146 | var button = findChild(pageStack, "fingerprintSetupDoneButton"); | ||
2681 | 147 | compare(button.enabled, true, "button was disabled when done"); | ||
2682 | 148 | } | ||
2683 | 149 | |||
2684 | 150 | function test_notDone() { | ||
2685 | 151 | var button = findChild(pageStack, "fingerprintSetupDoneButton"); | ||
2686 | 152 | compare(button.enabled, false, "button was enabled initially"); | ||
2687 | 153 | } | ||
2688 | 154 | |||
2689 | 155 | function test_statusLabel() { | ||
2690 | 156 | getStatusLabel().setText("foo"); | ||
2691 | 157 | statusLabelSpy.wait(); | ||
2692 | 158 | compare(getStatusLabel().text, "foo"); | ||
2693 | 159 | } | ||
2694 | 160 | |||
2695 | 161 | function test_direction_data() { | ||
2696 | 162 | return [ | ||
2697 | 163 | { tag: "empty", visual: { visible: false, rotation: 0 }}, | ||
2698 | 164 | { tag: "not available", dir: FingerprintReader.NotAvailable, visual: { visible: false, rotation: 0 }}, | ||
2699 | 165 | { tag: "SouthWest", dir: FingerprintReader.SouthWest, visual: { visible: true, rotation: 225 }}, | ||
2700 | 166 | { tag: "South", dir: FingerprintReader.South, visual: { visible: true, rotation: 180 }}, | ||
2701 | 167 | { tag: "SouthEast", dir: FingerprintReader.SouthEast, visual: { visible: true, rotation: 135 }}, | ||
2702 | 168 | { tag: "NorthWest", dir: FingerprintReader.NorthWest, visual: { visible: true, rotation: 315 }}, | ||
2703 | 169 | { tag: "North", dir: FingerprintReader.North, visual: { visible: true, rotation: 0 }}, | ||
2704 | 170 | { tag: "NorthEast", dir: FingerprintReader.NorthEast, visual: { visible: true, rotation: 45 }}, | ||
2705 | 171 | { tag: "East", dir: FingerprintReader.East, visual: { visible: true, rotation: 90 }}, | ||
2706 | 172 | { tag: "West", dir: FingerprintReader.West, visual: { visible: true, rotation: 270 }} | ||
2707 | 173 | ] | ||
2708 | 174 | } | ||
2709 | 175 | |||
2710 | 176 | function test_direction(data) { | ||
2711 | 177 | var vis = findChild(setupInstance, "fingerprintDirectionVisual"); | ||
2712 | 178 | var hints = {}; | ||
2713 | 179 | hints[FingerprintReader.suggestedNextDirection] = data.dir; | ||
2714 | 180 | |||
2715 | 181 | setupInstance.enrollmentProgressed(0.5, hints); | ||
2716 | 182 | |||
2717 | 183 | tryCompare(vis, "opacity", data.visual.visible ? 1 : 0) | ||
2718 | 184 | compare(vis.opacity, data.visual.visible ? 1 : 0); | ||
2719 | 185 | compare(vis.rotation, data.visual.rotation); | ||
2720 | 186 | } | ||
2721 | 187 | |||
2722 | 188 | function test_progressHidden() { | ||
2723 | 189 | var pl = getProgressLabel(); | ||
2724 | 190 | compare(pl.opacity, 0); | ||
2725 | 191 | } | ||
2726 | 192 | |||
2727 | 193 | function test_progressVisible() { | ||
2728 | 194 | var pl = getProgressLabel(); | ||
2729 | 195 | setupInstance.enrollmentProgressed(0.5, {}); | ||
2730 | 196 | tryCompare(pl, "opacity", 1); | ||
2731 | 197 | tryCompare(pl, "text", i18n.dtr("ubuntu-settings-components", "%1%").arg(50)); | ||
2732 | 198 | } | ||
2733 | 199 | |||
2734 | 200 | function test_progressReadable() { | ||
2735 | 201 | setupInstance.enrollmentProgressed(0.6666666667, {}); | ||
2736 | 202 | tryCompare(getProgressLabel(), "text", i18n.dtr("ubuntu-settings-components", "%1%").arg(66)); | ||
2737 | 203 | } | ||
2738 | 204 | |||
2739 | 205 | // This is a visual test where we can confirm that the arrow | ||
2740 | 206 | // rotates using the orthodromic distance. | ||
2741 | 207 | function test_directions() { | ||
2742 | 208 | var hints = {}; | ||
2743 | 209 | |||
2744 | 210 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.North; | ||
2745 | 211 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2746 | 212 | wait(200) | ||
2747 | 213 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.East; | ||
2748 | 214 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2749 | 215 | wait(200) | ||
2750 | 216 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.South; | ||
2751 | 217 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2752 | 218 | wait(200) | ||
2753 | 219 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.West; | ||
2754 | 220 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2755 | 221 | wait(200) | ||
2756 | 222 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.SouthEast; | ||
2757 | 223 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2758 | 224 | wait(200) | ||
2759 | 225 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.NorthEast; | ||
2760 | 226 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2761 | 227 | wait(200) | ||
2762 | 228 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.NorthWest; | ||
2763 | 229 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2764 | 230 | wait(200) | ||
2765 | 231 | hints[FingerprintReader.suggestedNextDirection] = FingerprintReader.NorthEast; | ||
2766 | 232 | setupInstance.enrollmentProgressed(0.6666666667, hints); | ||
2767 | 233 | wait(200) | ||
2768 | 234 | } | ||
2769 | 235 | } | ||
2770 | 236 | } | ||
2771 | 0 | 237 | ||
2772 | === added file 'tests/qmltests/Fingerprint/tst_FingerprintVisual.qml' | |||
2773 | --- tests/qmltests/Fingerprint/tst_FingerprintVisual.qml 1970-01-01 00:00:00 +0000 | |||
2774 | +++ tests/qmltests/Fingerprint/tst_FingerprintVisual.qml 2016-06-15 10:46:42 +0000 | |||
2775 | @@ -0,0 +1,132 @@ | |||
2776 | 1 | /* | ||
2777 | 2 | * Copyright 2016 Canonical Ltd. | ||
2778 | 3 | * | ||
2779 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2780 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2781 | 6 | * the Free Software Foundation; version 3. | ||
2782 | 7 | * | ||
2783 | 8 | * This program is distributed in the hope that it will be useful, | ||
2784 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2785 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2786 | 11 | * GNU Lesser General Public License for more details. | ||
2787 | 12 | * | ||
2788 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2789 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2790 | 15 | * | ||
2791 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
2792 | 17 | */ | ||
2793 | 18 | |||
2794 | 19 | import QtQuick 2.4 | ||
2795 | 20 | import QtTest 1.0 | ||
2796 | 21 | import Ubuntu.Components 1.3 | ||
2797 | 22 | import Ubuntu.Settings.Fingerprint 0.1 | ||
2798 | 23 | import Ubuntu.Test 0.1 | ||
2799 | 24 | |||
2800 | 25 | Item { | ||
2801 | 26 | id: testRoot | ||
2802 | 27 | width: units.gu(50) | ||
2803 | 28 | height: units.gu(90) | ||
2804 | 29 | |||
2805 | 30 | SignalSpy { | ||
2806 | 31 | id: visualReadySpy | ||
2807 | 32 | signalName: "ready" | ||
2808 | 33 | } | ||
2809 | 34 | |||
2810 | 35 | Component { | ||
2811 | 36 | id: fingerprintVisualComp | ||
2812 | 37 | |||
2813 | 38 | FingerprintVisual { | ||
2814 | 39 | id: vis | ||
2815 | 40 | objectName: "fingerprintVisual" | ||
2816 | 41 | width: 400 | ||
2817 | 42 | height: width * 1.227 | ||
2818 | 43 | } | ||
2819 | 44 | } | ||
2820 | 45 | |||
2821 | 46 | |||
2822 | 47 | UbuntuTestCase { | ||
2823 | 48 | name: "FingerprintVisual" | ||
2824 | 49 | when: windowShown | ||
2825 | 50 | |||
2826 | 51 | function init() { | ||
2827 | 52 | visualReadySpy.target = fingerprintVisualComp.createObject(testRoot); | ||
2828 | 53 | visualReadySpy.wait() | ||
2829 | 54 | } | ||
2830 | 55 | |||
2831 | 56 | function cleanup() { | ||
2832 | 57 | findChild(testRoot, "fingerprintVisual").destroy(); | ||
2833 | 58 | } | ||
2834 | 59 | |||
2835 | 60 | function test_masks_data() { | ||
2836 | 61 | return [ | ||
2837 | 62 | { masks: null, targetMasks: [], tag: "null" }, | ||
2838 | 63 | { masks: [], targetMasks: [], tag: "no masks" }, | ||
2839 | 64 | { | ||
2840 | 65 | masks: [{x: 0, y: 0, width: 0, height: 0 }], | ||
2841 | 66 | targetMasks: [{x: 0, y: 0, width: 0, height: 0}], | ||
2842 | 67 | tag: "0" | ||
2843 | 68 | }, | ||
2844 | 69 | { | ||
2845 | 70 | masks: [ | ||
2846 | 71 | {x: null, y: "-a", width: "0x1", height: true }, | ||
2847 | 72 | {}, | ||
2848 | 73 | ], | ||
2849 | 74 | targetMasks: [], | ||
2850 | 75 | tag: "bad values" | ||
2851 | 76 | }, | ||
2852 | 77 | |||
2853 | 78 | // Masks for manual, visual checks. | ||
2854 | 79 | { | ||
2855 | 80 | masks: [ | ||
2856 | 81 | {x: 0, y: 0, width: 0.5, height: 0.5 } | ||
2857 | 82 | ], | ||
2858 | 83 | visualCheck: true, | ||
2859 | 84 | tag: "top right corner" | ||
2860 | 85 | }, | ||
2861 | 86 | { | ||
2862 | 87 | masks: [ | ||
2863 | 88 | {x: 0.5, y: 0, width: 0.5, height: 0.5 } | ||
2864 | 89 | ], | ||
2865 | 90 | visualCheck: true, | ||
2866 | 91 | tag: "top left corner" | ||
2867 | 92 | }, | ||
2868 | 93 | { | ||
2869 | 94 | masks: [ | ||
2870 | 95 | {x: 0, y: 0.5, width: 0.5, height: 0.5 } | ||
2871 | 96 | ], | ||
2872 | 97 | visualCheck: true, | ||
2873 | 98 | tag: "bottom right corner" | ||
2874 | 99 | }, | ||
2875 | 100 | { | ||
2876 | 101 | masks: [ | ||
2877 | 102 | {x: 0.5, y: 0.5, width: 0.5, height: 0.5 } | ||
2878 | 103 | ], | ||
2879 | 104 | visualCheck: true, | ||
2880 | 105 | tag: "bottom left corner" | ||
2881 | 106 | }, | ||
2882 | 107 | { | ||
2883 | 108 | masks: [ | ||
2884 | 109 | {x: 0, y: 0, width: 0.5, height: 0.5 }, | ||
2885 | 110 | {x: 0.5, y: 0, width: 0.5, height: 0.5 }, | ||
2886 | 111 | {x: 0, y: 0.5, width: 0.5, height: 0.5 }, | ||
2887 | 112 | {x: 0.5, y: 0.5, width: 0.5, height: 0.5 } | ||
2888 | 113 | ], | ||
2889 | 114 | visualCheck: true, | ||
2890 | 115 | tag: "all corners" | ||
2891 | 116 | } | ||
2892 | 117 | ] | ||
2893 | 118 | } | ||
2894 | 119 | |||
2895 | 120 | function test_masks (data) { | ||
2896 | 121 | var vis = findChild(testRoot, "fingerprintVisual"); | ||
2897 | 122 | vis.masks = data.masks; | ||
2898 | 123 | if (data.visualCheck) { | ||
2899 | 124 | wait(1000); | ||
2900 | 125 | } else { | ||
2901 | 126 | var actualMasks = vis.getMasksToEnroll(); | ||
2902 | 127 | var targetMasks = data.targetMasks; | ||
2903 | 128 | compare(actualMasks.length, targetMasks.length); | ||
2904 | 129 | } | ||
2905 | 130 | } | ||
2906 | 131 | } | ||
2907 | 132 | } | ||
2908 | 0 | 133 | ||
2909 | === added file 'tests/qmltests/Fingerprint/tst_Fingerprints.qml' | |||
2910 | --- tests/qmltests/Fingerprint/tst_Fingerprints.qml 1970-01-01 00:00:00 +0000 | |||
2911 | +++ tests/qmltests/Fingerprint/tst_Fingerprints.qml 2016-06-15 10:46:42 +0000 | |||
2912 | @@ -0,0 +1,230 @@ | |||
2913 | 1 | /* | ||
2914 | 2 | * Copyright 2016 Canonical Ltd. | ||
2915 | 3 | * | ||
2916 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2917 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2918 | 6 | * the Free Software Foundation; version 3. | ||
2919 | 7 | * | ||
2920 | 8 | * This program is distributed in the hope that it will be useful, | ||
2921 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2922 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2923 | 11 | * GNU Lesser General Public License for more details. | ||
2924 | 12 | * | ||
2925 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2926 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2927 | 15 | * | ||
2928 | 16 | * Authored by Jonas G. Drange <jonas.drange@canonical.com> | ||
2929 | 17 | */ | ||
2930 | 18 | |||
2931 | 19 | import QtQuick 2.4 | ||
2932 | 20 | import QtTest 1.0 | ||
2933 | 21 | import Ubuntu.Test 0.1 | ||
2934 | 22 | import Ubuntu.Settings.Fingerprint 0.1 | ||
2935 | 23 | import Biometryd 0.0 | ||
2936 | 24 | import GSettings 1.0 | ||
2937 | 25 | |||
2938 | 26 | Item { | ||
2939 | 27 | id: testRoot | ||
2940 | 28 | width: units.gu(50) | ||
2941 | 29 | height: units.gu(90) | ||
2942 | 30 | |||
2943 | 31 | Component { | ||
2944 | 32 | id: fingerprintsComponent | ||
2945 | 33 | |||
2946 | 34 | Fingerprints { | ||
2947 | 35 | anchors.fill: parent | ||
2948 | 36 | } | ||
2949 | 37 | } | ||
2950 | 38 | |||
2951 | 39 | SignalSpy { | ||
2952 | 40 | id: spy | ||
2953 | 41 | } | ||
2954 | 42 | |||
2955 | 43 | UbuntuTestCase { | ||
2956 | 44 | name: "FingerprintPanel" | ||
2957 | 45 | when: windowShown | ||
2958 | 46 | |||
2959 | 47 | property var fingerprintsInstance: null | ||
2960 | 48 | |||
2961 | 49 | function init() { | ||
2962 | 50 | Biometryd.setAvailable(true); | ||
2963 | 51 | fingerprintsInstance = fingerprintsComponent.createObject(testRoot); | ||
2964 | 52 | } | ||
2965 | 53 | |||
2966 | 54 | function cleanup() { | ||
2967 | 55 | spy.clear(); | ||
2968 | 56 | spy.target = null; | ||
2969 | 57 | spy.signalName = ""; | ||
2970 | 58 | fingerprintsInstance.destroy(); | ||
2971 | 59 | GSettingsController.setFingerprintNames({}); | ||
2972 | 60 | } | ||
2973 | 61 | |||
2974 | 62 | function getClearanceObserver() { | ||
2975 | 63 | return findInvisibleChild(fingerprintsInstance, "clearanceObserver"); | ||
2976 | 64 | } | ||
2977 | 65 | |||
2978 | 66 | function getListObserver() { | ||
2979 | 67 | return findInvisibleChild(fingerprintsInstance, "listObserver"); | ||
2980 | 68 | } | ||
2981 | 69 | |||
2982 | 70 | function getEnrollmentObserver() { | ||
2983 | 71 | return findInvisibleChild(fingerprintsInstance, "enrollmentObserver"); | ||
2984 | 72 | } | ||
2985 | 73 | |||
2986 | 74 | function getRemovalObserver() { | ||
2987 | 75 | return findInvisibleChild(fingerprintsInstance, "removalObserver"); | ||
2988 | 76 | } | ||
2989 | 77 | |||
2990 | 78 | function getBrokenDialog() { | ||
2991 | 79 | return findChild(testRoot, "fingerprintReaderBrokenDialog"); | ||
2992 | 80 | } | ||
2993 | 81 | |||
2994 | 82 | function getBrokenDialogOk() { | ||
2995 | 83 | return findChild(testRoot, "fingerprintReaderBrokenDialogOK"); | ||
2996 | 84 | } | ||
2997 | 85 | |||
2998 | 86 | function getAddFingerprintItem() { | ||
2999 | 87 | return findChild(fingerprintsInstance, "fingerprintAddListItemLayout"); | ||
3000 | 88 | } | ||
3001 | 89 | |||
3002 | 90 | function getRemoveAllButton() { | ||
3003 | 91 | return findChild(fingerprintsInstance, "fingerprintRemoveAllButton"); | ||
3004 | 92 | } | ||
3005 | 93 | |||
3006 | 94 | function getFingerprintsList() { | ||
3007 | 95 | return findChild(fingerprintsInstance, "fingerprintsList"); | ||
3008 | 96 | } | ||
3009 | 97 | |||
3010 | 98 | function getSetupEntry() { | ||
3011 | 99 | return findChild(fingerprintsInstance, "fingerprintSetupEntry"); | ||
3012 | 100 | } | ||
3013 | 101 | |||
3014 | 102 | function test_failures_data() { | ||
3015 | 103 | return [ | ||
3016 | 104 | { tag: "clearance", observer: getClearanceObserver, mock: "mockClearance", mockArgs: ["failed"] }, | ||
3017 | 105 | { tag: "list", observer: getListObserver, mock: "mockList", mockArgs: [[], "failed"] } | ||
3018 | 106 | ] | ||
3019 | 107 | } | ||
3020 | 108 | |||
3021 | 109 | function test_failures(data) { | ||
3022 | 110 | var obs = data.observer(); | ||
3023 | 111 | spy.signalName = "failed"; | ||
3024 | 112 | spy.target = obs; | ||
3025 | 113 | obs[data.mock].apply(null, data.mockArgs); | ||
3026 | 114 | spy.wait(); | ||
3027 | 115 | var errorDiag = getBrokenDialog(); | ||
3028 | 116 | var ok = getBrokenDialogOk(); | ||
3029 | 117 | mouseClick(ok, ok.width / 2, ok.height / 2); | ||
3030 | 118 | |||
3031 | 119 | // Halt testing until dialog has been destroyed. | ||
3032 | 120 | tryCompareFunction(function() { | ||
3033 | 121 | return getBrokenDialog(); | ||
3034 | 122 | }, null); | ||
3035 | 123 | } | ||
3036 | 124 | |||
3037 | 125 | function test_noPasscode() { | ||
3038 | 126 | fingerprintsInstance.passcodeSet = false; | ||
3039 | 127 | compare(fingerprintsInstance.state, "noPasscode"); | ||
3040 | 128 | |||
3041 | 129 | var setButton = findChild(fingerprintsInstance, "fingerprintSetPasscodeButton"); | ||
3042 | 130 | compare(setButton.visible, true); | ||
3043 | 131 | |||
3044 | 132 | var setupEntry = getSetupEntry(); | ||
3045 | 133 | compare(setupEntry.enabled, false); | ||
3046 | 134 | |||
3047 | 135 | var fingerprintsList = getFingerprintsList(); | ||
3048 | 136 | compare(fingerprintsList.enabled, false); | ||
3049 | 137 | } | ||
3050 | 138 | |||
3051 | 139 | function test_noScanner() { | ||
3052 | 140 | fingerprintsInstance.passcodeSet = true; | ||
3053 | 141 | Biometryd.setAvailable(false); | ||
3054 | 142 | compare(fingerprintsInstance.state, "noScanner"); | ||
3055 | 143 | |||
3056 | 144 | var addItem = getAddFingerprintItem(); | ||
3057 | 145 | compare(addItem.enabled, false); | ||
3058 | 146 | |||
3059 | 147 | var removeButton = getRemoveAllButton(); | ||
3060 | 148 | compare(removeButton.enabled, false); | ||
3061 | 149 | |||
3062 | 150 | var fingerprintsList = getFingerprintsList(); | ||
3063 | 151 | compare(fingerprintsList.visible, false); | ||
3064 | 152 | } | ||
3065 | 153 | |||
3066 | 154 | function test_passcode() { | ||
3067 | 155 | fingerprintsInstance.passcodeSet = true; | ||
3068 | 156 | compare(fingerprintsInstance.state, ""); | ||
3069 | 157 | var setButton = findChild(fingerprintsInstance, "fingerprintSetPasscodeButton"); | ||
3070 | 158 | compare(setButton.visible, false); | ||
3071 | 159 | var setupEntry = getSetupEntry(); | ||
3072 | 160 | compare(setupEntry.enabled, true); | ||
3073 | 161 | } | ||
3074 | 162 | |||
3075 | 163 | function test_changePasscode() { | ||
3076 | 164 | fingerprintsInstance.passcodeSet = false; | ||
3077 | 165 | var setButton = findChild(fingerprintsInstance, "fingerprintSetPasscodeButton"); | ||
3078 | 166 | |||
3079 | 167 | spy.signalName = "requestPasscode" | ||
3080 | 168 | spy.target = fingerprintsInstance; | ||
3081 | 169 | mouseClick(setButton, setButton.width / 2, setButton.height / 2); | ||
3082 | 170 | spy.wait(); | ||
3083 | 171 | |||
3084 | 172 | compare(spy.count, 1); | ||
3085 | 173 | } | ||
3086 | 174 | |||
3087 | 175 | function test_setup() { | ||
3088 | 176 | fingerprintsInstance.passcodeSet = false; | ||
3089 | 177 | var add = getAddFingerprintItem(); | ||
3090 | 178 | var remove = getRemoveAllButton(); | ||
3091 | 179 | compare(add.enabled, false); | ||
3092 | 180 | compare(remove.enabled, false); | ||
3093 | 181 | } | ||
3094 | 182 | |||
3095 | 183 | function test_noRemove() { | ||
3096 | 184 | fingerprintsInstance.passcodeSet = true; | ||
3097 | 185 | GSettingsController.setFingerprintNames({}); | ||
3098 | 186 | var remove = getRemoveAllButton(); | ||
3099 | 187 | compare(remove.enabled, false); | ||
3100 | 188 | } | ||
3101 | 189 | |||
3102 | 190 | function test_remove() { | ||
3103 | 191 | fingerprintsInstance.passcodeSet = true; | ||
3104 | 192 | GSettingsController.setFingerprintNames({"tmplId": "A Finger"}); | ||
3105 | 193 | |||
3106 | 194 | var remove = getRemoveAllButton(); | ||
3107 | 195 | mouseClick(remove, remove.width / 2, remove.height / 2); | ||
3108 | 196 | var diag = findChild(testRoot, "fingerprintRemoveAllDialog"); | ||
3109 | 197 | var confirm = findChild(diag, "fingerprintRemoveAllConfirmationButton"); | ||
3110 | 198 | compare(confirm.visible, true); | ||
3111 | 199 | mouseClick(confirm, confirm.width / 2, confirm.height / 2); | ||
3112 | 200 | |||
3113 | 201 | var obs = getClearanceObserver(); | ||
3114 | 202 | spy.signalName = "succeeded"; | ||
3115 | 203 | spy.target = obs; | ||
3116 | 204 | obs.mockClearance(""); | ||
3117 | 205 | spy.wait(); | ||
3118 | 206 | compare(spy.count, 1); | ||
3119 | 207 | |||
3120 | 208 | // Wait for dialog destruction (which is required for other tests) | ||
3121 | 209 | // to function. | ||
3122 | 210 | tryCompareFunction(function() { | ||
3123 | 211 | return findChild(testRoot, "fingerprintRemoveAllDialog"); | ||
3124 | 212 | }, null); | ||
3125 | 213 | } | ||
3126 | 214 | |||
3127 | 215 | function test_enrollmentSucceeded() { | ||
3128 | 216 | var obs = getEnrollmentObserver(); | ||
3129 | 217 | var targetFingerprintName = i18n.dtr("ubuntu-settings-components", "Finger %1").arg(1); | ||
3130 | 218 | spy.signalName = "succeeded"; | ||
3131 | 219 | spy.target = obs; | ||
3132 | 220 | obs.mockEnroll("tmplId", ""); | ||
3133 | 221 | spy.wait(); | ||
3134 | 222 | compare(spy.count, 1); | ||
3135 | 223 | compare(spy.signalArguments[0][0], "tmplId"); | ||
3136 | 224 | |||
3137 | 225 | tryCompareFunction(function() { | ||
3138 | 226 | return GSettingsController.fingerprintNames()["tmplId"]; | ||
3139 | 227 | }, targetFingerprintName); | ||
3140 | 228 | } | ||
3141 | 229 | } | ||
3142 | 230 | } | ||
3143 | 0 | 231 | ||
3144 | === added directory 'tests/qmltests/mocks' | |||
3145 | === added directory 'tests/qmltests/mocks/Biometryd' | |||
3146 | === added file 'tests/qmltests/mocks/Biometryd/CMakeLists.txt' | |||
3147 | --- tests/qmltests/mocks/Biometryd/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3148 | +++ tests/qmltests/mocks/Biometryd/CMakeLists.txt 2016-06-15 10:46:42 +0000 | |||
3149 | @@ -0,0 +1,20 @@ | |||
3150 | 1 | include_directories( | ||
3151 | 2 | ${CMAKE_CURRENT_BINARY_DIR} | ||
3152 | 3 | ) | ||
3153 | 4 | |||
3154 | 5 | set(MOCK_BIOMETRYD_SOURCES | ||
3155 | 6 | plugin.cpp | ||
3156 | 7 | MockDevice.cpp | ||
3157 | 8 | MockFingerprintReader.cpp | ||
3158 | 9 | MockObserver.cpp | ||
3159 | 10 | MockOperation.cpp | ||
3160 | 11 | MockService.cpp | ||
3161 | 12 | MockTemplateStore.cpp | ||
3162 | 13 | MockUser.cpp | ||
3163 | 14 | ) | ||
3164 | 15 | |||
3165 | 16 | add_library(MockBiometryd MODULE ${MOCK_BIOMETRYD_SOURCES}) | ||
3166 | 17 | |||
3167 | 18 | qt5_use_modules(MockBiometryd Qml Quick Core) | ||
3168 | 19 | |||
3169 | 20 | add_usc_mock(Biometryd 0.0 Biometryd TARGETS MockBiometryd) | ||
3170 | 0 | 21 | ||
3171 | === added file 'tests/qmltests/mocks/Biometryd/MockDevice.cpp' | |||
3172 | --- tests/qmltests/mocks/Biometryd/MockDevice.cpp 1970-01-01 00:00:00 +0000 | |||
3173 | +++ tests/qmltests/mocks/Biometryd/MockDevice.cpp 2016-06-15 10:46:42 +0000 | |||
3174 | @@ -0,0 +1,30 @@ | |||
3175 | 1 | /* | ||
3176 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3177 | 3 | * | ||
3178 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3179 | 5 | * it under the terms of the GNU General Public License as published by | ||
3180 | 6 | * the Free Software Foundation; version 3. | ||
3181 | 7 | * | ||
3182 | 8 | * This program is distributed in the hope that it will be useful, | ||
3183 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3184 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3185 | 11 | * GNU General Public License for more details. | ||
3186 | 12 | * | ||
3187 | 13 | * You should have received a copy of the GNU General Public License | ||
3188 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3189 | 15 | */ | ||
3190 | 16 | |||
3191 | 17 | #include "MockDevice.h" | ||
3192 | 18 | |||
3193 | 19 | MockDevice::MockDevice(QObject *parent) | ||
3194 | 20 | : QObject(parent) | ||
3195 | 21 | , m_ts(new MockTemplateStore(this)) | ||
3196 | 22 | { | ||
3197 | 23 | } | ||
3198 | 24 | |||
3199 | 25 | MockTemplateStore* MockDevice::templateStore() | ||
3200 | 26 | { | ||
3201 | 27 | return m_ts; | ||
3202 | 28 | } | ||
3203 | 29 | |||
3204 | 30 | #include "MockDevice.moc" | ||
3205 | 0 | 31 | ||
3206 | === added file 'tests/qmltests/mocks/Biometryd/MockDevice.h' | |||
3207 | --- tests/qmltests/mocks/Biometryd/MockDevice.h 1970-01-01 00:00:00 +0000 | |||
3208 | +++ tests/qmltests/mocks/Biometryd/MockDevice.h 2016-06-15 10:46:42 +0000 | |||
3209 | @@ -0,0 +1,38 @@ | |||
3210 | 1 | /* | ||
3211 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3212 | 3 | * | ||
3213 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3214 | 5 | * it under the terms of the GNU General Public License as published by | ||
3215 | 6 | * the Free Software Foundation; version 3. | ||
3216 | 7 | * | ||
3217 | 8 | * This program is distributed in the hope that it will be useful, | ||
3218 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3219 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3220 | 11 | * GNU General Public License for more details. | ||
3221 | 12 | * | ||
3222 | 13 | * You should have received a copy of the GNU General Public License | ||
3223 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3224 | 15 | */ | ||
3225 | 16 | |||
3226 | 17 | #ifndef MOCK_DEVICE_H | ||
3227 | 18 | #define MOCK_DEVICE_H | ||
3228 | 19 | |||
3229 | 20 | #include <QObject> | ||
3230 | 21 | #include "MockTemplateStore.h" | ||
3231 | 22 | |||
3232 | 23 | class MockDevice : public QObject | ||
3233 | 24 | { | ||
3234 | 25 | Q_OBJECT | ||
3235 | 26 | Q_DISABLE_COPY(MockDevice) | ||
3236 | 27 | |||
3237 | 28 | public: | ||
3238 | 29 | explicit MockDevice(QObject *parent = 0); | ||
3239 | 30 | Q_PROPERTY(MockTemplateStore* templateStore READ templateStore CONSTANT) | ||
3240 | 31 | |||
3241 | 32 | MockTemplateStore* templateStore(); | ||
3242 | 33 | |||
3243 | 34 | private: | ||
3244 | 35 | MockTemplateStore* m_ts; | ||
3245 | 36 | }; | ||
3246 | 37 | |||
3247 | 38 | #endif // MOCK_DEVICE_H | ||
3248 | 0 | 39 | ||
3249 | === added file 'tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp' | |||
3250 | --- tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp 1970-01-01 00:00:00 +0000 | |||
3251 | +++ tests/qmltests/mocks/Biometryd/MockFingerprintReader.cpp 2016-06-15 10:46:42 +0000 | |||
3252 | @@ -0,0 +1,49 @@ | |||
3253 | 1 | /* | ||
3254 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3255 | 3 | * | ||
3256 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3257 | 5 | * it under the terms of the GNU General Public License as published by | ||
3258 | 6 | * the Free Software Foundation; version 3. | ||
3259 | 7 | * | ||
3260 | 8 | * This program is distributed in the hope that it will be useful, | ||
3261 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3262 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3263 | 11 | * GNU General Public License for more details. | ||
3264 | 12 | * | ||
3265 | 13 | * You should have received a copy of the GNU General Public License | ||
3266 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3267 | 15 | */ | ||
3268 | 16 | |||
3269 | 17 | #include "MockFingerprintReader.h" | ||
3270 | 18 | |||
3271 | 19 | MockFingerprintReader::MockFingerprintReader(QObject *parent) | ||
3272 | 20 | : QObject(parent) | ||
3273 | 21 | { | ||
3274 | 22 | } | ||
3275 | 23 | |||
3276 | 24 | QString MockFingerprintReader::isFingerPresent() const | ||
3277 | 25 | { | ||
3278 | 26 | return "isFingerPresent"; | ||
3279 | 27 | } | ||
3280 | 28 | |||
3281 | 29 | QString MockFingerprintReader::hasMainClusterIdentified() const | ||
3282 | 30 | { | ||
3283 | 31 | return "hasMainClusterIdentified"; | ||
3284 | 32 | } | ||
3285 | 33 | |||
3286 | 34 | QString MockFingerprintReader::suggestedNextDirection() const | ||
3287 | 35 | { | ||
3288 | 36 | return "suggestedNextDirection"; | ||
3289 | 37 | } | ||
3290 | 38 | |||
3291 | 39 | QString MockFingerprintReader::estimatedFingerSize() const | ||
3292 | 40 | { | ||
3293 | 41 | return "estimatedFingerSize"; | ||
3294 | 42 | } | ||
3295 | 43 | |||
3296 | 44 | QString MockFingerprintReader::masks() const | ||
3297 | 45 | { | ||
3298 | 46 | return "masks"; | ||
3299 | 47 | } | ||
3300 | 48 | |||
3301 | 49 | #include "MockFingerprintReader.moc" | ||
3302 | 0 | 50 | ||
3303 | === added file 'tests/qmltests/mocks/Biometryd/MockFingerprintReader.h' | |||
3304 | --- tests/qmltests/mocks/Biometryd/MockFingerprintReader.h 1970-01-01 00:00:00 +0000 | |||
3305 | +++ tests/qmltests/mocks/Biometryd/MockFingerprintReader.h 2016-06-15 10:46:42 +0000 | |||
3306 | @@ -0,0 +1,65 @@ | |||
3307 | 1 | /* | ||
3308 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3309 | 3 | * | ||
3310 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3311 | 5 | * it under the terms of the GNU General Public License as published by | ||
3312 | 6 | * the Free Software Foundation; version 3. | ||
3313 | 7 | * | ||
3314 | 8 | * This program is distributed in the hope that it will be useful, | ||
3315 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3316 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3317 | 11 | * GNU General Public License for more details. | ||
3318 | 12 | * | ||
3319 | 13 | * You should have received a copy of the GNU General Public License | ||
3320 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3321 | 15 | */ | ||
3322 | 16 | |||
3323 | 17 | #ifndef MOCK_FINGERPRINTREADER_H | ||
3324 | 18 | #define MOCK_FINGERPRINTREADER_H | ||
3325 | 19 | |||
3326 | 20 | #include <QObject> | ||
3327 | 21 | #include <QString> | ||
3328 | 22 | #include <QVariant> | ||
3329 | 23 | #include <QList> | ||
3330 | 24 | #include <QRect> | ||
3331 | 25 | |||
3332 | 26 | class MockFingerprintReader : public QObject | ||
3333 | 27 | |||
3334 | 28 | { | ||
3335 | 29 | Q_OBJECT | ||
3336 | 30 | Q_DISABLE_COPY(MockFingerprintReader) | ||
3337 | 31 | Q_ENUMS(Direction) | ||
3338 | 32 | Q_PROPERTY(QString isFingerPresent READ isFingerPresent) | ||
3339 | 33 | Q_PROPERTY(QString hasMainClusterIdentified READ hasMainClusterIdentified) | ||
3340 | 34 | Q_PROPERTY(QString suggestedNextDirection READ suggestedNextDirection) | ||
3341 | 35 | Q_PROPERTY(QString masks READ masks) | ||
3342 | 36 | |||
3343 | 37 | public: | ||
3344 | 38 | explicit MockFingerprintReader(QObject *parent = 0); | ||
3345 | 39 | |||
3346 | 40 | enum class Direction | ||
3347 | 41 | { | ||
3348 | 42 | NotAvailable, | ||
3349 | 43 | SouthWest, | ||
3350 | 44 | South, | ||
3351 | 45 | SouthEast, | ||
3352 | 46 | NorthWest, | ||
3353 | 47 | North, | ||
3354 | 48 | NorthEast, | ||
3355 | 49 | East, | ||
3356 | 50 | West | ||
3357 | 51 | }; | ||
3358 | 52 | |||
3359 | 53 | Q_INVOKABLE QString isFingerPresent() const; | ||
3360 | 54 | Q_INVOKABLE QString hasMainClusterIdentified() const; | ||
3361 | 55 | Q_INVOKABLE QString suggestedNextDirection() const; | ||
3362 | 56 | Q_INVOKABLE QString estimatedFingerSize() const; | ||
3363 | 57 | Q_INVOKABLE QString masks() const; | ||
3364 | 58 | |||
3365 | 59 | |||
3366 | 60 | Q_SIGNALS: | ||
3367 | 61 | void succeeded(const QVariant &result); | ||
3368 | 62 | void failed(const QString &reason); | ||
3369 | 63 | }; | ||
3370 | 64 | |||
3371 | 65 | #endif // MOCK_FINGERPRINTREADER_H | ||
3372 | 0 | 66 | ||
3373 | === added file 'tests/qmltests/mocks/Biometryd/MockObserver.cpp' | |||
3374 | --- tests/qmltests/mocks/Biometryd/MockObserver.cpp 1970-01-01 00:00:00 +0000 | |||
3375 | +++ tests/qmltests/mocks/Biometryd/MockObserver.cpp 2016-06-15 10:46:42 +0000 | |||
3376 | @@ -0,0 +1,88 @@ | |||
3377 | 1 | /* | ||
3378 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3379 | 3 | * | ||
3380 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3381 | 5 | * it under the terms of the GNU General Public License as published by | ||
3382 | 6 | * the Free Software Foundation; version 3. | ||
3383 | 7 | * | ||
3384 | 8 | * This program is distributed in the hope that it will be useful, | ||
3385 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3386 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3387 | 11 | * GNU General Public License for more details. | ||
3388 | 12 | * | ||
3389 | 13 | * You should have received a copy of the GNU General Public License | ||
3390 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3391 | 15 | */ | ||
3392 | 16 | |||
3393 | 17 | #include "MockObserver.h" | ||
3394 | 18 | |||
3395 | 19 | class Result : public QObject | ||
3396 | 20 | { | ||
3397 | 21 | Q_OBJECT | ||
3398 | 22 | Q_PROPERTY(unsigned int uid READ uid CONSTANT) | ||
3399 | 23 | |||
3400 | 24 | public: | ||
3401 | 25 | explicit Result(unsigned int uid, QObject *parent = 0) | ||
3402 | 26 | : QObject(parent), m_uid(uid) | ||
3403 | 27 | {} | ||
3404 | 28 | |||
3405 | 29 | unsigned int uid() const { return m_uid; } | ||
3406 | 30 | |||
3407 | 31 | private: | ||
3408 | 32 | unsigned int m_uid; | ||
3409 | 33 | }; | ||
3410 | 34 | |||
3411 | 35 | MockObserver::MockObserver(QObject *parent) | ||
3412 | 36 | : QObject(parent) | ||
3413 | 37 | { | ||
3414 | 38 | } | ||
3415 | 39 | |||
3416 | 40 | void MockObserver::mockSize(int size, const QString &error) | ||
3417 | 41 | { | ||
3418 | 42 | if (error.isEmpty()) | ||
3419 | 43 | Q_EMIT succeeded(QVariant::fromValue(size)); | ||
3420 | 44 | else | ||
3421 | 45 | Q_EMIT failed(error); | ||
3422 | 46 | } | ||
3423 | 47 | |||
3424 | 48 | void MockObserver::mockEnroll(const QString &templateId, const QString &error) | ||
3425 | 49 | { | ||
3426 | 50 | if (error.isEmpty()) | ||
3427 | 51 | Q_EMIT succeeded(templateId); | ||
3428 | 52 | else | ||
3429 | 53 | Q_EMIT failed(error); | ||
3430 | 54 | } | ||
3431 | 55 | |||
3432 | 56 | void MockObserver::mockEnrollProgress(double percent, | ||
3433 | 57 | const QVariantMap& details) | ||
3434 | 58 | { | ||
3435 | 59 | Q_EMIT progressed(percent, details); | ||
3436 | 60 | } | ||
3437 | 61 | |||
3438 | 62 | void MockObserver::mockClearance(const QString &error) | ||
3439 | 63 | { | ||
3440 | 64 | if (error.isEmpty()) | ||
3441 | 65 | Q_EMIT succeeded(QVariant()); | ||
3442 | 66 | else | ||
3443 | 67 | Q_EMIT failed(error); | ||
3444 | 68 | } | ||
3445 | 69 | |||
3446 | 70 | void MockObserver::mockRemoval(const QString &templateId, | ||
3447 | 71 | const QString &error) | ||
3448 | 72 | { | ||
3449 | 73 | if (error.isEmpty()) | ||
3450 | 74 | Q_EMIT succeeded(templateId); | ||
3451 | 75 | else | ||
3452 | 76 | Q_EMIT failed(error); | ||
3453 | 77 | } | ||
3454 | 78 | |||
3455 | 79 | void MockObserver::mockList(const QStringList &templateIds, | ||
3456 | 80 | const QString &error) | ||
3457 | 81 | { | ||
3458 | 82 | if (error.isEmpty()) | ||
3459 | 83 | Q_EMIT succeeded(templateIds); | ||
3460 | 84 | else | ||
3461 | 85 | Q_EMIT failed(error); | ||
3462 | 86 | } | ||
3463 | 87 | |||
3464 | 88 | #include "MockObserver.moc" | ||
3465 | 0 | 89 | ||
3466 | === added file 'tests/qmltests/mocks/Biometryd/MockObserver.h' | |||
3467 | --- tests/qmltests/mocks/Biometryd/MockObserver.h 1970-01-01 00:00:00 +0000 | |||
3468 | +++ tests/qmltests/mocks/Biometryd/MockObserver.h 2016-06-15 10:46:42 +0000 | |||
3469 | @@ -0,0 +1,52 @@ | |||
3470 | 1 | /* | ||
3471 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3472 | 3 | * | ||
3473 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3474 | 5 | * it under the terms of the GNU General Public License as published by | ||
3475 | 6 | * the Free Software Foundation; version 3. | ||
3476 | 7 | * | ||
3477 | 8 | * This program is distributed in the hope that it will be useful, | ||
3478 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3479 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3480 | 11 | * GNU General Public License for more details. | ||
3481 | 12 | * | ||
3482 | 13 | * You should have received a copy of the GNU General Public License | ||
3483 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3484 | 15 | */ | ||
3485 | 16 | |||
3486 | 17 | #ifndef MOCK_OBSERVER_H | ||
3487 | 18 | #define MOCK_OBSERVER_H | ||
3488 | 19 | |||
3489 | 20 | #include <QObject> | ||
3490 | 21 | #include <QString> | ||
3491 | 22 | #include <QVariant> | ||
3492 | 23 | |||
3493 | 24 | class MockObserver : public QObject | ||
3494 | 25 | { | ||
3495 | 26 | Q_OBJECT | ||
3496 | 27 | Q_DISABLE_COPY(MockObserver) | ||
3497 | 28 | |||
3498 | 29 | public: | ||
3499 | 30 | explicit MockObserver(QObject *parent = 0); | ||
3500 | 31 | |||
3501 | 32 | Q_INVOKABLE void mockSize(int size, const QString &error); // only in mock | ||
3502 | 33 | Q_INVOKABLE void mockEnroll(const QString &templateId, | ||
3503 | 34 | const QString &error); // only in mock | ||
3504 | 35 | Q_INVOKABLE void mockEnrollProgress(double percent, | ||
3505 | 36 | const QVariantMap& details); // only in mock | ||
3506 | 37 | Q_INVOKABLE void mockClearance(const QString &error); // only in mock | ||
3507 | 38 | Q_INVOKABLE void mockRemoval(const QString &templateId, | ||
3508 | 39 | const QString &error); // only in mock | ||
3509 | 40 | Q_INVOKABLE void mockList(const QStringList &templateIds, | ||
3510 | 41 | const QString &error); // only in mock | ||
3511 | 42 | |||
3512 | 43 | |||
3513 | 44 | Q_SIGNALS: | ||
3514 | 45 | void progressed(double percent, const QVariantMap& details); | ||
3515 | 46 | void succeeded(const QVariant &result); | ||
3516 | 47 | void failed(const QString &reason); | ||
3517 | 48 | void canceled(const QString& reason); | ||
3518 | 49 | void started(); | ||
3519 | 50 | }; | ||
3520 | 51 | |||
3521 | 52 | #endif // MOCK_OBSERVER_H | ||
3522 | 0 | 53 | ||
3523 | === added file 'tests/qmltests/mocks/Biometryd/MockOperation.cpp' | |||
3524 | --- tests/qmltests/mocks/Biometryd/MockOperation.cpp 1970-01-01 00:00:00 +0000 | |||
3525 | +++ tests/qmltests/mocks/Biometryd/MockOperation.cpp 2016-06-15 10:46:42 +0000 | |||
3526 | @@ -0,0 +1,34 @@ | |||
3527 | 1 | /* | ||
3528 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3529 | 3 | * | ||
3530 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3531 | 5 | * it under the terms of the GNU General Public License as published by | ||
3532 | 6 | * the Free Software Foundation; version 3. | ||
3533 | 7 | * | ||
3534 | 8 | * This program is distributed in the hope that it will be useful, | ||
3535 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3536 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3537 | 11 | * GNU General Public License for more details. | ||
3538 | 12 | * | ||
3539 | 13 | * You should have received a copy of the GNU General Public License | ||
3540 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3541 | 15 | */ | ||
3542 | 16 | |||
3543 | 17 | #include "MockOperation.h" | ||
3544 | 18 | |||
3545 | 19 | MockOperation::MockOperation(QObject *parent) : QObject(parent) | ||
3546 | 20 | { | ||
3547 | 21 | } | ||
3548 | 22 | |||
3549 | 23 | bool MockOperation::start(MockObserver *observer) | ||
3550 | 24 | { | ||
3551 | 25 | Q_UNUSED(observer); | ||
3552 | 26 | return true; | ||
3553 | 27 | } | ||
3554 | 28 | |||
3555 | 29 | bool MockOperation::cancel() | ||
3556 | 30 | { | ||
3557 | 31 | return true; | ||
3558 | 32 | } | ||
3559 | 33 | |||
3560 | 34 | #include "MockOperation.moc" | ||
3561 | 0 | 35 | ||
3562 | === added file 'tests/qmltests/mocks/Biometryd/MockOperation.h' | |||
3563 | --- tests/qmltests/mocks/Biometryd/MockOperation.h 1970-01-01 00:00:00 +0000 | |||
3564 | +++ tests/qmltests/mocks/Biometryd/MockOperation.h 2016-06-15 10:46:42 +0000 | |||
3565 | @@ -0,0 +1,36 @@ | |||
3566 | 1 | /* | ||
3567 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3568 | 3 | * | ||
3569 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3570 | 5 | * it under the terms of the GNU General Public License as published by | ||
3571 | 6 | * the Free Software Foundation; version 3. | ||
3572 | 7 | * | ||
3573 | 8 | * This program is distributed in the hope that it will be useful, | ||
3574 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3575 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3576 | 11 | * GNU General Public License for more details. | ||
3577 | 12 | * | ||
3578 | 13 | * You should have received a copy of the GNU General Public License | ||
3579 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3580 | 15 | */ | ||
3581 | 16 | |||
3582 | 17 | #ifndef MOCK_OPERATION_H | ||
3583 | 18 | #define MOCK_OPERATION_H | ||
3584 | 19 | |||
3585 | 20 | #include <QObject> | ||
3586 | 21 | |||
3587 | 22 | class MockObserver; | ||
3588 | 23 | |||
3589 | 24 | class MockOperation : public QObject | ||
3590 | 25 | { | ||
3591 | 26 | Q_OBJECT | ||
3592 | 27 | Q_DISABLE_COPY(MockOperation) | ||
3593 | 28 | |||
3594 | 29 | public: | ||
3595 | 30 | explicit MockOperation(QObject *parent = 0); | ||
3596 | 31 | |||
3597 | 32 | Q_INVOKABLE bool start(MockObserver* observer); | ||
3598 | 33 | Q_INVOKABLE bool cancel(); | ||
3599 | 34 | }; | ||
3600 | 35 | |||
3601 | 36 | #endif // MOCK_OPERATION_H | ||
3602 | 0 | 37 | ||
3603 | === added file 'tests/qmltests/mocks/Biometryd/MockService.cpp' | |||
3604 | --- tests/qmltests/mocks/Biometryd/MockService.cpp 1970-01-01 00:00:00 +0000 | |||
3605 | +++ tests/qmltests/mocks/Biometryd/MockService.cpp 2016-06-15 10:46:42 +0000 | |||
3606 | @@ -0,0 +1,42 @@ | |||
3607 | 1 | /* | ||
3608 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3609 | 3 | * | ||
3610 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3611 | 5 | * it under the terms of the GNU General Public License as published by | ||
3612 | 6 | * the Free Software Foundation; version 3. | ||
3613 | 7 | * | ||
3614 | 8 | * This program is distributed in the hope that it will be useful, | ||
3615 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3616 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3617 | 11 | * GNU General Public License for more details. | ||
3618 | 12 | * | ||
3619 | 13 | * You should have received a copy of the GNU General Public License | ||
3620 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3621 | 15 | */ | ||
3622 | 16 | |||
3623 | 17 | #include "MockService.h" | ||
3624 | 18 | |||
3625 | 19 | MockService::MockService(QObject *parent) | ||
3626 | 20 | : QObject(parent) | ||
3627 | 21 | , m_device(new MockDevice(this)) | ||
3628 | 22 | , m_available(false) | ||
3629 | 23 | { | ||
3630 | 24 | } | ||
3631 | 25 | |||
3632 | 26 | MockDevice* MockService::defaultDevice() | ||
3633 | 27 | { | ||
3634 | 28 | return m_device; | ||
3635 | 29 | } | ||
3636 | 30 | |||
3637 | 31 | bool MockService::isAvailable() const | ||
3638 | 32 | { | ||
3639 | 33 | return m_available; | ||
3640 | 34 | } | ||
3641 | 35 | |||
3642 | 36 | void MockService::setAvailable(const bool available) | ||
3643 | 37 | { | ||
3644 | 38 | m_available = available; | ||
3645 | 39 | Q_EMIT (availableChanged(available)); | ||
3646 | 40 | } | ||
3647 | 41 | |||
3648 | 42 | #include "MockService.moc" | ||
3649 | 0 | 43 | ||
3650 | === added file 'tests/qmltests/mocks/Biometryd/MockService.h' | |||
3651 | --- tests/qmltests/mocks/Biometryd/MockService.h 1970-01-01 00:00:00 +0000 | |||
3652 | +++ tests/qmltests/mocks/Biometryd/MockService.h 2016-06-15 10:46:42 +0000 | |||
3653 | @@ -0,0 +1,46 @@ | |||
3654 | 1 | /* | ||
3655 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3656 | 3 | * | ||
3657 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3658 | 5 | * it under the terms of the GNU General Public License as published by | ||
3659 | 6 | * the Free Software Foundation; version 3. | ||
3660 | 7 | * | ||
3661 | 8 | * This program is distributed in the hope that it will be useful, | ||
3662 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3663 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3664 | 11 | * GNU General Public License for more details. | ||
3665 | 12 | * | ||
3666 | 13 | * You should have received a copy of the GNU General Public License | ||
3667 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3668 | 15 | */ | ||
3669 | 16 | |||
3670 | 17 | #ifndef MOCK_SERVICE_H | ||
3671 | 18 | #define MOCK_SERVICE_H | ||
3672 | 19 | |||
3673 | 20 | #include <QObject> | ||
3674 | 21 | |||
3675 | 22 | #include "MockDevice.h" | ||
3676 | 23 | |||
3677 | 24 | class MockService : public QObject | ||
3678 | 25 | { | ||
3679 | 26 | Q_OBJECT | ||
3680 | 27 | Q_DISABLE_COPY(MockService) | ||
3681 | 28 | |||
3682 | 29 | public: | ||
3683 | 30 | explicit MockService(QObject *parent = 0); | ||
3684 | 31 | Q_PROPERTY(MockDevice* defaultDevice READ defaultDevice CONSTANT) | ||
3685 | 32 | Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged) | ||
3686 | 33 | |||
3687 | 34 | MockDevice* defaultDevice(); | ||
3688 | 35 | bool isAvailable() const; | ||
3689 | 36 | Q_INVOKABLE void setAvailable(const bool available); // mock only | ||
3690 | 37 | |||
3691 | 38 | Q_SIGNALS: | ||
3692 | 39 | void availableChanged(bool); | ||
3693 | 40 | |||
3694 | 41 | private: | ||
3695 | 42 | MockDevice* m_device; | ||
3696 | 43 | bool m_available; | ||
3697 | 44 | }; | ||
3698 | 45 | |||
3699 | 46 | #endif // MOCK_SERVICE_H | ||
3700 | 0 | 47 | ||
3701 | === added file 'tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp' | |||
3702 | --- tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp 1970-01-01 00:00:00 +0000 | |||
3703 | +++ tests/qmltests/mocks/Biometryd/MockTemplateStore.cpp 2016-06-15 10:46:42 +0000 | |||
3704 | @@ -0,0 +1,56 @@ | |||
3705 | 1 | /* | ||
3706 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3707 | 3 | * | ||
3708 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3709 | 5 | * it under the terms of the GNU General Public License as published by | ||
3710 | 6 | * the Free Software Foundation; version 3. | ||
3711 | 7 | * | ||
3712 | 8 | * This program is distributed in the hope that it will be useful, | ||
3713 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3714 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3715 | 11 | * GNU General Public License for more details. | ||
3716 | 12 | * | ||
3717 | 13 | * You should have received a copy of the GNU General Public License | ||
3718 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3719 | 15 | */ | ||
3720 | 16 | |||
3721 | 17 | #include "MockTemplateStore.h" | ||
3722 | 18 | |||
3723 | 19 | MockTemplateStore::MockTemplateStore(QObject *parent) | ||
3724 | 20 | { | ||
3725 | 21 | Q_UNUSED(parent); | ||
3726 | 22 | } | ||
3727 | 23 | |||
3728 | 24 | MockSizeQuery* MockTemplateStore::size(MockUser* user) | ||
3729 | 25 | { | ||
3730 | 26 | Q_UNUSED(user); | ||
3731 | 27 | return new MockSizeQuery(this); | ||
3732 | 28 | } | ||
3733 | 29 | |||
3734 | 30 | MockEnrollment* MockTemplateStore::enroll(MockUser* user) | ||
3735 | 31 | { | ||
3736 | 32 | Q_UNUSED(user); | ||
3737 | 33 | return new MockEnrollment(this); | ||
3738 | 34 | } | ||
3739 | 35 | |||
3740 | 36 | MockClearance* MockTemplateStore::clear(MockUser* user) | ||
3741 | 37 | { | ||
3742 | 38 | Q_UNUSED(user); | ||
3743 | 39 | return new MockClearance(this); | ||
3744 | 40 | } | ||
3745 | 41 | |||
3746 | 42 | MockRemoval* MockTemplateStore::remove(MockUser* user, | ||
3747 | 43 | const QString &templateId) | ||
3748 | 44 | { | ||
3749 | 45 | Q_UNUSED(user); | ||
3750 | 46 | Q_UNUSED(templateId); | ||
3751 | 47 | return new MockRemoval(this); | ||
3752 | 48 | } | ||
3753 | 49 | |||
3754 | 50 | MockList* MockTemplateStore::list(MockUser* user) | ||
3755 | 51 | { | ||
3756 | 52 | Q_UNUSED(user); | ||
3757 | 53 | return new MockList(this); | ||
3758 | 54 | } | ||
3759 | 55 | |||
3760 | 56 | #include "MockTemplateStore.moc" | ||
3761 | 0 | 57 | ||
3762 | === added file 'tests/qmltests/mocks/Biometryd/MockTemplateStore.h' | |||
3763 | --- tests/qmltests/mocks/Biometryd/MockTemplateStore.h 1970-01-01 00:00:00 +0000 | |||
3764 | +++ tests/qmltests/mocks/Biometryd/MockTemplateStore.h 2016-06-15 10:46:42 +0000 | |||
3765 | @@ -0,0 +1,86 @@ | |||
3766 | 1 | /* | ||
3767 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3768 | 3 | * | ||
3769 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3770 | 5 | * it under the terms of the GNU General Public License as published by | ||
3771 | 6 | * the Free Software Foundation; version 3. | ||
3772 | 7 | * | ||
3773 | 8 | * This program is distributed in the hope that it will be useful, | ||
3774 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3775 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3776 | 11 | * GNU General Public License for more details. | ||
3777 | 12 | * | ||
3778 | 13 | * You should have received a copy of the GNU General Public License | ||
3779 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3780 | 15 | */ | ||
3781 | 16 | |||
3782 | 17 | #ifndef MOCK_TEMPLATESTORE_H | ||
3783 | 18 | #define MOCK_TEMPLATESTORE_H | ||
3784 | 19 | |||
3785 | 20 | #include <QObject> | ||
3786 | 21 | #include "MockOperation.h" | ||
3787 | 22 | |||
3788 | 23 | class MockUser; | ||
3789 | 24 | |||
3790 | 25 | class MockSizeQuery : public MockOperation | ||
3791 | 26 | { | ||
3792 | 27 | Q_OBJECT | ||
3793 | 28 | public: | ||
3794 | 29 | MockSizeQuery(QObject *parent) : MockOperation(parent) | ||
3795 | 30 | { | ||
3796 | 31 | } | ||
3797 | 32 | }; | ||
3798 | 33 | |||
3799 | 34 | class MockEnrollment : public MockOperation | ||
3800 | 35 | { | ||
3801 | 36 | Q_OBJECT | ||
3802 | 37 | public: | ||
3803 | 38 | MockEnrollment(QObject *parent) : MockOperation(parent) | ||
3804 | 39 | { | ||
3805 | 40 | } | ||
3806 | 41 | }; | ||
3807 | 42 | |||
3808 | 43 | class MockClearance : public MockOperation | ||
3809 | 44 | { | ||
3810 | 45 | Q_OBJECT | ||
3811 | 46 | public: | ||
3812 | 47 | MockClearance(QObject *parent) : MockOperation(parent) | ||
3813 | 48 | { | ||
3814 | 49 | } | ||
3815 | 50 | }; | ||
3816 | 51 | |||
3817 | 52 | class MockRemoval : public MockOperation | ||
3818 | 53 | { | ||
3819 | 54 | Q_OBJECT | ||
3820 | 55 | public: | ||
3821 | 56 | MockRemoval(QObject *parent) : MockOperation(parent) | ||
3822 | 57 | { | ||
3823 | 58 | } | ||
3824 | 59 | }; | ||
3825 | 60 | |||
3826 | 61 | class MockList : public MockOperation | ||
3827 | 62 | { | ||
3828 | 63 | Q_OBJECT | ||
3829 | 64 | public: | ||
3830 | 65 | MockList(QObject *parent) : MockOperation(parent) | ||
3831 | 66 | { | ||
3832 | 67 | } | ||
3833 | 68 | }; | ||
3834 | 69 | |||
3835 | 70 | class MockTemplateStore : public QObject | ||
3836 | 71 | { | ||
3837 | 72 | Q_OBJECT | ||
3838 | 73 | Q_DISABLE_COPY(MockTemplateStore) | ||
3839 | 74 | |||
3840 | 75 | public: | ||
3841 | 76 | explicit MockTemplateStore(QObject *parent = 0); | ||
3842 | 77 | |||
3843 | 78 | Q_INVOKABLE MockSizeQuery* size(MockUser* user); | ||
3844 | 79 | Q_INVOKABLE MockEnrollment* enroll(MockUser* user); | ||
3845 | 80 | Q_INVOKABLE MockClearance* clear(MockUser* user); | ||
3846 | 81 | Q_INVOKABLE MockRemoval* remove(MockUser* user, | ||
3847 | 82 | const QString &templateId); | ||
3848 | 83 | Q_INVOKABLE MockList* list(MockUser* user); | ||
3849 | 84 | }; | ||
3850 | 85 | |||
3851 | 86 | #endif // MOCK_TEMPLATESTORE_H | ||
3852 | 0 | 87 | ||
3853 | === added file 'tests/qmltests/mocks/Biometryd/MockUser.cpp' | |||
3854 | --- tests/qmltests/mocks/Biometryd/MockUser.cpp 1970-01-01 00:00:00 +0000 | |||
3855 | +++ tests/qmltests/mocks/Biometryd/MockUser.cpp 2016-06-15 10:46:42 +0000 | |||
3856 | @@ -0,0 +1,33 @@ | |||
3857 | 1 | /* | ||
3858 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3859 | 3 | * | ||
3860 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3861 | 5 | * it under the terms of the GNU General Public License as published by | ||
3862 | 6 | * the Free Software Foundation; version 3. | ||
3863 | 7 | * | ||
3864 | 8 | * This program is distributed in the hope that it will be useful, | ||
3865 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3866 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3867 | 11 | * GNU General Public License for more details. | ||
3868 | 12 | * | ||
3869 | 13 | * You should have received a copy of the GNU General Public License | ||
3870 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3871 | 15 | */ | ||
3872 | 16 | |||
3873 | 17 | #include "MockUser.h" | ||
3874 | 18 | |||
3875 | 19 | MockUser::MockUser(QObject *parent) : QObject(parent) | ||
3876 | 20 | { | ||
3877 | 21 | } | ||
3878 | 22 | |||
3879 | 23 | int MockUser::uid() const | ||
3880 | 24 | { | ||
3881 | 25 | return m_uid; | ||
3882 | 26 | } | ||
3883 | 27 | |||
3884 | 28 | void MockUser::setUid(const int &uid) | ||
3885 | 29 | { | ||
3886 | 30 | m_uid = uid; | ||
3887 | 31 | } | ||
3888 | 32 | |||
3889 | 33 | #include "MockUser.moc" | ||
3890 | 0 | 34 | ||
3891 | === added file 'tests/qmltests/mocks/Biometryd/MockUser.h' | |||
3892 | --- tests/qmltests/mocks/Biometryd/MockUser.h 1970-01-01 00:00:00 +0000 | |||
3893 | +++ tests/qmltests/mocks/Biometryd/MockUser.h 2016-06-15 10:46:42 +0000 | |||
3894 | @@ -0,0 +1,38 @@ | |||
3895 | 1 | /* | ||
3896 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
3897 | 3 | * | ||
3898 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3899 | 5 | * it under the terms of the GNU General Public License as published by | ||
3900 | 6 | * the Free Software Foundation; version 3. | ||
3901 | 7 | * | ||
3902 | 8 | * This program is distributed in the hope that it will be useful, | ||
3903 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3904 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3905 | 11 | * GNU General Public License for more details. | ||
3906 | 12 | * | ||
3907 | 13 | * You should have received a copy of the GNU General Public License | ||
3908 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3909 | 15 | */ | ||
3910 | 16 | |||
3911 | 17 | #ifndef MOCK_USER_H | ||
3912 | 18 | #define MOCK_USER_H | ||
3913 | 19 | |||
3914 | 20 | #include <QObject> | ||
3915 | 21 | |||
3916 | 22 | class MockUser : public QObject | ||
3917 | 23 | { | ||
3918 | 24 | Q_OBJECT | ||
3919 | 25 | Q_DISABLE_COPY(MockUser) | ||
3920 | 26 | |||
3921 | 27 | public: | ||
3922 | 28 | explicit MockUser(QObject *parent = 0); | ||
3923 | 29 | Q_PROPERTY(int uid READ uid WRITE setUid) | ||
3924 | 30 | |||
3925 | 31 | int uid() const; | ||
3926 | 32 | void setUid(const int &uid); | ||
3927 | 33 | |||
3928 | 34 | private: | ||
3929 | 35 | int m_uid = 0; | ||
3930 | 36 | }; | ||
3931 | 37 | |||
3932 | 38 | #endif // MOCK_USER_H | ||
3933 | 0 | 39 | ||
3934 | === added file 'tests/qmltests/mocks/Biometryd/plugin.cpp' | |||
3935 | --- tests/qmltests/mocks/Biometryd/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
3936 | +++ tests/qmltests/mocks/Biometryd/plugin.cpp 2016-06-15 10:46:42 +0000 | |||
3937 | @@ -0,0 +1,60 @@ | |||
3938 | 1 | /* | ||
3939 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
3940 | 3 | * | ||
3941 | 4 | * This program is free software; you can redistribute it and/or modify | ||
3942 | 5 | * it under the terms of the GNU General Public License as published by | ||
3943 | 6 | * the Free Software Foundation; version 3. | ||
3944 | 7 | * | ||
3945 | 8 | * This program is distributed in the hope that it will be useful, | ||
3946 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3947 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3948 | 11 | * GNU General Public License for more details. | ||
3949 | 12 | * | ||
3950 | 13 | * You should have received a copy of the GNU General Public License | ||
3951 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3952 | 15 | */ | ||
3953 | 16 | |||
3954 | 17 | #include "plugin.h" | ||
3955 | 18 | |||
3956 | 19 | #include "MockDevice.h" | ||
3957 | 20 | #include "MockFingerprintReader.h" | ||
3958 | 21 | #include "MockObserver.h" | ||
3959 | 22 | #include "MockOperation.h" | ||
3960 | 23 | #include "MockService.h" | ||
3961 | 24 | #include "MockTemplateStore.h" | ||
3962 | 25 | #include "MockUser.h" | ||
3963 | 26 | |||
3964 | 27 | #include <QtQml> | ||
3965 | 28 | |||
3966 | 29 | void BackendPlugin::registerTypes(const char *uri) | ||
3967 | 30 | { | ||
3968 | 31 | Q_ASSERT(uri == QLatin1String("Biometryd")); | ||
3969 | 32 | |||
3970 | 33 | qmlRegisterType<MockObserver>(uri, 0, 0, "Observer"); | ||
3971 | 34 | qmlRegisterType<MockUser>(uri, 0, 0, "User"); | ||
3972 | 35 | |||
3973 | 36 | qmlRegisterUncreatableType<MockDevice>(uri, 0, 0, "Device", "Rely on Biometryd.instance"); | ||
3974 | 37 | |||
3975 | 38 | qmlRegisterUncreatableType<MockOperation>(uri, 0, 0, "Operation", "Rely on Biometryd.instance"); | ||
3976 | 39 | qmlRegisterUncreatableType<MockSizeQuery>(uri, 0, 0, "SizeQuery", "Rely on Biometryd.instance"); | ||
3977 | 40 | qmlRegisterUncreatableType<MockEnrollment>(uri, 0, 0, "Enrollment", "Rely on Biometryd.instance"); | ||
3978 | 41 | qmlRegisterUncreatableType<MockClearance>(uri, 0, 0, "Clearance", "Rely on Biometryd.instance"); | ||
3979 | 42 | qmlRegisterUncreatableType<MockTemplateStore>(uri, 0, 0, "TemplateStore", "Rely on Biometryd.instance"); | ||
3980 | 43 | qmlRegisterUncreatableType<MockRemoval>(uri, 0, 0, "Removal", "Rely on Biometryd.instance"); | ||
3981 | 44 | qmlRegisterUncreatableType<MockList>(uri, 0, 0, "List", "Rely on Biometryd.instance"); | ||
3982 | 45 | |||
3983 | 46 | qmlRegisterSingletonType<MockService>( | ||
3984 | 47 | uri, 0, 0, "Biometryd", | ||
3985 | 48 | [](QQmlEngine*, QJSEngine*) -> QObject* | ||
3986 | 49 | { | ||
3987 | 50 | return new MockService; | ||
3988 | 51 | } | ||
3989 | 52 | ); | ||
3990 | 53 | qmlRegisterSingletonType<MockFingerprintReader>( | ||
3991 | 54 | uri, 0, 0, "FingerprintReader", | ||
3992 | 55 | [](QQmlEngine*, QJSEngine*) -> QObject* | ||
3993 | 56 | { | ||
3994 | 57 | return new MockFingerprintReader; | ||
3995 | 58 | } | ||
3996 | 59 | ); | ||
3997 | 60 | } | ||
3998 | 0 | 61 | ||
3999 | === added file 'tests/qmltests/mocks/Biometryd/plugin.h' | |||
4000 | --- tests/qmltests/mocks/Biometryd/plugin.h 1970-01-01 00:00:00 +0000 | |||
4001 | +++ tests/qmltests/mocks/Biometryd/plugin.h 2016-06-15 10:46:42 +0000 | |||
4002 | @@ -0,0 +1,31 @@ | |||
4003 | 1 | /* | ||
4004 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
4005 | 3 | * | ||
4006 | 4 | * This program is free software; you can redistribute it and/or modify | ||
4007 | 5 | * it under the terms of the GNU General Public License as published by | ||
4008 | 6 | * the Free Software Foundation; version 3. | ||
4009 | 7 | * | ||
4010 | 8 | * This program is distributed in the hope that it will be useful, | ||
4011 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4012 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4013 | 11 | * GNU General Public License for more details. | ||
4014 | 12 | * | ||
4015 | 13 | * You should have received a copy of the GNU General Public License | ||
4016 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4017 | 15 | */ | ||
4018 | 16 | |||
4019 | 17 | #ifndef MOCK_BIOMETRYD_PLUGIN_H | ||
4020 | 18 | #define MOCK_BIOMETRYD_PLUGIN_H | ||
4021 | 19 | |||
4022 | 20 | #include <QQmlExtensionPlugin> | ||
4023 | 21 | |||
4024 | 22 | class BackendPlugin : public QQmlExtensionPlugin | ||
4025 | 23 | { | ||
4026 | 24 | Q_OBJECT | ||
4027 | 25 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
4028 | 26 | |||
4029 | 27 | public: | ||
4030 | 28 | void registerTypes(const char *uri) override; | ||
4031 | 29 | }; | ||
4032 | 30 | |||
4033 | 31 | #endif // MOCK_BIOMETRYD_PLUGIN_H | ||
4034 | 0 | 32 | ||
4035 | === added file 'tests/qmltests/mocks/Biometryd/qmldir' | |||
4036 | --- tests/qmltests/mocks/Biometryd/qmldir 1970-01-01 00:00:00 +0000 | |||
4037 | +++ tests/qmltests/mocks/Biometryd/qmldir 2016-06-15 10:46:42 +0000 | |||
4038 | @@ -0,0 +1,2 @@ | |||
4039 | 1 | module Biometryd | ||
4040 | 2 | plugin MockBiometryd | ||
4041 | 0 | 3 | ||
4042 | === added file 'tests/qmltests/mocks/CMakeLists.txt' | |||
4043 | --- tests/qmltests/mocks/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4044 | +++ tests/qmltests/mocks/CMakeLists.txt 2016-06-15 10:46:42 +0000 | |||
4045 | @@ -0,0 +1,32 @@ | |||
4046 | 1 | include(QmlPlugins) | ||
4047 | 2 | |||
4048 | 3 | # Set up and optionally install a mock plugin for ubuntu-settings-components. | ||
4049 | 4 | # | ||
4050 | 5 | # add_usc_mock(plugin version path | ||
4051 | 6 | # [PREFIX string] # Install the plugin to the specified prefix under unity8 private plugin directory | ||
4052 | 7 | # [...] # See export_qmlfiles and export_qmlplugin documentation for more options | ||
4053 | 8 | # ) | ||
4054 | 9 | |||
4055 | 10 | macro(add_usc_mock PLUGIN VERSION PATH) | ||
4056 | 11 | set(single PREFIX) | ||
4057 | 12 | cmake_parse_arguments(MOCK "" "${single}" "" ${ARGN}) | ||
4058 | 13 | |||
4059 | 14 | if(MOCK_PREFIX) | ||
4060 | 15 | export_qmlfiles(${PLUGIN} ${PATH} | ||
4061 | 16 | DESTINATION ${SHELL_INSTALL_QML}/${MOCK_PREFIX} | ||
4062 | 17 | TARGET_PREFIX ${MOCK_PREFIX}-Mock | ||
4063 | 18 | ${MOCK_UNPARSED_ARGUMENTS} | ||
4064 | 19 | ) | ||
4065 | 20 | export_qmlplugin(${PLUGIN} ${VERSION} ${PATH} | ||
4066 | 21 | DESTINATION ${SHELL_INSTALL_QML}/${MOCK_PREFIX} | ||
4067 | 22 | TARGET_PREFIX ${MOCK_PREFIX}-Mock | ||
4068 | 23 | ${MOCK_UNPARSED_ARGUMENTS} | ||
4069 | 24 | ) | ||
4070 | 25 | else() | ||
4071 | 26 | export_qmlfiles(${PLUGIN} ${PATH} TARGET_PREFIX Mock ${MOCK_UNPARSED_ARGUMENTS}) | ||
4072 | 27 | export_qmlplugin(${PLUGIN} ${VERSION} ${PATH} TARGET_PREFIX Mock ${MOCK_UNPARSED_ARGUMENTS}) | ||
4073 | 28 | endif() | ||
4074 | 29 | endmacro() | ||
4075 | 30 | |||
4076 | 31 | add_subdirectory(Biometryd) | ||
4077 | 32 | add_subdirectory(GSettings.1.0) | ||
4078 | 0 | 33 | ||
4079 | === added directory 'tests/qmltests/mocks/GSettings.1.0' | |||
4080 | === added file 'tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt' | |||
4081 | --- tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4082 | +++ tests/qmltests/mocks/GSettings.1.0/CMakeLists.txt 2016-06-15 10:46:42 +0000 | |||
4083 | @@ -0,0 +1,20 @@ | |||
4084 | 1 | include_directories( | ||
4085 | 2 | ${CMAKE_CURRENT_BINARY_DIR} | ||
4086 | 3 | ${Qt5Core_INCLUDE_DIRS} | ||
4087 | 4 | ${Qt5Quick_INCLUDE_DIRS} | ||
4088 | 5 | ) | ||
4089 | 6 | |||
4090 | 7 | set(GSettingsQML_SOURCES | ||
4091 | 8 | fake_gsettings.cpp | ||
4092 | 9 | plugin.cpp | ||
4093 | 10 | ) | ||
4094 | 11 | |||
4095 | 12 | add_library(FakeGSettingsQml MODULE ${GSettingsQML_SOURCES}) | ||
4096 | 13 | target_link_libraries(FakeGSettingsQml | ||
4097 | 14 | ${Qt5Core_LIBRARIES} | ||
4098 | 15 | ${Qt5Quick_LIBRARIES} | ||
4099 | 16 | ) | ||
4100 | 17 | |||
4101 | 18 | qt5_use_modules(FakeGSettingsQml Qml) | ||
4102 | 19 | |||
4103 | 20 | add_usc_mock(GSettings 1.0 GSettings.1.0 TARGETS FakeGSettingsQml) | ||
4104 | 0 | 21 | ||
4105 | === added file 'tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp' | |||
4106 | --- tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp 1970-01-01 00:00:00 +0000 | |||
4107 | +++ tests/qmltests/mocks/GSettings.1.0/fake_gsettings.cpp 2016-06-15 10:46:42 +0000 | |||
4108 | @@ -0,0 +1,124 @@ | |||
4109 | 1 | /* | ||
4110 | 2 | * Copyright 2013 Canonical Ltd. | ||
4111 | 3 | * | ||
4112 | 4 | * This program is free software; you can redistribute it and/or modify | ||
4113 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
4114 | 6 | * the Free Software Foundation; version 3. | ||
4115 | 7 | * | ||
4116 | 8 | * This program is distributed in the hope that it will be useful, | ||
4117 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4118 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4119 | 11 | * GNU Lesser General Public License for more details. | ||
4120 | 12 | * | ||
4121 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
4122 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4123 | 15 | */ | ||
4124 | 16 | |||
4125 | 17 | #include "fake_gsettings.h" | ||
4126 | 18 | |||
4127 | 19 | #include <QDebug> | ||
4128 | 20 | |||
4129 | 21 | GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0; | ||
4130 | 22 | |||
4131 | 23 | GSettingsControllerQml::GSettingsControllerQml() | ||
4132 | 24 | : m_fingerprintNames() | ||
4133 | 25 | { | ||
4134 | 26 | } | ||
4135 | 27 | |||
4136 | 28 | GSettingsControllerQml::~GSettingsControllerQml() { | ||
4137 | 29 | s_controllerInstance = 0; | ||
4138 | 30 | } | ||
4139 | 31 | |||
4140 | 32 | GSettingsControllerQml* GSettingsControllerQml::instance() { | ||
4141 | 33 | if (!s_controllerInstance) { | ||
4142 | 34 | s_controllerInstance = new GSettingsControllerQml(); | ||
4143 | 35 | } | ||
4144 | 36 | return s_controllerInstance; | ||
4145 | 37 | } | ||
4146 | 38 | |||
4147 | 39 | QVariantMap GSettingsControllerQml::fingerprintNames() const | ||
4148 | 40 | { | ||
4149 | 41 | return m_fingerprintNames; | ||
4150 | 42 | } | ||
4151 | 43 | |||
4152 | 44 | void GSettingsControllerQml::setFingerprintNames(QVariantMap map) | ||
4153 | 45 | { | ||
4154 | 46 | if (map != m_fingerprintNames) { | ||
4155 | 47 | m_fingerprintNames = map; | ||
4156 | 48 | Q_EMIT fingerprintNamesChanged(); | ||
4157 | 49 | } | ||
4158 | 50 | } | ||
4159 | 51 | |||
4160 | 52 | GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) { | ||
4161 | 53 | } | ||
4162 | 54 | |||
4163 | 55 | QByteArray GSettingsSchemaQml::id() const { | ||
4164 | 56 | return m_id; | ||
4165 | 57 | } | ||
4166 | 58 | |||
4167 | 59 | void GSettingsSchemaQml::setId(const QByteArray &id) { | ||
4168 | 60 | if (!m_id.isEmpty()) { | ||
4169 | 61 | qWarning("GSettings.schema.id may only be set on construction"); | ||
4170 | 62 | return; | ||
4171 | 63 | } | ||
4172 | 64 | |||
4173 | 65 | m_id = id; | ||
4174 | 66 | } | ||
4175 | 67 | |||
4176 | 68 | QByteArray GSettingsSchemaQml::path() const { | ||
4177 | 69 | return m_path; | ||
4178 | 70 | } | ||
4179 | 71 | |||
4180 | 72 | void GSettingsSchemaQml::setPath(const QByteArray &path) { | ||
4181 | 73 | if (!m_path.isEmpty()) { | ||
4182 | 74 | qWarning("GSettings.schema.path may only be set on construction"); | ||
4183 | 75 | return; | ||
4184 | 76 | } | ||
4185 | 77 | |||
4186 | 78 | m_path = path; | ||
4187 | 79 | } | ||
4188 | 80 | |||
4189 | 81 | GSettingsQml::GSettingsQml(QObject *parent) | ||
4190 | 82 | : QObject(parent), | ||
4191 | 83 | m_valid(false) | ||
4192 | 84 | { | ||
4193 | 85 | m_schema = new GSettingsSchemaQml(this); | ||
4194 | 86 | } | ||
4195 | 87 | |||
4196 | 88 | void GSettingsQml::classBegin() | ||
4197 | 89 | { | ||
4198 | 90 | } | ||
4199 | 91 | |||
4200 | 92 | void GSettingsQml::componentComplete() | ||
4201 | 93 | { | ||
4202 | 94 | // Emulate what the real GSettings module does, and only return undefined | ||
4203 | 95 | // values until we are completed loading. | ||
4204 | 96 | m_valid = true; | ||
4205 | 97 | |||
4206 | 98 | // FIXME: We should make this dynamic, instead of hard-coding all possible | ||
4207 | 99 | // properties in one object. We should create properties based on the schema. | ||
4208 | 100 | connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::fingerprintNamesChanged, | ||
4209 | 101 | this, &GSettingsQml::fingerprintNamesChanged); | ||
4210 | 102 | |||
4211 | 103 | Q_EMIT fingerprintNamesChanged(); | ||
4212 | 104 | } | ||
4213 | 105 | |||
4214 | 106 | GSettingsSchemaQml * GSettingsQml::schema() const { | ||
4215 | 107 | return m_schema; | ||
4216 | 108 | } | ||
4217 | 109 | |||
4218 | 110 | QVariantMap GSettingsQml::fingerprintNames() const | ||
4219 | 111 | { | ||
4220 | 112 | if (m_valid && m_schema->id() == "com.ubuntu.touch.system") { | ||
4221 | 113 | return GSettingsControllerQml::instance()->fingerprintNames(); | ||
4222 | 114 | } else { | ||
4223 | 115 | return QVariantMap(); | ||
4224 | 116 | } | ||
4225 | 117 | } | ||
4226 | 118 | |||
4227 | 119 | void GSettingsQml::setFingerprintNames(const QVariantMap &map) | ||
4228 | 120 | { | ||
4229 | 121 | if (m_valid && m_schema->id() == "com.ubuntu.touch.system") { | ||
4230 | 122 | GSettingsControllerQml::instance()->setFingerprintNames(map); | ||
4231 | 123 | } | ||
4232 | 124 | } | ||
4233 | 0 | 125 | ||
4234 | === added file 'tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h' | |||
4235 | --- tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h 1970-01-01 00:00:00 +0000 | |||
4236 | +++ tests/qmltests/mocks/GSettings.1.0/fake_gsettings.h 2016-06-15 10:46:42 +0000 | |||
4237 | @@ -0,0 +1,101 @@ | |||
4238 | 1 | /* | ||
4239 | 2 | * Copyright 2013 Canonical Ltd. | ||
4240 | 3 | * | ||
4241 | 4 | * This program is free software; you can redistribute it and/or modify | ||
4242 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
4243 | 6 | * the Free Software Foundation; version 3. | ||
4244 | 7 | * | ||
4245 | 8 | * This program is distributed in the hope that it will be useful, | ||
4246 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4247 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4248 | 11 | * GNU Lesser General Public License for more details. | ||
4249 | 12 | * | ||
4250 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
4251 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4252 | 15 | */ | ||
4253 | 16 | |||
4254 | 17 | #ifndef FAKE_GSETTINGS_H | ||
4255 | 18 | #define FAKE_GSETTINGS_H | ||
4256 | 19 | |||
4257 | 20 | #include <QList> | ||
4258 | 21 | #include <QObject> | ||
4259 | 22 | #include <QQmlParserStatus> | ||
4260 | 23 | #include <QStringList> | ||
4261 | 24 | #include <QVariant> | ||
4262 | 25 | |||
4263 | 26 | class GSettingsSchemaQml: public QObject | ||
4264 | 27 | { | ||
4265 | 28 | Q_OBJECT | ||
4266 | 29 | |||
4267 | 30 | Q_PROPERTY(QByteArray id READ id WRITE setId) | ||
4268 | 31 | public: | ||
4269 | 32 | GSettingsSchemaQml(QObject *parent = nullptr); | ||
4270 | 33 | |||
4271 | 34 | QByteArray id() const; | ||
4272 | 35 | void setId(const QByteArray &id); | ||
4273 | 36 | |||
4274 | 37 | QByteArray path() const; | ||
4275 | 38 | void setPath(const QByteArray &path); | ||
4276 | 39 | |||
4277 | 40 | private: | ||
4278 | 41 | QByteArray m_id; | ||
4279 | 42 | QByteArray m_path; | ||
4280 | 43 | }; | ||
4281 | 44 | |||
4282 | 45 | class GSettingsQml: public QObject, public QQmlParserStatus | ||
4283 | 46 | { | ||
4284 | 47 | Q_OBJECT | ||
4285 | 48 | Q_INTERFACES(QQmlParserStatus) | ||
4286 | 49 | |||
4287 | 50 | Q_PROPERTY(GSettingsSchemaQml* schema READ schema NOTIFY schemaChanged) | ||
4288 | 51 | Q_PROPERTY(QVariantMap fingerprintNames | ||
4289 | 52 | READ fingerprintNames | ||
4290 | 53 | WRITE setFingerprintNames | ||
4291 | 54 | NOTIFY fingerprintNamesChanged) | ||
4292 | 55 | |||
4293 | 56 | public: | ||
4294 | 57 | GSettingsQml(QObject *parent = nullptr); | ||
4295 | 58 | |||
4296 | 59 | void classBegin() override; | ||
4297 | 60 | void componentComplete() override; | ||
4298 | 61 | |||
4299 | 62 | GSettingsSchemaQml * schema() const; | ||
4300 | 63 | |||
4301 | 64 | QVariantMap fingerprintNames() const; | ||
4302 | 65 | void setFingerprintNames(const QVariantMap &map); | ||
4303 | 66 | |||
4304 | 67 | Q_SIGNALS: | ||
4305 | 68 | void fingerprintNamesChanged(); | ||
4306 | 69 | void schemaChanged(); | ||
4307 | 70 | |||
4308 | 71 | private: | ||
4309 | 72 | GSettingsSchemaQml* m_schema; | ||
4310 | 73 | bool m_valid; | ||
4311 | 74 | |||
4312 | 75 | friend class GSettingsSchemaQml; | ||
4313 | 76 | }; | ||
4314 | 77 | |||
4315 | 78 | class GSettingsControllerQml: public QObject | ||
4316 | 79 | { | ||
4317 | 80 | Q_OBJECT | ||
4318 | 81 | |||
4319 | 82 | public: | ||
4320 | 83 | static GSettingsControllerQml* instance(); | ||
4321 | 84 | ~GSettingsControllerQml(); | ||
4322 | 85 | |||
4323 | 86 | Q_INVOKABLE QVariantMap fingerprintNames() const; | ||
4324 | 87 | Q_INVOKABLE void setFingerprintNames(QVariantMap map); | ||
4325 | 88 | |||
4326 | 89 | Q_SIGNALS: | ||
4327 | 90 | void fingerprintNamesChanged(); | ||
4328 | 91 | |||
4329 | 92 | private: | ||
4330 | 93 | GSettingsControllerQml(); | ||
4331 | 94 | |||
4332 | 95 | QVariantMap m_fingerprintNames; | ||
4333 | 96 | |||
4334 | 97 | static GSettingsControllerQml* s_controllerInstance; | ||
4335 | 98 | QList<GSettingsQml *> m_registeredGSettings; | ||
4336 | 99 | }; | ||
4337 | 100 | |||
4338 | 101 | #endif // FAKE_GSETTINGS_H | ||
4339 | 0 | 102 | ||
4340 | === added file 'tests/qmltests/mocks/GSettings.1.0/plugin.cpp' | |||
4341 | --- tests/qmltests/mocks/GSettings.1.0/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
4342 | +++ tests/qmltests/mocks/GSettings.1.0/plugin.cpp 2016-06-15 10:46:42 +0000 | |||
4343 | @@ -0,0 +1,33 @@ | |||
4344 | 1 | /* | ||
4345 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
4346 | 3 | * | ||
4347 | 4 | * This program is free software; you can redistribute it and/or modify | ||
4348 | 5 | * it under the terms of the GNU General Public License as published by | ||
4349 | 6 | * the Free Software Foundation; version 3. | ||
4350 | 7 | * | ||
4351 | 8 | * This program is distributed in the hope that it will be useful, | ||
4352 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4353 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4354 | 11 | * GNU General Public License for more details. | ||
4355 | 12 | * | ||
4356 | 13 | * You should have received a copy of the GNU General Public License | ||
4357 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4358 | 15 | */ | ||
4359 | 16 | |||
4360 | 17 | #include "plugin.h" | ||
4361 | 18 | #include "fake_gsettings.h" | ||
4362 | 19 | |||
4363 | 20 | #include <QtQml/qqml.h> | ||
4364 | 21 | |||
4365 | 22 | static QObject* controllerProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */) | ||
4366 | 23 | { | ||
4367 | 24 | return GSettingsControllerQml::instance(); | ||
4368 | 25 | } | ||
4369 | 26 | |||
4370 | 27 | void FakeGSettingsQmlPlugin::registerTypes(const char *uri) | ||
4371 | 28 | { | ||
4372 | 29 | qmlRegisterSingletonType<GSettingsControllerQml>(uri, 1, 0, "GSettingsController", controllerProvider); | ||
4373 | 30 | qmlRegisterType<GSettingsQml>(uri, 1, 0, "GSettings"); | ||
4374 | 31 | qmlRegisterUncreatableType<GSettingsSchemaQml>(uri, 1, 0, "GSettingsSchema", | ||
4375 | 32 | "GSettingsSchema can only be used inside of a GSettings component"); | ||
4376 | 33 | } | ||
4377 | 0 | 34 | ||
4378 | === added file 'tests/qmltests/mocks/GSettings.1.0/plugin.h' | |||
4379 | --- tests/qmltests/mocks/GSettings.1.0/plugin.h 1970-01-01 00:00:00 +0000 | |||
4380 | +++ tests/qmltests/mocks/GSettings.1.0/plugin.h 2016-06-15 10:46:42 +0000 | |||
4381 | @@ -0,0 +1,31 @@ | |||
4382 | 1 | /* | ||
4383 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
4384 | 3 | * | ||
4385 | 4 | * This program is free software; you can redistribute it and/or modify | ||
4386 | 5 | * it under the terms of the GNU General Public License as published by | ||
4387 | 6 | * the Free Software Foundation; version 3. | ||
4388 | 7 | * | ||
4389 | 8 | * This program is distributed in the hope that it will be useful, | ||
4390 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4391 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4392 | 11 | * GNU General Public License for more details. | ||
4393 | 12 | * | ||
4394 | 13 | * You should have received a copy of the GNU General Public License | ||
4395 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4396 | 15 | */ | ||
4397 | 16 | |||
4398 | 17 | #ifndef PLUGIN_H | ||
4399 | 18 | #define PLUGIN_H | ||
4400 | 19 | |||
4401 | 20 | #include <QtQml/QQmlExtensionPlugin> | ||
4402 | 21 | |||
4403 | 22 | class FakeGSettingsQmlPlugin : public QQmlExtensionPlugin | ||
4404 | 23 | { | ||
4405 | 24 | Q_OBJECT | ||
4406 | 25 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
4407 | 26 | |||
4408 | 27 | public: | ||
4409 | 28 | void registerTypes(const char *uri) override; | ||
4410 | 29 | }; | ||
4411 | 30 | |||
4412 | 31 | #endif // PLUGIN_H | ||
4413 | 0 | 32 | ||
4414 | === added file 'tests/qmltests/mocks/GSettings.1.0/qmldir' | |||
4415 | --- tests/qmltests/mocks/GSettings.1.0/qmldir 1970-01-01 00:00:00 +0000 | |||
4416 | +++ tests/qmltests/mocks/GSettings.1.0/qmldir 2016-06-15 10:46:42 +0000 | |||
4417 | @@ -0,0 +1,2 @@ | |||
4418 | 1 | module GSettings | ||
4419 | 2 | plugin FakeGSettingsQml |