Extract app UI layout primitives
This commit is contained in:
+13
-12
@@ -25,6 +25,7 @@ import (
|
||||
"git.julianfamily.org/keepassgo/internal/apiaudit"
|
||||
"git.julianfamily.org/keepassgo/internal/apitokens"
|
||||
"git.julianfamily.org/keepassgo/internal/appstate"
|
||||
appuilayout "git.julianfamily.org/keepassgo/internal/appui/layout"
|
||||
"git.julianfamily.org/keepassgo/internal/clipboard"
|
||||
"git.julianfamily.org/keepassgo/internal/passwords"
|
||||
"git.julianfamily.org/keepassgo/internal/session"
|
||||
@@ -372,10 +373,10 @@ func TestUIHeaderMenusUseOverlayModelAcrossModes(t *testing.T) {
|
||||
func TestAnchoredMenuXAllowsWiderMenusToExtendLeft(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := anchoredMenuX(48, 160); got != -112 {
|
||||
if got := appuilayout.AnchoredMenuX(48, 160); got != -112 {
|
||||
t.Fatalf("anchoredMenuX(48, 160) = %d, want -112", got)
|
||||
}
|
||||
if got := anchoredMenuX(160, 48); got != 112 {
|
||||
if got := appuilayout.AnchoredMenuX(160, 48); got != 112 {
|
||||
t.Fatalf("anchoredMenuX(160, 48) = %d, want 112", got)
|
||||
}
|
||||
}
|
||||
@@ -383,10 +384,10 @@ func TestAnchoredMenuXAllowsWiderMenusToExtendLeft(t *testing.T) {
|
||||
func TestAnchoredMenuOriginXClampsToVisibleContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := anchoredMenuOriginX(360, 312, 360, 140); got != 220 {
|
||||
if got := appuilayout.AnchoredMenuOriginX(360, 312, 360, 140); got != 220 {
|
||||
t.Fatalf("anchoredMenuOriginX should keep a right-aligned menu visible, got %d want 220", got)
|
||||
}
|
||||
if got := anchoredMenuOriginX(360, 0, 44, 160); got != 0 {
|
||||
if got := appuilayout.AnchoredMenuOriginX(360, 0, 44, 160); got != 0 {
|
||||
t.Fatalf("anchoredMenuOriginX should clamp oversized left overflow to zero, got %d want 0", got)
|
||||
}
|
||||
}
|
||||
@@ -394,7 +395,7 @@ func TestAnchoredMenuOriginXClampsToVisibleContainer(t *testing.T) {
|
||||
func TestHeaderActionMetricsComputeTriggerAnchors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
metrics := headerActionMetrics{
|
||||
metrics := appuilayout.HeaderActionMetrics{
|
||||
RowOriginX: 24,
|
||||
Spacing: 8,
|
||||
RowDims: layout.Dimensions{Size: image.Pt(180, 40)},
|
||||
@@ -403,10 +404,10 @@ func TestHeaderActionMetricsComputeTriggerAnchors(t *testing.T) {
|
||||
MainDims: layout.Dimensions{Size: image.Pt(36, 40)},
|
||||
}
|
||||
|
||||
if got := metrics.syncAnchor(); got != (dropdownAnchor{TriggerRightX: 76, TriggerBottomY: 40}) {
|
||||
if got := metrics.SyncAnchor(); got != (appuilayout.DropdownAnchor{TriggerRightX: 76, TriggerBottomY: 40}) {
|
||||
t.Fatalf("metrics.syncAnchor() = %+v, want right=76 bottom=40", got)
|
||||
}
|
||||
if got := metrics.mainAnchor(); got != (dropdownAnchor{TriggerRightX: 172, TriggerBottomY: 40}) {
|
||||
if got := metrics.MainAnchor(); got != (appuilayout.DropdownAnchor{TriggerRightX: 172, TriggerBottomY: 40}) {
|
||||
t.Fatalf("metrics.mainAnchor() = %+v, want right=172 bottom=40", got)
|
||||
}
|
||||
}
|
||||
@@ -414,15 +415,15 @@ func TestHeaderActionMetricsComputeTriggerAnchors(t *testing.T) {
|
||||
func TestDropdownSurfaceOriginKeepsMenusWithinVisibleArea(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
surface := dropdownSurface{ContainerWidth: 320, LeftInset: 16, TopInset: 16}
|
||||
anchor := dropdownAnchor{TriggerRightX: 300, TriggerBottomY: 42}
|
||||
surface := appuilayout.DropdownSurface{ContainerWidth: 320, LeftInset: 16, TopInset: 16}
|
||||
anchor := appuilayout.DropdownAnchor{TriggerRightX: 300, TriggerBottomY: 42}
|
||||
|
||||
if got := surface.origin(anchor, 140); got != image.Pt(176, 58) {
|
||||
if got := surface.Origin(anchor, 140); got != image.Pt(176, 58) {
|
||||
t.Fatalf("surface.origin(anchor, 140) = %v, want (176,58)", got)
|
||||
}
|
||||
|
||||
leftAnchor := dropdownAnchor{TriggerRightX: 36, TriggerBottomY: 42}
|
||||
if got := surface.origin(leftAnchor, 120); got != image.Pt(16, 58) {
|
||||
leftAnchor := appuilayout.DropdownAnchor{TriggerRightX: 36, TriggerBottomY: 42}
|
||||
if got := surface.Origin(leftAnchor, 120); got != image.Pt(16, 58) {
|
||||
t.Fatalf("surface.origin(leftAnchor, 120) = %v, want (16,58)", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user