MCPcopy Index your code
hub / github.com/EngoEngine/engo / TestTMXFiletypeLoad

Function TestTMXFiletypeLoad

common/tmx_test.go:113–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

111func (*tmxTestScene) Type() string { return "testScene" }
112
113func TestTMXFiletypeLoad(t *testing.T) {
114 // Start an instance of engo
115 engo.Run(engo.RunOptions{
116 NoRun: true,
117 HeadlessMode: true,
118 }, &tmxTestScene{})
119
120 // Create an image in memory
121 imgbuf := bytes.NewBuffer([]byte{})
122 img := image.NewRGBA(image.Rect(0, 0, 457, 305))
123 err := png.Encode(imgbuf, img)
124 if err != nil {
125 t.Errorf("Unable to encode png from image")
126 }
127
128 // Load the image
129 err = engo.Files.LoadReaderData("test.png", imgbuf)
130 if err != nil {
131 t.Errorf("Unable to load test png. Error was: %v", err)
132 }
133
134 // Load the template
135 buf := bytes.NewBuffer([]byte{})
136 tmpl, err := template.New("test").Parse(testTMXtmpl)
137 if err != nil {
138 t.Error("Error parsing tmx template")
139 }
140 err = tmpl.Execute(buf, tmxData{
141 Orientation: "orthogonal",
142 RenderOrder: "right-down",
143 })
144 if err != nil {
145 t.Error("Error executing tmx template")
146 }
147
148 // Load tmx
149 err = engo.Files.LoadReaderData("test.tmx", buf)
150 if err != nil {
151 t.Errorf("Unable to load tmx file for testing. Error was: %v", err)
152 }
153}
154
155func TestTMXTileNotLoadedFileNotExist(t *testing.T) {
156 // Ensure the file is not loaded

Callers

nothing calls this directly

Calls 4

RunFunction · 0.92
LoadReaderDataMethod · 0.80
NewMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected