Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package platform
|
|
|
|
import "testing"
|
|
|
|
// A placement's page takes the pointer in its clip, inside its rounded
|
|
// corners, as it shows scaled, and where nothing covers it.
|
|
func TestWebViewPlacementAt(t *testing.T) {
|
|
// A page 200 by 100 shown at half its size, from 10, 20, its corners
|
|
// rounded by 20 of its DIPs: 10 of the surface's.
|
|
p := WebViewPlacement{
|
|
Frame: RectF{X: 10, Y: 20, W: 100, H: 50}, Clip: RectF{X: 10, Y: 20, W: 100, H: 50},
|
|
Width: 200, Height: 100, Radii: [4]float64{20, 20, 20, 0},
|
|
Covers: []RectF{{X: 50, Y: 40, W: 10, H: 10}},
|
|
}
|
|
if sx, sy := p.Scale(); sx != 0.5 || sy != 0.5 {
|
|
t.Errorf("scale %v, %v: want a half", sx, sy)
|
|
}
|
|
if x, y := p.ToPage(60, 45); x != 100 || y != 50 {
|
|
t.Errorf("the surface's 60, 45 is the page's %v, %v: want its center", x, y)
|
|
}
|
|
for _, c := range []struct {
|
|
x, y float64
|
|
want bool
|
|
}{
|
|
{60, 30, true}, // inside
|
|
{11, 21, false}, // cut off by the top-left corner
|
|
{109, 21, false}, // the top-right
|
|
{109, 69, false}, // the bottom-right
|
|
{11, 69, true}, // the bottom-left is square
|
|
{13, 23, true}, // inside the top-left corner's curve
|
|
{11, 30, true}, // below the top-left corner
|
|
{55, 45, false}, // covered
|
|
{5, 30, false}, // outside the clip
|
|
} {
|
|
if got := p.At(c.x, c.y); got != c.want {
|
|
t.Errorf("At(%v, %v) = %v, want %v", c.x, c.y, got, c.want)
|
|
}
|
|
}
|
|
// Without a size, the page is the frame's.
|
|
q := WebViewPlacement{Frame: RectF{W: 40, H: 30}, Clip: RectF{W: 40, H: 30}}
|
|
if w, h := q.Size(); w != 40 || h != 30 || !q.At(1, 1) || q.Rounded() {
|
|
t.Errorf("a placement without a size or corners: size %v by %v", w, h)
|
|
}
|
|
}
|