aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel d'Andrada <daniel.dandrada@luxoft.com>2017-10-26 16:53:00 +0200
committerDaniel d'Andrada <daniel.dandrada@luxoft.com>2018-02-28 15:58:02 +0100
commitade3b97523d28db476a56a86a861ea14080749b7 (patch)
treee4163f10c8ecbec50547468eafeebcf4797ae8d2 /tests
parent15846e28541a7849d3603a76cd1d8e17bab3541c (diff)
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).
Diffstat (limited to 'tests')
-rw-r--r--tests/qmltests/tst_HomePage.qml7
1 files changed, 6 insertions, 1 deletions
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})