on xenial help sign in
Add mock Fingerprints module
c4e7e98Michael Terry
tests/mocks/Ubuntu/CMakeLists.txt+1
@@ -1,5 +1,6 @@
1add_subdirectory(Connectivity)
1add_subdirectory(Connectivity)
2add_subdirectory(DownloadDaemonListener)
2add_subdirectory(DownloadDaemonListener)
3+add_subdirectory(Fingerprints)
3add_subdirectory(Payments)
4add_subdirectory(Payments)
4add_subdirectory(SystemImage)
5add_subdirectory(SystemImage)
5add_subdirectory(SystemSettings)
6add_subdirectory(SystemSettings)
tests/mocks/Ubuntu/Fingerprints/CMakeLists.txtnew file+10
@@ -0,0 +1,10 @@
1+set(MOCK_FINGERPRINTS_SOURCES
2+ plugin.cpp
3+ MockFingerprints.cpp
4+)
5+
6+add_library(MockFingerprints MODULE ${MOCK_FINGERPRINTS_SOURCES})
7+
8+qt5_use_modules(MockFingerprints Qml Quick Core)
9+
10+add_unity8_mock(Ubuntu.Fingerprints 0.1 Ubuntu/Fingerprints TARGETS MockFingerprints)
tests/mocks/Ubuntu/Fingerprints/Fingerprints.qmltypesnew file+39
@@ -0,0 +1,39 @@
1+import QtQuick.tooling 1.2
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Ubuntu.Fingerprints 0.1 tests/mocks'
8+
9+Module {
10+ dependencies: []
11+ Component {
12+ name: "MockFingerprints"
13+ prototype: "QObject"
14+ exports: ["Ubuntu.Fingerprints/Fingerprints 0.1"]
15+ isCreatable: false
16+ isSingleton: true
17+ exportMetaObjectRevisions: [0]
18+ Enum {
19+ name: "IdentificationError"
20+ values: {
21+ "None": 0,
22+ "Error": 1
23+ }
24+ }
25+ Signal {
26+ name: "identificationCompleted"
27+ Parameter { name: "uid"; type: "int" }
28+ }
29+ Signal {
30+ name: "identificationFailed"
31+ Parameter { type: "IdentificationError" }
32+ }
33+ Method {
34+ name: "mockIdentification"
35+ Parameter { name: "uid"; type: "int" }
36+ Parameter { name: "error"; type: "IdentificationError" }
37+ }
38+ }
39+}
tests/mocks/Ubuntu/Fingerprints/MockFingerprints.cppnew file+30
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (C) 2016 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "MockFingerprints.h"
18+
19+MockFingerprints::MockFingerprints(QObject *parent)
20+ : QObject(parent)
21+{
22+}
23+
24+void MockFingerprints::mockIdentification(int uid, IdentificationError error)
25+{
26+ if (error != None)
27+ Q_EMIT identificationFailed(error);
28+ else
29+ Q_EMIT identificationCompleted(uid);
30+}
tests/mocks/Ubuntu/Fingerprints/MockFingerprints.hnew file+43
@@ -0,0 +1,43 @@
1+/*
2+ * Copyright (C) 2016 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MOCK_FINGERPRINTS_H
18+#define MOCK_FINGERPRINTS_H
19+
20+#include <QObject>
21+
22+class MockFingerprints : public QObject
23+{
24+ Q_OBJECT
25+ Q_DISABLE_COPY(MockFingerprints)
26+ Q_ENUMS(IdentificationError)
27+
28+public:
29+ enum IdentificationError {
30+ None,
31+ Error,
32+ };
33+
34+ explicit MockFingerprints(QObject *parent = 0);
35+
36+ Q_INVOKABLE void mockIdentification(int uid, IdentificationError error); // only in mock
37+
38+Q_SIGNALS:
39+ void identificationCompleted(int uid);
40+ void identificationFailed(IdentificationError);
41+};
42+
43+#endif // MOCK_FINGERPRINTS_H
tests/mocks/Ubuntu/Fingerprints/plugin.cppnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "plugin.h"
18+#include "MockFingerprints.h"
19+
20+#include <QtQml>
21+
22+static QObject *service_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23+{
24+ Q_UNUSED(engine)
25+ Q_UNUSED(scriptEngine)
26+ return new MockFingerprints();
27+}
28+
29+void BackendPlugin::registerTypes(const char *uri)
30+{
31+ Q_ASSERT(uri == QLatin1String("Ubuntu.Fingerprints"));
32+
33+ qmlRegisterSingletonType<MockFingerprints>(uri, 0, 1, "Fingerprints", service_provider);
34+}
tests/mocks/Ubuntu/Fingerprints/plugin.hnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2016 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MOCK_FINGERPRINTS_PLUGIN_H
18+#define MOCK_FINGERPRINTS_PLUGIN_H
19+
20+#include <QQmlExtensionPlugin>
21+
22+class BackendPlugin : public QQmlExtensionPlugin
23+{
24+ Q_OBJECT
25+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26+
27+public:
28+ void registerTypes(const char *uri) override;
29+};
30+
31+#endif // MOCK_FINGERPRINTS_PLUGIN_H
tests/mocks/Ubuntu/Fingerprints/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Ubuntu.Fingerprints
2+plugin MockFingerprints
3+typeinfo Fingerprints.qmltypes