File: tst_actioncreator.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 (88 lines) | stat: -rw-r--r-- 1,976 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
import QtQuick 2.0
import QtTest 1.0
import QuickFlux 1.1

TestCase {
    name : "ActionCreatorTests"

    ActionCreator {
        id: actionCreator
        signal test1();
        signal test2(int v1, string v2, real v3, var v4)
    }

    AppListener {
        id: listener
        property var payload: new Array
        onDispatched: {
            payload.push({
               type: type,
               message: message
              });
        }
    }

    function test_emission() {
        listener.payload = [];
        actionCreator.test1();
        compare(listener.payload.length, 1);
        compare(listener.payload[0].type, "test1");

        var data = {
            f1 : "f1"
        }

        actionCreator.test2(1,"v2",3.0,data);
        compare(listener.payload.length, 2);
        compare(listener.payload[1].type, "test2");

        var message = listener.payload[1].message;
        compare(message.v1, 1);
        compare(message.v2, "v2");
        compare(message.v3, 3.0);
        compare(message.v4, data);
    }

    ActionCreator {
        // No signals
        id: dummy
    }

    ActionCreator {
        id: actionCreator2
        objectName: "actionCreator2";

        signal test1

        dispatcher: Dispatcher {
            id: dispatcher2
            property var payload: new Array
            onDispatched: {
                dispatcher2.payload.push({
                   type: type,
                   message: message
                });
            }
        }
    }

    AppListener {
        id: listener2
        signal test1();
        property var payload: new Array
        onDispatched: {
            listener2.payload.push({
               type: type,
               message: message
            });
        }
    }

    function test_customDispatcher() {
        listener2.payload = [];
        actionCreator2.test1();
        compare(listener2.payload.length, 0);
        compare(dispatcher2.payload.length, 1);
    }
}