• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / brs / #213

27 Jan 2025 05:30PM UTC coverage: 86.996% (-2.2%) from 89.205%
#213

push

web-flow
Implemented several improvements to SceneGraph (#87)

* Implemented several improvements to SceneGraph

* Fixed most test cases

* Reduced unnecessary code

* Fixed typo

* Added Warning when trying to create a non-existent Node

* Fixed parser

* Fixed unit tests

* Implemented support for `infoFields`

* Prettier fix

* Simplified execute callback code and matched behavior with Roku

* Adding comment to clarify the exception

2240 of 2807 branches covered (79.8%)

Branch coverage included in aggregate %.

139 of 304 new or added lines in 18 files covered. (45.72%)

2 existing lines in 1 file now uncovered.

6129 of 6813 relevant lines covered (89.96%)

27562.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.14
/src/brsTypes/components/RoSGNodeEvent.ts
1
import { BrsComponent } from "./BrsComponent";
143✔
2
import { ValueKind, BrsString, BrsValue, BrsBoolean } from "../BrsType";
143✔
3
import { Callable } from "../Callable";
143✔
4
import { Interpreter } from "../../interpreter";
5
import { RoSGNode } from "./RoSGNode";
6
import { BrsType, RoAssociativeArray } from "..";
143✔
7

8
export class RoSGNodeEvent extends BrsComponent implements BrsValue {
143✔
9
    readonly kind = ValueKind.Object;
99✔
10

11
    constructor(
12
        readonly node: RoSGNode,
99✔
13
        readonly fieldName: BrsString,
99✔
14
        readonly fieldValue: BrsType,
99✔
15
        readonly infoFields?: RoAssociativeArray
99✔
16
    ) {
17
        super("roSGNodeEvent");
99✔
18
        this.appendMethods([
99✔
19
            this.getData,
20
            this.getField,
21
            this.getRoSGNode,
22
            this.getNode,
23
            this.getInfo,
24
        ]);
25
    }
26

27
    equalTo(other: BrsType) {
28
        // RBI doesn't allow events to be compared.
29
        return BrsBoolean.False;
1✔
30
    }
31

32
    toString() {
33
        return "<Component: roSGNodeEvent>";
2✔
34
    }
35

36
    /** Retrieves the new field value at the time of the change. */
37
    private getData = new Callable("getdata", {
99✔
38
        signature: {
39
            args: [],
40
            returns: ValueKind.Dynamic,
41
        },
42
        impl: (_: Interpreter) => {
43
            return this.fieldValue;
82✔
44
        },
45
    });
46

47
    /** Retrieves the name of the field that changed. */
48
    private getField = new Callable("getfield", {
99✔
49
        signature: {
50
            args: [],
51
            returns: ValueKind.Dynamic,
52
        },
53
        impl: (_: Interpreter) => {
54
            return this.fieldName;
2✔
55
        },
56
    });
57

58
    /** Retrieves a pointer to the node. This can be used for nodes without an ID. */
59
    private getRoSGNode = new Callable("getrosgnode", {
99✔
60
        signature: {
61
            args: [],
62
            returns: ValueKind.Dynamic,
63
        },
64
        impl: (_: Interpreter) => {
65
            return this.node;
2✔
66
        },
67
    });
68

69
    /** Retrieves the ID of the node that changed. */
70
    private getNode = new Callable("getnode", {
99✔
71
        signature: {
72
            args: [],
73
            returns: ValueKind.Dynamic,
74
        },
75
        impl: (_: Interpreter) => {
76
            return this.node.get(new BrsString("id"));
2✔
77
        },
78
    });
79

80
    /** Retrieves an AA that contains the values of selected "context" fields. */
81
    private getInfo = new Callable("getinfo", {
99✔
82
        signature: {
83
            args: [],
84
            returns: ValueKind.Object,
85
        },
86
        impl: (_: Interpreter) => {
NEW
87
            return this.infoFields ?? new RoAssociativeArray([]);
×
88
        },
89
    });
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc