summaryrefslogtreecommitdiff
path: root/tests/projects/qt/quickplugin/src
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-06-09 23:58:46 +0200
committerArthur LAURENT <[email protected]>2022-06-09 23:58:46 +0200
commit7b9a4f0ce02fc059e76fa9cba90425fd75f0326e (patch)
treee74bf06063f2daaf5b7f6ebc5a98a257c0c8745a /tests/projects/qt/quickplugin/src
parent50f55f6e0e7ce6a5474fb5dd784c90321371396c (diff)
Add qt.quickplugin test
Diffstat (limited to 'tests/projects/qt/quickplugin/src')
-rw-r--r--tests/projects/qt/quickplugin/src/Foo.cpp16
-rw-r--r--tests/projects/qt/quickplugin/src/Foo.h22
-rw-r--r--tests/projects/qt/quickplugin/src/Plugin.cpp10
-rw-r--r--tests/projects/qt/quickplugin/src/Plugin.h10
4 files changed, 58 insertions, 0 deletions
diff --git a/tests/projects/qt/quickplugin/src/Foo.cpp b/tests/projects/qt/quickplugin/src/Foo.cpp
new file mode 100644
index 000000000..83aceec6a
--- /dev/null
+++ b/tests/projects/qt/quickplugin/src/Foo.cpp
@@ -0,0 +1,16 @@
+#include "Foo.h"
+
+Foo::Foo(QObject *parent) : QObject { parent }, m_bar{ 0 } {
+}
+
+int Foo::bar() const noexcept {
+ return m_bar;
+}
+
+void Foo::setBar(int bar) noexcept {
+ if(bar == m_bar) return;
+
+ m_bar = bar;
+
+ Q_EMIT barChanged(m_bar);
+} \ No newline at end of file
diff --git a/tests/projects/qt/quickplugin/src/Foo.h b/tests/projects/qt/quickplugin/src/Foo.h
new file mode 100644
index 000000000..71e2b0e23
--- /dev/null
+++ b/tests/projects/qt/quickplugin/src/Foo.h
@@ -0,0 +1,22 @@
+#include <QtCore/QObject>
+#include <QtQml/qqml.h>
+
+class Foo: public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int bar READ bar WRITE setBar NOTIFY barChanged)
+ QML_NAMED_ELEMENT(Foo)
+
+ public:
+ explicit Foo(QObject *parent = nullptr);
+
+ int bar() const noexcept;
+ void setBar(int bar) noexcept;
+
+ Q_SIGNALS:
+ void barChanged(int bar);
+
+ private:
+ int m_bar;
+};
+
+QML_DECLARE_TYPE(Foo)
diff --git a/tests/projects/qt/quickplugin/src/Plugin.cpp b/tests/projects/qt/quickplugin/src/Plugin.cpp
new file mode 100644
index 000000000..9138c68b0
--- /dev/null
+++ b/tests/projects/qt/quickplugin/src/Plugin.cpp
@@ -0,0 +1,10 @@
+#include "Plugin.h"
+
+void qml_register_types_My_Plugin();
+
+/////////////////////////////////////
+/////////////////////////////////////
+Plugin::Plugin(QObject *parent) : QQmlEngineExtensionPlugin { parent } {
+ volatile auto registration = &qml_register_types_My_Plugin;
+ Q_UNUSED(registration);
+}
diff --git a/tests/projects/qt/quickplugin/src/Plugin.h b/tests/projects/qt/quickplugin/src/Plugin.h
new file mode 100644
index 000000000..72f7b6466
--- /dev/null
+++ b/tests/projects/qt/quickplugin/src/Plugin.h
@@ -0,0 +1,10 @@
+#include <QtCore/QObject>
+#include <QtQml/QQmlEngineExtensionPlugin>
+
+class Plugin: public QQmlEngineExtensionPlugin {
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
+
+ public:
+ explicit Plugin(QObject *parent = nullptr);
+};