(t *testing.T)
| 194 | } |
| 195 | } |
| 196 | func TestStateTreeNode(t *testing.T) { |
| 197 | ctx := log.Testing(t) |
| 198 | ctx = database.Put(ctx, database.NewInMemory(ctx)) |
| 199 | header := capture.Header{ABI: device.AndroidARM64v8a} |
| 200 | cap, err := capture.NewGraphicsCapture(ctx, arena.New(), "test-capture", &header, nil, []api.Cmd{}) |
| 201 | if err != nil { |
| 202 | panic(err) |
| 203 | } |
| 204 | c, err := cap.Path(ctx) |
| 205 | if err != nil { |
| 206 | panic(err) |
| 207 | } |
| 208 | ctx = capture.Put(ctx, c) |
| 209 | rootPath := c.Command(0).StateAfter() |
| 210 | gs, err := capture.NewState(ctx) |
| 211 | if err != nil { |
| 212 | panic(err) |
| 213 | } |
| 214 | tree := &stateTree{ |
| 215 | globalState: gs, |
| 216 | root: &stn{ |
| 217 | name: "root", |
| 218 | value: reflect.ValueOf(testState), |
| 219 | path: rootPath, |
| 220 | }, |
| 221 | api: &path.API{ID: path.NewID(id.ID(test.API{}.ID()))}, |
| 222 | groupLimit: 10, |
| 223 | } |
| 224 | root := &path.StateTreeNode{Indices: []uint64{}} |
| 225 | |
| 226 | // Write some data to 0x1000. |
| 227 | e := gs.MemoryEncoder(memory.ApplicationPool, memory.Range{Base: 0x1000, Size: 0x8000}) |
| 228 | for i := 0; i < 0x1000; i++ { |
| 229 | e.I64(int64(i * 10)) |
| 230 | } |
| 231 | |
| 232 | for _, test := range []struct { |
| 233 | path *path.StateTreeNode |
| 234 | expected *service.StateTreeNode |
| 235 | }{ |
| 236 | { |
| 237 | root, |
| 238 | &service.StateTreeNode{ |
| 239 | NumChildren: 7, |
| 240 | Name: "root", |
| 241 | ValuePath: rootPath.Path(), |
| 242 | }, |
| 243 | }, { |
| 244 | root.Index(0), // 0 |
| 245 | &service.StateTreeNode{ |
| 246 | NumChildren: 0, |
| 247 | Name: "Bool", |
| 248 | ValuePath: rootPath.Field("Bool").Path(), |
| 249 | Preview: box.NewValue(true), |
| 250 | PreviewIsValue: true, |
| 251 | }, |
| 252 | }, { |
| 253 | root.Index(1), // 1 |
nothing calls this directly
no test coverage detected