Example #1
0
func TestTreeToListNodeFlat(t *testing.T) {
	list_adapter, _ := a(n(10), n(20), n(30))
	test(t, "flat", list_adapter,
		gxui.AdapterItem(10),
		gxui.AdapterItem(20),
		gxui.AdapterItem(30),
	)
}
Example #2
0
func TestTreeToListNodeDeep(t *testing.T) {

	list_adapter, tree_adapter := a(
		n(100,
			n(110),
			n(120,
				n(121),
				n(122),
				n(123)),
			n(130),
			n(140,
				n(141),
				n(142))))

	test(t, "unexpanded", list_adapter,
		gxui.AdapterItem(100),
	)

	list_adapter.node.children[0].Expand()
	test(t, "single expanded", list_adapter,
		gxui.AdapterItem(100), // (0) 100
		gxui.AdapterItem(110), // (1)  ╠══ 110
		gxui.AdapterItem(120), // (2)  ╠══ 120
		gxui.AdapterItem(130), // (3)  ╠══ 130
		gxui.AdapterItem(140), // (4)  ╚══ 140
	)

	list_adapter.ExpandAll()
	test(t, "fully expanded", list_adapter,
		gxui.AdapterItem(100), // (0) 100
		gxui.AdapterItem(110), // (1)  ╠══ 110
		gxui.AdapterItem(120), // (2)  ╠══ 120
		gxui.AdapterItem(121), // (3)  ║    ╠══ 121
		gxui.AdapterItem(122), // (4)  ║    ╠══ 122
		gxui.AdapterItem(123), // (5)  ║    ╚══ 123
		gxui.AdapterItem(130), // (6)  ╠══ 130
		gxui.AdapterItem(140), // (7)  ╚══ 140
		gxui.AdapterItem(141), // (8)       ╠══ 141
		gxui.AdapterItem(142), // (9)       ╚══ 142
	)

	list_adapter.node.NodeAt(2).Collapse()
	test(t, "one collapsed", list_adapter,
		gxui.AdapterItem(100), // (0) 100
		gxui.AdapterItem(110), // (1)  ╠══ 110
		gxui.AdapterItem(120), // (2)  ╠══ 120
		gxui.AdapterItem(130), // (3)  ╠══ 130
		gxui.AdapterItem(140), // (4)  ╚══ 140
		gxui.AdapterItem(141), // (5)       ╠══ 141
		gxui.AdapterItem(142), // (6)       ╚══ 142
	)

	tree_adapter.children[0].children = append(tree_adapter.children[0].children, n(150))
	test(t, "mutate, no data-changed", list_adapter,
		gxui.AdapterItem(100), // (0) 100
		gxui.AdapterItem(110), // (1)  ╠══ 110
		gxui.AdapterItem(120), // (2)  ╠══ 120
		gxui.AdapterItem(130), // (3)  ╠══ 130
		gxui.AdapterItem(140), // (4)  ╚══ 140
		gxui.AdapterItem(141), // (5)       ╠══ 141
		gxui.AdapterItem(142), // (6)       ╚══ 142
	)

	tree_adapter.DataChanged(false)
	test(t, "data-changed", list_adapter,
		gxui.AdapterItem(100), // (0) 100
		gxui.AdapterItem(110), // (1)  ╠══ 110
		gxui.AdapterItem(120), // (2)  ╠══ 120
		gxui.AdapterItem(130), // (3)  ╠══ 130
		gxui.AdapterItem(140), // (4)  ╠══ 140
		gxui.AdapterItem(141), // (5)  ║    ╠══ 141
		gxui.AdapterItem(142), // (6)  ║    ╚══ 142
		gxui.AdapterItem(150), // (7)  ╚══ 150
	)
}