Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions framework/src/components/rooibos/RooibosResultRow.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
function init() as void
m.bar = m.top.findNode("bar")
m.nameLabel = m.top.findNode("nameLabel")
m.countLabel = m.top.findNode("countLabel")

m.colors = {
passBar: "#3ddc97"
failBar: "#ff5470"
passName: "#cfcfdc"
failName: "#ffdcdc"
focusName: "#6c63ff"
countText: "#ff5470"
}
m.countLabel.color = m.colors.countText

m.passed = true
m.failedCount = 0
m.totalCount = 0
end function

function onItemContentChanged() as void
content = m.top.itemContent
if content = invalid then return

if content.passed = invalid then
m.passed = true
else
m.passed = content.passed
end if
m.failedCount = pickInt(content.failedCount, 0)
m.totalCount = pickInt(content.totalCount, 0)

name = ""
if content.name <> invalid then name = content.name
m.nameLabel.text = name

if m.passed then
m.bar.color = m.colors.passBar
else
m.bar.color = m.colors.failBar
end if

applyDisplay()
end function

function onFocusChanged() as void
applyDisplay()
end function

function applyDisplay() as void
focused = m.top.itemHasFocus
m.nameLabel.color = nameColorFor(focused, m.passed)
m.countLabel.text = countTextFor(focused, m.passed, m.failedCount, m.totalCount)
end function

function nameColorFor(focused as boolean, passed as boolean) as string
if focused then return m.colors.focusName
if passed then return m.colors.passName
return m.colors.failName
end function

function countTextFor(focused as boolean, passed as boolean, failedCount as integer, totalCount as integer) as string
if not focused or passed or totalCount <= 0 or failedCount <= 0 then return ""
if failedCount = totalCount then
return "all " + totalCount.toStr().trim() + " failed"
end if
return failedCount.toStr().trim() + " failed"
end function

function pickInt(value as dynamic, fallback as integer) as integer
if value = invalid then return fallback
return value
end function
26 changes: 26 additions & 0 deletions framework/src/components/rooibos/RooibosResultRow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<component name="RooibosResultRow" extends="Group">
<script type="text/brightscript" uri="pkg:/components/rooibos/RooibosResultRow.brs" />

<interface>
<field id="itemContent" type="node" onChange="onItemContentChanged" />
<field id="itemHasFocus" type="bool" onChange="onFocusChanged" />
</interface>

<children>
<Rectangle id="bar" width="3" height="22" color="#3ddc97" translation="[0, 0]" />
<Label id="nameLabel"
font="font:SmallestSystemFont"
color="#cfcfdc"
width="340" height="22"
translation="[14, 0]"
vertAlign="center" />
<Label id="countLabel"
font="font:SmallestSystemFont"
color="#ff5470"
width="130" height="22"
translation="[360, 0]"
horizAlign="right"
vertAlign="center" />
</children>
</component>
36 changes: 36 additions & 0 deletions framework/src/components/rooibos/RooibosScrollableResults.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function init() as void
m.rootContent = m.top.findNode("rootContent")
m.top.itemComponentName = "RooibosResultRow"
m.top.drawFocusFeedback = false
end function

' Append a result line. args is an associative array with:
' name as string — display text
' passed as boolean — true for OK rows, false for failed/error rows
' failedCount as integer — failures within the suite (failed rows only)
' totalCount as integer — total tests run within the suite
function appendLine(args as object) as void
if args = invalid or args.name = invalid then return

item = m.rootContent.createChild("ContentNode")
item.addFields({
name: ""
passed: true
failedCount: 0
totalCount: 0
})

item.name = args.name
if args.passed <> invalid then item.passed = args.passed
if args.failedCount <> invalid then item.failedCount = args.failedCount
if args.totalCount <> invalid then item.totalCount = args.totalCount

' Auto-scroll to the new row
m.top.jumpToItem = m.rootContent.getChildCount() - 1
end function

function clear() as void
while m.rootContent.getChildCount() > 0
m.rootContent.removeChildrenIndex(m.rootContent.getChildCount(), 0)
end while
end function
13 changes: 13 additions & 0 deletions framework/src/components/rooibos/RooibosScrollableResults.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<component name="RooibosScrollableResults" extends="MarkupList">
<script type="text/brightscript" uri="pkg:/components/rooibos/RooibosScrollableResults.brs" />

<interface>
<function name="appendLine" />
<function name="clear" />
</interface>

<children>
<ContentNode id="rootContent" role="content" />
</children>
</component>
Binary file added framework/src/images/rooibos/failure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added framework/src/images/rooibos/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added framework/src/images/rooibos/success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading