This repository has been archived on 2022-06-29. You can view files and clone it, but cannot push or open issues or pull requests.
urtrator/vendor/github.com/mattn/go-gtk/gtk/gtk_test.go
Jon Chen 737231705f
adds vendor directory
vendors dependencies in standard `vendor` directory, managed by glide
2017-05-14 19:35:03 -07:00

59 lines
1.3 KiB
Go

package gtk
import (
"testing"
)
func TestUpdateTreeViewColumns(t *testing.T) {
Init(nil)
columnsDesc := []struct {
Title string
Type string
GTKType ICellRenderer
}{
{"Col_1", "text", NewCellRendererText()},
{"Col_2", "text", NewCellRendererText()},
}
tw := NewTreeView()
for i, c := range columnsDesc {
tw.AppendColumn(NewTreeViewColumnWithAttributes(c.Title, c.GTKType, c.Type, i))
}
columns := tw.GetColumns()
if len(columns) != len(columnsDesc) {
t.Error("Wrong number of the columns:", len(columns), len(columnsDesc))
} else {
for i, _ := range columnsDesc {
if columns[i].GetTitle() != columnsDesc[i].Title {
t.Error("Wrong column title:", columns[i].GetTitle(), columnsDesc[i].Title)
}
}
}
for lastIndex := len(columns) - 1; lastIndex >= 0; {
c := columns[lastIndex]
after := tw.RemoveColumn(c)
numbersColumns := lastIndex
if numbersColumns != after {
t.Error("Failed remove column:", numbersColumns, after)
}
lastIndex -= 1
if lastIndex >= 0 {
if title := tw.GetColumns()[lastIndex].GetTitle(); title != columnsDesc[lastIndex].Title {
t.Error("Wrong column title:", title, columnsDesc[lastIndex].Title)
}
}
}
if count := len(tw.GetColumns()); count != 0 {
t.Error("Wrong number of the columns:", count)
}
}