WIP components (as built)
This commit is contained in:
112 files changed
+3607
-1241
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package mujica
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
func TestOHLCChartSharesDataAndDiffersInLook(t *testing.T) {
|
||||
candles := sampleCandles(60)
|
||||
view := MarketView{Count: 40}
|
||||
ohlc := true
|
||||
var res ChartResult
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
Use(c, Settings{})
|
||||
if ohlc {
|
||||
res = OHLCChart(c, candles, &view, CandlestickOptions{Frame: ChartFrame{Label: "Bars"}})
|
||||
} else {
|
||||
res = CandlestickChart(c, candles, &view, CandlestickOptions{Frame: ChartFrame{Label: "Bars"}})
|
||||
}
|
||||
}, 600, 320)
|
||||
tt.Key(0, ui.KeyTab)
|
||||
tt.Key(0, ui.KeyEnd)
|
||||
if res.Point != 59 || mktState0(res).drawn != 40 {
|
||||
t.Fatalf("point %d drawn %d", res.Point, mktState0(res).drawn)
|
||||
}
|
||||
a := encode(t, tt.Image())
|
||||
ohlc = false
|
||||
tt.Frame()
|
||||
if bytes.Equal(a, encode(t, tt.Image())) {
|
||||
t.Fatal("OHLC bars look the same as candles")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOHLCChartSnapshot(t *testing.T) {
|
||||
candles := sampleCandles(60)
|
||||
view := MarketView{Count: 50}
|
||||
snapshot(t, "ohlc_chart", 640, 300, func(c *ui.Context) {
|
||||
ui.Column(c).Padding(12).Children(func() {
|
||||
OHLCChart(c, candles, &view, CandlestickOptions{Frame: ChartFrame{Label: "Bars", Height: 240}})
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user