WIP components (as built)
This commit is contained in:
70 files changed
+2610
-235
No files matched your search
@@ -64,3 +64,52 @@ func TestSourcesPanelSnapshot(t *testing.T) {
|
||||
ui.Column(c).Padding(16).Height(420).Children(func() { SourcesPanel(c, sourcesSample, st) })
|
||||
})
|
||||
}
|
||||
|
||||
func TestSourcesPanelLargeData(t *testing.T) {
|
||||
sources := make([]Source, 100000)
|
||||
for i := range sources {
|
||||
sources[i] = Source{Title: fmt.Sprintf("Archive %d", i), URL: "https://example.com"}
|
||||
}
|
||||
st := CitationState{}
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
Use(c, Settings{})
|
||||
ui.Column(c).Width(360).Height(300).Children(func() { SourcesPanel(c, sources, &st) })
|
||||
}, 400, 300)
|
||||
if n := len(tt.Texts()); n > 250 {
|
||||
t.Fatalf("built %d labels for 100000 sources, want <= 250", n)
|
||||
}
|
||||
st.Active = 99999
|
||||
tt.Frame()
|
||||
r, ok := tt.Find("Archive 99998")
|
||||
if !ok || r.Y < 0 || r.Y+r.H > 300 {
|
||||
t.Fatalf("active source bounds %v found %v", r, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourcesPanelRepeatsCitationLocate(t *testing.T) {
|
||||
sources := make([]Source, 100)
|
||||
for i := range sources {
|
||||
sources[i] = Source{Title: fmt.Sprintf("Archive %d", i+1), URL: "https://example.com"}
|
||||
}
|
||||
var st CitationState
|
||||
actions := 0
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
Use(c, Settings{})
|
||||
ui.Column(c).Fill().Children(func() {
|
||||
if CitationBadge(c, 90, sources[89], &st).Changed() {
|
||||
actions++
|
||||
}
|
||||
ui.Column(c).Height(250).Children(func() { SourcesPanel(c, sources, &st) })
|
||||
})
|
||||
}, 400, 300)
|
||||
for i := range 2 {
|
||||
if err := tt.Click("Source 90: Archive 90"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b, ok := tt.Find("Archive 90")
|
||||
if !ok || b.H == 0 || b.Y < 0 || b.Y+b.H > 300 || actions != i+1 {
|
||||
t.Fatalf("locate %d: bounds %v found %v events %d", i+1, b, ok, actions)
|
||||
}
|
||||
tt.Scroll(100, 150, 0, -100000)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user