From ade3b97523d28db476a56a86a861ea14080749b7 Mon Sep 17 00:00:00 2001 From: Daniel d'Andrada Date: Thu, 26 Oct 2017 16:53:00 +0200 Subject: Proper model implementation and dependency injection instead of singletons - Have a proper implementation of the applications model used in triton - Also use a dependency injection approach, where components get the needed models as properties instead of importing singletons themselves. That makes testing easier (no need to come up with fake implementations of qml modules exporting fake singletons) as you can just directly assign a mock to the model property and also makes the dependencies absolutely clear in the code (you can see the models being passed down to the children that use them). --- tests/qmltests/tst_HomePage.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/qmltests/tst_HomePage.qml b/tests/qmltests/tst_HomePage.qml index acc59bc3..d837b5e0 100644 --- a/tests/qmltests/tst_HomePage.qml +++ b/tests/qmltests/tst_HomePage.qml @@ -90,7 +90,12 @@ Item { HomePage { id: homePage anchors.fill: parent - widgetsList: ListModel { id: listModel } + widgetsList: ListModel { + id: listModel + function application(index) { + return get(index).appInfo; + } + } Component.onCompleted: { listModel.append({"appInfo":redApp}) listModel.append({"appInfo":greenApp}) -- cgit v1.2.3