Comments (3)
@tig I added these two DimAutoStyle.Auto
unit tests to give an opinion on how the behavior is verified using ContentSize
and Text
. Only the test that uses Text
fails if the maximum value is defined as Fill()
. In my opinion, just like using ContentSize
, the value returned from Fill()
is what should be considered.
[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);
}
from terminal.gui.
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.
from terminal.gui.
Basically in each test, using DimAutoStyle.Auto
, I am testing 3 views, where the first does not use the maximum value, the second uses an absolute value and the third uses Fill
. In the first test I am using ContentSize
and in the second I am using Text
, where view2.TextDirection = TextDirection.TopBottom_LeftRight
. Practically the tests pass as expected and the only exception is in the second test, using Text
, in the view that is using Fill
, it does not respect the width of the superview (40), returning Text.Length
(35). I didn't want to use Theory
to avoid complicating things and making it simpler.
from terminal.gui.
Related Issues (20)
- Changing `Visible` does not effect `Subviews`'s `Visible` HOT 8
- Adornments = too many `Views`
- Forcing focus to a `RadioGroup` inside of a Wizard cause the `RadioGroup` and the `Next/Finish` button to be focused at the same time HOT 6
- Arrow Right in TextField/TextView should not move tab if there is a selection HOT 2
- `Slider` does not seem to respect click handlers HOT 3
- `Pos.Has` should be generic like `Dim.Has<T>`
- Consider making `Pos.AnchorEnd` take a `Pos` instead of `int`? HOT 1
- ProcessContinuousButtonPressedAsync is using a stale MouseEvent.
- `SpinnerView` Calling `AdvanceAnimation` in Constructor HOT 1
- `Slider`: API for setting options is clunky
- Authenticode Sign HOT 1
- Application stops responding HOT 12
- Disabled MenuItem triggers exception HOT 3
- Tiled mode: need a way to declare tiled view size dependencies
- Navigation Scenario: Add a `TabStop` Editor
- Subviews in `Adornments` that are not `ViewArrangement.Fixed` are not supported
- Terminal Gui Templates still using v1 HOT 2
- `MouseEnter/Leave` is broken for Views with subviews
- Tracking `Windows Terminal` Issue - App size is corrupted
- `HighlightOnPress` and/or `WantContinousButtonPressed` has issues with nested subviews. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminal.gui.