MCPcopy
hub / github.com/go-qml/qml / TestContextSetVars

Method TestContextSetVars

qml_test.go:227–258  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

225}
226
227func (s *S) TestContextSetVars(c *C) {
228 component, err := s.engine.LoadString("file.qml", "import QtQuick 2.0\nItem { width: 42 }")
229 c.Assert(err, IsNil)
230 root := component.Create(nil)
231
232 vars := GoType{
233 StringValue: "<content>",
234 BoolValue: true,
235 IntValue: 42,
236 Int64Value: 42,
237 Int32Value: 42,
238 Float64Value: 4.2,
239 Float32Value: 4.2,
240 AnyValue: nil,
241 ObjectValue: root,
242 }
243 s.context.SetVars(&vars)
244
245 c.Assert(s.context.Var("stringValue"), Equals, "<content>")
246 c.Assert(s.context.Var("boolValue"), Equals, true)
247 c.Assert(s.context.Var("intValue"), Equals, 42)
248 c.Assert(s.context.Var("int64Value"), Equals, int64(42))
249 c.Assert(s.context.Var("int32Value"), Equals, 42)
250 c.Assert(s.context.Var("float64Value"), Equals, float64(4.2))
251 c.Assert(s.context.Var("float32Value"), Equals, float32(4.2))
252 c.Assert(s.context.Var("anyValue"), Equals, nil)
253
254 vars.AnyValue = 42
255 c.Assert(s.context.Var("anyValue"), Equals, 42)
256
257 c.Assert(s.context.Var("objectValue").(qml.Object).Int("width"), Equals, 42)
258}
259
260func (s *S) TestComponentSetDataError(c *C) {
261 _, err := s.engine.LoadString("file.qml", "Item{}")

Callers

nothing calls this directly

Calls 5

LoadStringMethod · 0.80
SetVarsMethod · 0.80
VarMethod · 0.80
CreateMethod · 0.65
IntMethod · 0.65

Tested by

no test coverage detected