Files
Terminal.Gui/UnitTests/PosTests.cs
BDisp e784765094 Fixes #1179. TextView does not copy to the clipboard on deleting. (#1180)
* Fixes #1133. Flaw in LayoutSubviews/TopologicalSort.

* Toplevel can't be used on Pos/Dim but only his subviews. Was not caught before because the LayoutSubviews  method never gone so deep before.

* Fixed the error that is triggered when the Pos/Dim is the current Application.Top.

* Application.Top is the only exception in the TopologicalSort method check.

* Fixes #1179. TextView does not copy to the clipboard on deleting.

* Added Button DoubleClick and fixed WordForward/WordBackward issues.

* Prevents a negative height.

* Fixes the enter key line feed.

* Fixes #1187. Prevents WordBackward throwing an exception if point is greater than the text length.

* Fixes #1189. Prevents negative index.

* Fixes #1193. A  non auto size default Button now preserves his width and thus the text alignment now work.

* Fixing the Width and Height checks of the Dim class with AutoSize dependence.

* Fixes #1197. Prevents width negative value if added directly to the Application.Top

* Fixes #1199. Normalize views constructors and did some typo fixing.

* Fixing the Application.Top Pos/Dim settings.

* Always uses inverted color for selected text to avoid same colors.

* Prevents throw an exception if the clipboard content is null.

* Added Find and Replace (next/previous). Replace All and Select All. A non modal dialog box.

* Keeps tracking the selected replaced text.

* Fixes #1202. CheckBox now deals with a functional '_' underscore hotkey.

* The selected text should be maintained when losing focus.

* Fixes an extra line on page down.

* Fixes the WordBackward if it text has more than one whitespaces or when has only one digit or letter.

* Fixes WordForward/WordBackward on text with more than one whitespace or with only one digit or letter.

* Forgot to replace the hacking.

* Added unit tests for the TextField view. Fixed some more bugs.

* Redraw should only show the selected text if it is focused.

* Fixes cursor position on double click and ensures the setting of the selected text.

* Added match whole word checking.

* Added missing parameters documentation.

* Ensures the SelectedLength property to be always with positive value.

* Fixes the WordBackward when at the end of the text has a character between two whitespace.

* Added unit tests to the TextView, Used property and fixed some more bugs.

* Fixed Used to only show if it has focus.

* Fixed ReplaceAll and prevents Debug.Assert from showing.
2021-04-13 13:37:13 -07:00

