-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finish Dim.Auto (Content)
#3499
Comments
@tig I added these two [Fact]
public void Dim_Auto_ContentSize_Min_Max ()
{
var size = new Size (5, 5);
var view1 = new View { Width = Auto (DimAutoStyle.Auto, 10), Height = Auto (DimAutoStyle.Auto, 10) };
view1.SetContentSize (size);
var view2 = new View { Width = Auto (DimAutoStyle.Auto, 10, 30), Height = Auto (DimAutoStyle.Auto, 10, 30) };
view2.SetContentSize (size);
var view3 = new View { Width = Auto (DimAutoStyle.Auto, 10, Fill ()), Height = Auto (DimAutoStyle.Auto, 10, Fill ()) };
view3.SetContentSize (size);
var top = new View { Width = 20, Height = 20 };
top.Add (view1, view2, view3);
top.LayoutSubviews ();
Assert.Equal (new (0, 0, 10, 10), view1.Frame);
Assert.Equal (new (0, 0, 10, 10), view2.Frame);
Assert.Equal (new (0, 0, 10, 10), view3.Frame);
size = new (35, 35);
view1.SetContentSize (size);
view2.SetContentSize (size);
view3.SetContentSize (size);
top.Width = 40;
top.Height = 40;
top.LayoutSubviews ();
Assert.Equal (size, view1.GetContentSize ());
Assert.Equal (size, view2.GetContentSize ());
Assert.Equal (size, view3.GetContentSize ());
Assert.Equal (new (0, 0, 35, 35), view1.Frame);
Assert.Equal (new (0, 0, 30, 30), view2.Frame);
Assert.Equal (new (0, 0, 35, 35), view3.Frame);
size = new (50, 50);
view1.SetContentSize (size);
view2.SetContentSize (size);
view3.SetContentSize (size);
top.LayoutSubviews ();
Assert.Equal (size, view1.GetContentSize ());
Assert.Equal (size, view2.GetContentSize ());
Assert.Equal (size, view3.GetContentSize ());
Assert.Equal (new (0, 0, 50, 50), view1.Frame);
Assert.Equal (new (0, 0, 30, 30), view2.Frame);
Assert.Equal (new (0, 0, 40, 40), view3.Frame);
}
[Fact]
public void Dim_Auto_Text_Min_Max ()
{
var length = 5;
var view1 = new View { Width = Auto (DimAutoStyle.Auto, 10), Height = Auto (DimAutoStyle.Auto, 10) };
view1.Text = new ('x', length);
var view2 = new View { Width = Auto (DimAutoStyle.Auto, 10, 30), Height = Auto (DimAutoStyle.Auto, 10, 30) };
view2.TextDirection = TextDirection.TopBottom_LeftRight;
view2.Text = new ('x', length);
var view3 = new View { Width = Auto (DimAutoStyle.Auto, 10, Fill ()), Height = Auto (DimAutoStyle.Auto, 10, Fill ()) };
view3.Text = new ('x', length);
var top = new View { Width = 20, Height = 20 };
top.Add (view1, view2, view3);
top.LayoutSubviews ();
Assert.Equal (new (0, 0, 10, 10), view1.Frame);
Assert.Equal (new (0, 0, 10, 10), view2.Frame);
Assert.Equal (new (0, 0, 10, 10), view3.Frame);
length = 35;
view1.Text = new ('x', length);
view2.Text = new ('x', length);
view3.Text = new ('x', length);
top.Width = 40;
top.Height = 40;
top.LayoutSubviews ();
Assert.Equal (length, view1.Text.Length);
Assert.Equal (length, view2.Text.Length);
Assert.Equal (length, view3.Text.Length);
Assert.Equal (new (0, 0, 35, 10), view1.Frame);
Assert.Equal (new (0, 0, 10, 30), view2.Frame);
// This gives {X = 0 Y = 0 Width = 35 Height = 10}
// but I think the Fill should be respected
Assert.Equal (new (0, 0, 40, 10), view3.Frame);
length = 50;
view1.Text = new ('x', length);
view2.Text = new ('x', length);
view3.Text = new ('x', length);
top.LayoutSubviews ();
Assert.Equal (length, view1.Text.Length);
Assert.Equal (length, view2.Text.Length);
Assert.Equal (length, view3.Text.Length);
Assert.Equal (new (0, 0, 50, 10), view1.Frame);
Assert.Equal (new (0, 0, 10, 30), view2.Frame);
Assert.Equal (new (0, 0, 40, 10), view3.Frame);
} |
I appreciate you doing this, but there is a LOT going on in those tests. Is there any way you can simplify them down to more precise cases? If not, that's ok... but it would make my life a lot easier. |
Basically in each test, using |
Fixes #3499. Finishes `Dim.Auto` implementation
This puppy is not really finished:
Dim.Auto
forContent
including subviews. #3451DimAutoStyle.Content
sorta works. Needs moar. This issue is to track.The text was updated successfully, but these errors were encountered: