mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
unit: add PxToDp and PxToSp
PxToDp and PxToSp are useful when you are trying to calculate text-size or widget size based on dynamically sized container. Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
@@ -29,4 +29,20 @@ func TestMetric_DpToSp(t *testing.T) {
|
||||
t.Errorf("SpToDp conversion mismatch %v != %v", exp, got)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
exp := unit.Dp(5)
|
||||
got := m.PxToDp(m.Dp(5))
|
||||
if got != exp {
|
||||
t.Errorf("PxToDp conversion mismatch %v != %v", exp, got)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
exp := unit.Sp(5)
|
||||
got := m.PxToSp(m.Sp(5))
|
||||
if got != exp {
|
||||
t.Errorf("PxToSp conversion mismatch %v != %v", exp, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user