541 lines
18 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using Terminal.Gui;
using Xunit;
// Alais Console to MockConsole so we don't accidentally use Console
using Console = Terminal.Gui.FakeConsole;
namespace Terminal.Gui {
public class PosTests {
[Fact]
public void New_Works ()
{
var pos = new Pos ();
Assert.Equal ("Terminal.Gui.Pos", pos.ToString ());
}
[Fact]
public void AnchorEnd_SetsValue ()
{
var n = 0;
var pos = Pos.AnchorEnd ();
Assert.Equal ($"Pos.AnchorEnd(margin={n})", pos.ToString ());
n = 5;
pos = Pos.AnchorEnd (n);
Assert.Equal ($"Pos.AnchorEnd(margin={n})", pos.ToString ());
}
[Fact]
public void AnchorEnd_Equal ()
{
var n1 = 0;
var n2 = 0;
var pos1 = Pos.AnchorEnd (n1);
var pos2 = Pos.AnchorEnd (n2);
Assert.Equal (pos1, pos2);
// Test inequality
n2 = 5;
pos2 = Pos.AnchorEnd (n2);
Assert.NotEqual (pos1, pos2);
}
[Fact]
public void AnchorEnd_Negative_Throws ()
{
Pos pos;
var n = -1;
Assert.Throws<ArgumentException> (() => pos = Pos.AnchorEnd (n));
}
[Fact]
public void At_SetsValue ()
{
var pos = Pos.At (0);
Assert.Equal ("Pos.Absolute(0)", pos.ToString ());
pos = Pos.At (5);
Assert.Equal ("Pos.Absolute(5)", pos.ToString ());
pos = Pos.At (-1);
Assert.Equal ("Pos.Absolute(-1)", pos.ToString ());
}
[Fact]
public void At_Equal ()
{
var n1 = 0;
var n2 = 0;
var pos1 = Pos.At (n1);
var pos2 = Pos.At (n2);
Assert.Equal (pos1, pos2);
}
[Fact]
public void SetSide_Null_Throws ()
{
var pos = Pos.Left (null);
Assert.Throws<NullReferenceException> (() => pos.ToString ());
pos = Pos.X (null);
Assert.Throws<NullReferenceException> (() => pos.ToString ());
pos = Pos.Top (null);
Assert.Throws<NullReferenceException> (() => pos.ToString ());
pos = Pos.Y (null);
Assert.Throws<NullReferenceException> (() => pos.ToString ());
pos = Pos.Bottom (null);
Assert.Throws<NullReferenceException> (() => pos.ToString ());
pos = Pos.Right (null);
Assert.Throws<NullReferenceException> (() => pos.ToString ());
}
// TODO: Test Left, Top, Right bottom Equal
/// <summary>
/// Tests Pos.Left, Pos.X, Pos.Top, Pos.Y, Pos.Right, and Pos.Bottom set operations
/// </summary>
[Fact]
public void PosSide_SetsValue ()
{
string side; // used in format string
var testRect = Rect.Empty;
var testInt = 0;
Pos pos;
// Pos.Left
side = "x";
testInt = 0;
testRect = Rect.Empty;
pos = Pos.Left (new View ());
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
pos = Pos.Left (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testRect = new Rect (1, 2, 3, 4);
pos = Pos.Left (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Left(win) + 0
pos = Pos.Left (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = 1;
// Pos.Left(win) +1
pos = Pos.Left (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = -1;
// Pos.Left(win) -1
pos = Pos.Left (new View (testRect)) - testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.X
side = "x";
testInt = 0;
testRect = Rect.Empty;
pos = Pos.X (new View ());
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
pos = Pos.X (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testRect = new Rect (1, 2, 3, 4);
pos = Pos.X (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.X(win) + 0
pos = Pos.X (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = 1;
// Pos.X(win) +1
pos = Pos.X (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = -1;
// Pos.X(win) -1
pos = Pos.X (new View (testRect)) - testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Top
side = "y";
testInt = 0;
testRect = Rect.Empty;
pos = Pos.Top (new View ());
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
pos = Pos.Top (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testRect = new Rect (1, 2, 3, 4);
pos = Pos.Top (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Top(win) + 0
pos = Pos.Top (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = 1;
// Pos.Top(win) +1
pos = Pos.Top (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = -1;
// Pos.Top(win) -1
pos = Pos.Top (new View (testRect)) - testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Y
side = "y";
testInt = 0;
testRect = Rect.Empty;
pos = Pos.Y (new View ());
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
pos = Pos.Y (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testRect = new Rect (1, 2, 3, 4);
pos = Pos.Y (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Y(win) + 0
pos = Pos.Y (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = 1;
// Pos.Y(win) +1
pos = Pos.Y (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = -1;
// Pos.Y(win) -1
pos = Pos.Y (new View (testRect)) - testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Bottom
side = "bottom";
testRect = Rect.Empty;
testInt = 0;
pos = Pos.Bottom (new View ());
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
pos = Pos.Bottom (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testRect = new Rect (1, 2, 3, 4);
pos = Pos.Bottom (new View (testRect));
Assert.Equal ($"Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}})){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
// Pos.Bottom(win) + 0
pos = Pos.Bottom (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = 1;
// Pos.Bottom(win) +1
pos = Pos.Bottom (new View (testRect)) + testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
testInt = -1;
// Pos.Bottom(win) -1
pos = Pos.Bottom (new View (testRect)) - testInt;
Assert.Equal ($"Pos.Combine(Pos.Combine(Pos.View(side={side}, target=View()({{X={testRect.X},Y={testRect.Y},Width={testRect.Width},Height={testRect.Height}}}))+Pos.Absolute(0)){(testInt < 0 ? '-' : '+')}Pos.Absolute({testInt}))", pos.ToString ());
}
// See: https://github.com/migueldeicaza/gui.cs/issues/504
[Fact]
public void LeftTopBottomRight_Win_ShouldNotThrow ()
{
// Setup Fake driver
(Window win, Button button) setup ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
Application.Iteration = () => {
Application.RequestStop ();
};
var win = new Window ("window") {
X = 0,
Y = 0,
Width = Dim.Fill (),
Height = Dim.Fill (),
};
Application.Top.Add (win);
var button = new Button ("button") {
X = Pos.Center (),
};
win.Add (button);
return (win, button);
}
Application.RunState rs;
void cleanup (Application.RunState rs)
{
// Cleanup
Application.End (rs);
}
// Test cases:
var app = setup ();
app.button.Y = Pos.Left (app.win);
rs = Application.Begin (Application.Top);
Application.Run ();
cleanup (rs);
app = setup ();
app.button.Y = Pos.X (app.win);
rs = Application.Begin (Application.Top);
Application.Run ();
cleanup (rs);
app = setup ();
app.button.Y = Pos.Top (app.win);
rs = Application.Begin (Application.Top);
Application.Run ();
cleanup (rs);
app = setup ();
app.button.Y = Pos.Y (app.win);
rs = Application.Begin (Application.Top);
Application.Run ();
cleanup (rs);
app = setup ();
app.button.Y = Pos.Bottom (app.win);
rs = Application.Begin (Application.Top);
Application.Run ();
cleanup (rs);
app = setup ();
app.button.Y = Pos.Right (app.win);
rs = Application.Begin (Application.Top);
Application.Run ();
cleanup (rs);
}
[Fact]
public void Center_SetsValue ()
{
var pos = Pos.Center ();
Assert.Equal ("Pos.Center", pos.ToString ());
}
[Fact]
public void Percent_SetsValue ()
{
float f = 0;
var pos = Pos.Percent (f);
Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
f = 0.5F;
pos = Pos.Percent (f);
Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
f = 100;
pos = Pos.Percent (f);
Assert.Equal ($"Pos.Factor({f / 100:0.###})", pos.ToString ());
}
[Fact]
public void Percent_Equal ()
{
var n1 = 0;
var n2 = 0;
var pos1 = Pos.Percent (n1);
var pos2 = Pos.Percent (n2);
// BUGBUG: Pos.Percent should support equality
Assert.NotEqual (pos1, pos2);
}
[Fact]
public void Percent_ThrowsOnIvalid ()
{
var pos = Pos.Percent (0);
Assert.Throws<ArgumentException> (() => pos = Pos.Percent (-1));
Assert.Throws<ArgumentException> (() => pos = Pos.Percent (101));
Assert.Throws<ArgumentException> (() => pos = Pos.Percent (100.0001F));
Assert.Throws<ArgumentException> (() => pos = Pos.Percent (1000001));
}
[Fact]
public void Pos_Validation_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var t = Application.Top;
var w = new Window ("w") {
X = Pos.Left (t) + 2,
Y = Pos.At (2)
};
var v = new View ("v") {
X = Pos.Center (),
Y = Pos.Percent (10)
};
w.Add (v);
t.Add (w);
t.Ready += () => {
Assert.Equal (2, w.X = 2);
Assert.Equal (2, w.Y = 2);
Assert.Throws<ArgumentException> (() => v.X = 2);
Assert.Throws<ArgumentException> (() => v.Y = 2);
};
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Shutdown ();
}
[Fact]
public void Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Null ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var t = Application.Top;
var w = new Window (new Rect (1, 2, 4, 5), "w");
t.Add (w);
t.Ready += () => {
Assert.Equal (2, w.X = 2);
Assert.Equal (2, w.Y = 2);
};
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Shutdown ();
}
[Fact]
public void Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var t = Application.Top;
var w = new Window ("w") {
X = Pos.Left (t) + 2,
Y = Pos.At (2)
};
var v = new View ("v") {
X = Pos.Center (),
Y = Pos.Percent (10)
};
w.Add (v);
t.Add (w);
t.Ready += () => {
v.LayoutStyle = LayoutStyle.Absolute;
Assert.Equal (2, v.X = 2);
Assert.Equal (2, v.Y = 2);
};
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Shutdown ();
}
// DONE: Test PosCombine
// DONE: Test operators
[Fact]
public void PosCombine_Do_Not_Throws ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var t = Application.Top;
var w = new Window ("w") {
X = Pos.Left (t) + 2,
Y = Pos.Top (t) + 2
};
var f = new FrameView ("f");
var v1 = new View ("v1") {
X = Pos.Left (w) + 2,
Y = Pos.Top (w) + 2
};
var v2 = new View ("v2") {
X = Pos.Left (v1) + 2,
Y = Pos.Top (v1) + 2
};
f.Add (v1, v2);
w.Add (f);
t.Add (w);
f.X = Pos.X (t) + Pos.X (v2) - Pos.X (v1);
f.Y = Pos.Y (t) + Pos.Y (v2) - Pos.Y (v1);
t.Ready += () => {
Assert.Equal (0, t.Frame.X);
Assert.Equal (0, t.Frame.Y);
Assert.Equal (2, w.Frame.X);
Assert.Equal (2, w.Frame.Y);
Assert.Equal (2, f.Frame.X);
Assert.Equal (2, f.Frame.Y);
Assert.Equal (4, v1.Frame.X);
Assert.Equal (4, v1.Frame.Y);
Assert.Equal (6, v2.Frame.X);
Assert.Equal (6, v2.Frame.Y);
};
Application.Iteration += () => Application.RequestStop ();
Application.Run ();
Application.Shutdown ();
}
[Fact]
public void PosCombine_Will_Throws ()
{
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
var t = Application.Top;
var w = new Window ("w") {
X = Pos.Left (t) + 2,
Y = Pos.Top (t) + 2
};
var f = new FrameView ("f");
var v1 = new View ("v1") {
X = Pos.Left (w) + 2,
Y = Pos.Top (w) + 2
};
var v2 = new View ("v2") {
X = Pos.Left (v1) + 2,
Y = Pos.Top (v1) + 2
};
f.Add (v1); // v2 not added
w.Add (f);
t.Add (w);
f.X = Pos.X (v2) - Pos.X (v1);
f.Y = Pos.Y (v2) - Pos.Y (v1);
Assert.Throws<InvalidOperationException> (() => Application.Run ());
Application.Shutdown ();
}
}
}