コード例 #1
0
ファイル: tree_to_list_test.go プロジェクト: liulnn/gxui
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),
	)
}
コード例 #2
0
func TestTINFlatSimple(t *testing.T) {
	N := createTestTreeNode
	root := CreateTreeInternalRoot(N(0, N(10), N(20), N(30)))

	test.AssertEquals(t, 3, root.descendants)
	test.AssertEquals(t, gxui.AdapterItem(10), root.ItemAt(0))
	test.AssertEquals(t, gxui.AdapterItem(20), root.ItemAt(1))
	test.AssertEquals(t, gxui.AdapterItem(30), root.ItemAt(2))
}
コード例 #3
0
func TestTINExpandExpandFirst(t *testing.T) {
	N := createTestTreeNode
	root := CreateTreeInternalRoot(N(0,
		N(10,
			N(11), N(12), N(13), N(14)),
		N(20,
			N(21), N(22), N(23), N(24)),
		N(30,
			N(31), N(32), N(33), N(34)),
	))

	root.Child(0).Expand()
	test.AssertEquals(t, 7, root.descendants)
	test.AssertEquals(t, gxui.AdapterItem(10), root.ItemAt(0))
	test.AssertEquals(t, gxui.AdapterItem(11), root.ItemAt(1))
	test.AssertEquals(t, gxui.AdapterItem(12), root.ItemAt(2))
	test.AssertEquals(t, gxui.AdapterItem(13), root.ItemAt(3))
	test.AssertEquals(t, gxui.AdapterItem(14), root.ItemAt(4))
	test.AssertEquals(t, gxui.AdapterItem(20), root.ItemAt(5))

	root.Child(0).Collapse()
	test.AssertEquals(t, 3, root.descendants)
	test.AssertEquals(t, gxui.AdapterItem(10), root.ItemAt(0))
	test.AssertEquals(t, gxui.AdapterItem(20), root.ItemAt(1))
	test.AssertEquals(t, gxui.AdapterItem(30), root.ItemAt(2))
}
コード例 #4
0
func TestTINDeepNoExpand(t *testing.T) {
	N := createTestTreeNode
	root := CreateTreeInternalRoot(N(0,
		N(10,
			N(11), N(12), N(13), N(14)),
		N(20,
			N(21), N(22), N(23), N(24)),
		N(30,
			N(31), N(32), N(33), N(34)),
	))

	test.AssertEquals(t, 3, root.descendants)
	test.AssertEquals(t, gxui.AdapterItem(10), root.ItemAt(0))
	test.AssertEquals(t, gxui.AdapterItem(20), root.ItemAt(1))
	test.AssertEquals(t, gxui.AdapterItem(30), root.ItemAt(2))
}
コード例 #5
0
ファイル: tree_to_list_test.go プロジェクト: liulnn/gxui
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
	)
}