on xenial help sign in
more work on the fake plugin (doesn't work)
commit5900ed62ca0f0b8080ca13bcdf38bbb460cd7c63 authorAndrea Cimitan <andrea.cimitan@canonical.com> dateThu 25 Jul 2013, 10:21 (13 years ago) parentfa641c4
7 files changed+158−9
tests/mocks/CMakeLists.txt+1 tests/mocks/GSettings/CMakeLists.txt+32 tests/mocks/GSettings/GSettings.qml → tests/mocks/GSettings/fake_gsettings.cpp+9−8 tests/mocks/GSettings/fake_gsettings.h+40 tests/mocks/GSettings/fake_schema.cpp+33 tests/mocks/GSettings/fake_schema.h+42 tests/mocks/GSettings/qmldir+1−1
tests/mocks/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(GSettings)
12add_subdirectory(libusermetrics)
23add_subdirectory(LightDM)
34add_subdirectory(QMenuModel)
tests/mocks/GSettings/CMakeLists.txtnew file+32
@@ -0,0 +1,32 @@
1+set(CMAKE_AUTOMOC ON)
2+
3+include(FindPkgConfig)
4+find_package(Qt5Core REQUIRED)
5+find_package(Qt5Quick REQUIRED)
6+
7+include_directories(
8+ ${CMAKE_CURRENT_BINARY_DIR}
9+ ${Qt5Core_INCLUDE_DIRS}
10+ ${Qt5Quick_INCLUDE_DIRS}
11+)
12+
13+add_definitions(-DQT_NO_KEYWORDS)
14+
15+set(GSettingsQML_SOURCES
16+ fake_gsettings.cpp
17+ fake_schema.cpp
18+ plugin.cpp
19+)
20+
21+add_library(FakeGSettingsQml MODULE ${GSettingsQML_SOURCES})
22+target_link_libraries(FakeGSettingsQml
23+ ${Qt5Core_LIBRARIES}
24+ ${Qt5Quick_LIBRARIES}
25+)
26+
27+qt5_use_modules(FakeGSettingsQml Qml)
28+
29+# copy qmldir file into build directory for shadow builds
30+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
31+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
32+ )
tests/mocks/GSettings/GSettings.qml → tests/mocks/GSettings/fake_gsettings.cpprenamed+9−8
@@ -14,14 +14,15 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
17+#include "fake_gsettings.h"
18+#include "fake_schema.h"
1819
19−Item {
20− property url pictureUri
21−
22− property var schema: QtObject {
23− property string id: "org.gnome.desktop.background"
24− }
20+GSettings::GSettings(QObject *parent) :
21+ QObject(parent)
22+{
23+ m_schema = new Schema();
24+}
2525
26− Component.onCompleted: console.log(" XXXXXXXXXXX loaded")
26+QObject GSettings::schema() const {
27+ return m_schema;
2728}
tests/mocks/GSettings/fake_gsettings.hnew file+40
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef FAKE_GSETTINGS_H
18+#define FAKE_GSETTINGS_H
19+
20+#include <QObject>
21+
22+class GSettings : public QObject
23+{
24+ Q_OBJECT
25+
26+ Q_PROPERTY(QObject schema READ schema NOTIFY schemaChanged)
27+
28+public:
29+ explicit GSettings(QObject *parent = 0);
30+
31+ QObject schema() const;
32+
33+Q_SIGNALS:
34+ void schemaChanged(const QObject&);
35+
36+private:
37+ QObject m_schema;
38+};
39+
40+#endif // FAKE_GSETTINGS_H
tests/mocks/GSettings/fake_schema.cppnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "fake_schema.h"
18+
19+Schema::Schema(QObject *parent) :
20+ QObject(parent)
21+{
22+}
23+
24+QString Schema::id() const {
25+ return m_id;
26+}
27+
28+void Schema::setId(const QString &str) {
29+ if (str != m_id) {
30+ m_id = str;
31+ Q_EMIT idChanged(m_id);
32+ }
33+}
tests/mocks/GSettings/fake_schema.hnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef FAKE_SCHEMA_H
18+#define FAKE_SCHEMA_H
19+
20+#include <QObject>
21+
22+class Schema : public QObject
23+{
24+ Q_OBJECT
25+
26+ Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
27+
28+public:
29+ explicit Schema(QObject *parent = 0);
30+
31+ QString id() const;
32+
33+ void setId(const QString& str);
34+
35+Q_SIGNALS:
36+ void idChanged(const QString&);
37+
38+private:
39+ QString m_id;
40+};
41+
42+#endif // FAKE_SCHEMA_H
tests/mocks/GSettings/qmldir+1−1
@@ -1,2 +1,2 @@
11module GSettings
2−GSettings 1.0 GSettings.qml
2+plugin FakeGSettingsQml