• 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

9.84
/src/brsTypes/components/RoSGScreen.ts
1
import { BrsComponent } from "./BrsComponent";
143✔
2
import { ValueKind, BrsString, BrsValue, BrsBoolean, Uninitialized, BrsInvalid } from "../BrsType";
143✔
3
import { Callable, StdlibArgument } from "../Callable";
143✔
4
import { Interpreter } from "../../interpreter";
5
import { BrsNodeType, BrsType, createNodeByType, mGlobal, NodeFactory, RoSGNode } from "..";
143✔
6
import { RoSGScreenEvent } from "./RoSGScreenEvent";
143✔
7
import { RoMessagePort } from "./RoMessagePort";
8

9
export class roSGScreen extends BrsComponent implements BrsValue {
143✔
NEW
10
    readonly kind = ValueKind.Object;
×
11
    private port?: RoMessagePort;
12
    private sceneNode?: RoSGNode;
13
    constructor(_: Interpreter) {
NEW
14
        super("roSGScreen");
×
NEW
15
        this.registerMethods({
×
16
            ifSGScreen: [
17
                this.getGlobalNode,
18
                this.show,
19
                this.close,
20
                this.createScene,
21
                this.getScene,
22
                this.setMessagePort,
23
                this.getMessagePort,
24
            ],
25
        });
26
    }
27

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

33
    toString() {
NEW
34
        return "<Component: roSGScreen>";
×
35
    }
36

37
    /** Returns a global reference object for the SceneGraph application. */
NEW
38
    private getGlobalNode = new Callable("getGlobalNode", {
×
39
        signature: {
40
            args: [],
41
            returns: ValueKind.Dynamic,
42
        },
43
        impl: (_: Interpreter) => {
NEW
44
            return mGlobal ?? BrsInvalid.Instance;
×
45
        },
46
    });
47

48
    /** Renders the SceneGraph scene defined by the roSGScreen object on the display screen. */
NEW
49
    private show = new Callable("show", {
×
50
        signature: {
51
            args: [],
52
            returns: ValueKind.Boolean,
53
        },
54
        impl: (_: Interpreter) => {
55
            // TODO: Implement show
NEW
56
            return BrsBoolean.False;
×
57
        },
58
    });
59

60
    /** Removes the SceneGraph scene from the display screen. */
NEW
61
    private close = new Callable("close", {
×
62
        signature: {
63
            args: [],
64
            returns: ValueKind.Void,
65
        },
66
        impl: (_: Interpreter) => {
NEW
67
            this.port?.pushMessage(new RoSGScreenEvent(BrsBoolean.True));
×
NEW
68
            return Uninitialized.Instance;
×
69
        },
70
    });
71

72
    /** Creates the SceneGraph scene object based on the specified sceneType object. */
NEW
73
    private createScene = new Callable("createScene", {
×
74
        signature: {
75
            args: [new StdlibArgument("sceneType", ValueKind.String)],
76
            returns: ValueKind.Object,
77
        },
78
        impl: (interpreter: Interpreter, sceneType: BrsString) => {
NEW
79
            let returnValue: BrsType = BrsInvalid.Instance;
×
NEW
80
            if (sceneType.value === "Scene") {
×
NEW
81
                returnValue = NodeFactory.createNode(BrsNodeType.Scene) ?? BrsInvalid.Instance;
×
82
            } else {
NEW
83
                const typeDef = interpreter.environment.nodeDefMap.get(
×
84
                    sceneType.value.toLowerCase()
85
                );
NEW
86
                if (typeDef && typeDef.extends === "Scene") {
×
NEW
87
                    returnValue = createNodeByType(interpreter, sceneType);
×
88
                }
89
            }
NEW
90
            if (returnValue instanceof RoSGNode) {
×
NEW
91
                this.sceneNode = returnValue;
×
92
            }
NEW
93
            return returnValue;
×
94
        },
95
    });
96

97
    /** The roSGScene object associated with the screen. */
NEW
98
    private getScene = new Callable("getScene", {
×
99
        signature: {
100
            args: [],
101
            returns: ValueKind.Object,
102
        },
103
        impl: (_: Interpreter) => {
NEW
104
            return this.sceneNode ?? BrsInvalid.Instance;
×
105
        },
106
    });
107

108
    /** Sets the roMessagePort to be used for all events from the component */
NEW
109
    private setMessagePort = new Callable("setMessagePort", {
×
110
        signature: {
111
            args: [new StdlibArgument("port", ValueKind.Dynamic)],
112
            returns: ValueKind.Void,
113
        },
114
        impl: (_, port: RoMessagePort) => {
NEW
115
            this.port = port;
×
NEW
116
            return BrsInvalid.Instance;
×
117
        },
118
    });
119
    /** Returns the message port (if any) currently associated with the object */
NEW
120
    readonly getMessagePort = new Callable("getMessagePort", {
×
121
        signature: {
122
            args: [],
123
            returns: ValueKind.Object,
124
        },
125
        impl: (_) => {
NEW
126
            return this.port ?? BrsInvalid.Instance;
×
127
        },
128
    });
129
}
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