Started QQuickView tests

This commit is contained in:
Filippo Cucchetto 2016-06-26 18:46:03 +02:00
parent 4068279091
commit c6283eed47
4 changed files with 48 additions and 16 deletions

View File

@ -33,21 +33,21 @@ DOS_API void DOS_CALL dos_qapplication_delete();
// QQmlApplicationEngine // QQmlApplicationEngine
DOS_API DosQQmlApplicationEngine *DOS_CALL dos_qqmlapplicationengine_create(); DOS_API DosQQmlApplicationEngine *DOS_CALL dos_qqmlapplicationengine_create();
DOS_API void DOS_CALL dos_qqmlapplicationengine_load(DosQQmlApplicationEngine *vptr, const char *filename); DOS_API void DOS_CALL dos_qqmlapplicationengine_load(DosQQmlApplicationEngine *vptr, const char *filename);
DOS_API void DOS_CALL dos_qqmlapplicationengine_load_url(DosQQmlApplicationEngine *vptr, DosQUrl *url); DOS_API void DOS_CALL dos_qqmlapplicationengine_load_url(DosQQmlApplicationEngine *vptr, DosQUrl *url);
DOS_API void DOS_CALL dos_qqmlapplicationengine_load_data(DosQQmlApplicationEngine *vptr, const char *data); DOS_API void DOS_CALL dos_qqmlapplicationengine_load_data(DosQQmlApplicationEngine *vptr, const char *data);
DOS_API void DOS_CALL dos_qqmlapplicationengine_add_import_path(DosQQmlApplicationEngine *vptr, const char *path); DOS_API void DOS_CALL dos_qqmlapplicationengine_add_import_path(DosQQmlApplicationEngine *vptr, const char *path);
DOS_API DosQQmlContext *DOS_CALL dos_qqmlapplicationengine_context(DosQQmlApplicationEngine *vptr); DOS_API DosQQmlContext *DOS_CALL dos_qqmlapplicationengine_context(DosQQmlApplicationEngine *vptr);
DOS_API void DOS_CALL dos_qqmlapplicationengine_delete(DosQQmlApplicationEngine *vptr); DOS_API void DOS_CALL dos_qqmlapplicationengine_delete(DosQQmlApplicationEngine *vptr);
// QQuickView // QQuickView
DOS_API DosQQuickView *DOS_CALL dos_qquickview_create(); DOS_API DosQQuickView *DOS_CALL dos_qquickview_create();
DOS_API void DOS_CALL dos_qquickview_show(DosQQuickView *vptr); DOS_API void DOS_CALL dos_qquickview_show(DosQQuickView *vptr);
DOS_API char *DOS_CALL dos_qquickview_source(const DosQQuickView *vptr); DOS_API char *DOS_CALL dos_qquickview_source(const DosQQuickView *vptr);
DOS_API void DOS_CALL dos_qquickview_set_source_url(DosQQuickView *vptr, DosQUrl *url); DOS_API void DOS_CALL dos_qquickview_set_source_url(DosQQuickView *vptr, DosQUrl *url);
DOS_API void DOS_CALL dos_qquickview_set_source(DosQQuickView *vptr, const char *filename); DOS_API void DOS_CALL dos_qquickview_set_source(DosQQuickView *vptr, const char *filename);
DOS_API void DOS_CALL dos_qquickview_set_resize_mode(DosQQuickView *vptr, int resizeMode); DOS_API void DOS_CALL dos_qquickview_set_resize_mode(DosQQuickView *vptr, int resizeMode);
DOS_API void DOS_CALL dos_qquickview_delete(DosQQuickView *vptr); DOS_API void DOS_CALL dos_qquickview_delete(DosQQuickView *vptr);
DOS_API DosQQmlContext *DOS_CALL dos_qquickview_rootContext(DosQQuickView *vptr); DOS_API DosQQmlContext *DOS_CALL dos_qquickview_rootContext(DosQQuickView *vptr);
// QQmlContext // QQmlContext
@ -155,11 +155,11 @@ DOS_API char *DOS_CALL dos_qobject_objectName(const DosQObject *vptr);
/// @param vptr the DosQObject pointer /// @param vptr the DosQObject pointer
/// @param name a pointer to a UTF8 string. The string is owned by the caller thus /// @param name a pointer to a UTF8 string. The string is owned by the caller thus
/// it will not be deleted. /// it will not be deleted.
DOS_API void DOS_CALL dos_qobject_setObjectName(DosQObject *vptr, const char *name); DOS_API void DOS_CALL dos_qobject_setObjectName(DosQObject *vptr, const char *name);
/// Delete the DosQObject /// Delete the DosQObject
/// @param vptr the DosQObject pointer /// @param vptr the DosQObject pointer
DOS_API void DOS_CALL dos_qobject_delete(DosQObject *vptr); DOS_API void DOS_CALL dos_qobject_delete(DosQObject *vptr);
// QModelIndex // QModelIndex
DOS_API DosQModelIndex *DOS_CALL dos_qmodelindex_create(); DOS_API DosQModelIndex *DOS_CALL dos_qmodelindex_create();
@ -176,8 +176,8 @@ DOS_API void DOS_CALL dos_qmodelindex_assign (DosQModelIndex *l, const DosQModel
// QHash<int, QByteArray> // QHash<int, QByteArray>
DOS_API DosQHashIntQByteArray *DOS_CALL dos_qhash_int_qbytearray_create(); DOS_API DosQHashIntQByteArray *DOS_CALL dos_qhash_int_qbytearray_create();
DOS_API void DOS_CALL dos_qhash_int_qbytearray_delete(DosQHashIntQByteArray *vptr); DOS_API void DOS_CALL dos_qhash_int_qbytearray_delete(DosQHashIntQByteArray *vptr);
DOS_API void DOS_CALL dos_qhash_int_qbytearray_insert(DosQHashIntQByteArray *vptr, int key, const char *value); DOS_API void DOS_CALL dos_qhash_int_qbytearray_insert(DosQHashIntQByteArray *vptr, int key, const char *value);
DOS_API char *DOS_CALL dos_qhash_int_qbytearray_value (DosQHashIntQByteArray *vptr, int key); DOS_API char *DOS_CALL dos_qhash_int_qbytearray_value (DosQHashIntQByteArray *vptr, int key);
// QResource // QResource
@ -185,7 +185,7 @@ DOS_API void DOS_CALL dos_qresource_register(const char *filename);
// QUrl // QUrl
DOS_API DosQUrl *DOS_CALL dos_qurl_create(const char *url, int parsingMode); DOS_API DosQUrl *DOS_CALL dos_qurl_create(const char *url, int parsingMode);
DOS_API void DOS_CALL dos_qurl_delete(DosQUrl *vptr); DOS_API void DOS_CALL dos_qurl_delete(DosQUrl *vptr);
DOS_API char *DOS_CALL dos_qurl_to_string(const DosQUrl *vptr); DOS_API char *DOS_CALL dos_qurl_to_string(const DosQUrl *vptr);
DOS_API bool dos_qurl_isValid(const DosQUrl *vptr); DOS_API bool dos_qurl_isValid(const DosQUrl *vptr);

View File

@ -4,5 +4,6 @@
<file>testQAbstractItemModel.qml</file> <file>testQAbstractItemModel.qml</file>
<file>testQObject.qml</file> <file>testQObject.qml</file>
<file>testQDeclarative.qml</file> <file>testQDeclarative.qml</file>
<file>testQQuickView.qml</file>
</qresource> </qresource>
</RCC> </RCC>

7
test/testQQuickView.qml Normal file
View File

@ -0,0 +1,7 @@
import QtQuick 2.5
Item {
objectName: "testObject"
width: 400
height: 400
}

View File

@ -631,6 +631,30 @@ private slots:
} }
}; };
/*
* Test QQuickView
*/
class TestQQuickView : public QObject
{
Q_OBJECT
private slots:
void testCreate() {
VoidPointer view(dos_qquickview_create(), &dos_qquickview_delete);
QVERIFY(view.get());
}
void testSourceAndSetSource() {
std::string testUrl = "qrc:/testQQuickView.qml";
VoidPointer view(dos_qquickview_create(), &dos_qquickview_delete);
VoidPointer url(dos_qurl_create(testUrl.c_str(), QUrl::StrictMode), &dos_qurl_delete);
dos_qquickview_set_source_url(view.get(), url.get());
CharPointer tempUrl(dos_qquickview_source(view.get()), &dos_chararray_delete);
QCOMPARE(std::string(tempUrl.get()), testUrl);
dos_qquickview_show(view.get());
}
};
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
using namespace DOS; using namespace DOS;
@ -646,7 +670,7 @@ int main(int argc, char *argv[])
success &= ExecuteGuiTest<TestQObject>(argc, argv); success &= ExecuteGuiTest<TestQObject>(argc, argv);
success &= ExecuteGuiTest<TestQAbstractListModel>(argc, argv); success &= ExecuteGuiTest<TestQAbstractListModel>(argc, argv);
success &= ExecuteGuiTest<TestQDeclarativeIntegration>(argc, argv); success &= ExecuteGuiTest<TestQDeclarativeIntegration>(argc, argv);
success &= ExecuteGuiTest<TestQQuickView>(argc, argv);
return success ? 0 : 1; return success ? 0 : 1;
} }