File: tst_store_children.qml

package info (click to toggle)
quickflux 1.1.3%2Bgit20201110.2a37acf-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,036 kB
  • sloc: cpp: 2,874; makefile: 26
file content (93 lines) | stat: -rw-r--r-- 1,871 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import QtQuick 2.0
import QtTest 1.0
import QuickFlux 1.1

TestCase {
    name : "StoreChildrenTests"

    property var seq: new Array;

    ActionCreator {
        id: defaultActionCreator

        signal test1();
    }

    ActionCreator {
        id: actionCreator

        dispatcher: Dispatcher {}

        signal test1
    }

    Store {
        id: store
        property int test1: 0

        Store {
            id: child1

            property int test1: 0

            Filter {
                type: "test1"
                onDispatched: {
                    child1.test1++;
                    seq.push("child1");
                }
            }
        }

        Store {
            id: child2
            property int test1: 0

            Filter {
                type: "test1"
                onDispatched: {
                    child2.test1++;
                    seq.push("child2");
                }
            }
        }

        Filter {
            type: "test1"
            onDispatched: {
                store.test1++;
                seq.push("store");
            }
        }
    }

    function test_dispatch() {
        compare(child1.bindSource, null);
        compare(child2.bindSource, null);

        store.dispatch("test1");
        compare(store.test1, 1);
        compare(child1.test1, 1);
        compare(child2.test1, 1);
        compare(seq,["child1", "child2", "store"]);

        store.bind(actionCreator);

        defaultActionCreator.test1();

        compare(store.test1, 1);
        compare(child1.test1, 1);
        compare(child2.test1, 1);
        compare(seq,["child1", "child2", "store"]);

        actionCreator.test1();

        compare(store.test1, 2);
        compare(child1.test1, 2);
        compare(child2.test1, 2);
        compare(seq,["child1", "child2", "store", "child1", "child2", "store"]);

    }

}