|
@@ -486,7 +486,6 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
Assert.True (win1.IsMdiChild);
|
|
|
Assert.Null (top.Focused);
|
|
|
Assert.Null (top.MostFocused);
|
|
|
- Assert.Equal (win1.Subviews [0], win1.Focused);
|
|
|
Assert.Equal (tf1W1, win1.MostFocused);
|
|
|
Assert.True (win1.IsMdiChild);
|
|
|
Assert.Single (Application.MdiChildes);
|
|
@@ -499,7 +498,6 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
Assert.True (win2.IsMdiChild);
|
|
|
Assert.Null (top.Focused);
|
|
|
Assert.Null (top.MostFocused);
|
|
|
- Assert.Equal (win2.Subviews [0], win2.Focused);
|
|
|
Assert.Equal (tf1W2, win2.MostFocused);
|
|
|
Assert.Equal (2, Application.MdiChildes.Count);
|
|
|
|
|
@@ -683,35 +681,25 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void Mouse_Drag_On_Top_With_Superview_Null ()
|
|
|
{
|
|
|
- var menu = new MenuBar (new MenuBarItem [] {
|
|
|
- new MenuBarItem("File", new MenuItem [] {
|
|
|
- new MenuItem("New", "", null)
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- var sbar = new StatusBar (new StatusItem [] {
|
|
|
- new StatusItem(Key.N, "~CTRL-N~ New", null)
|
|
|
- });
|
|
|
-
|
|
|
- var win = new Window ("Window");
|
|
|
+ var win = new Window ();
|
|
|
var top = Application.Top;
|
|
|
- top.Add (menu, sbar, win);
|
|
|
-
|
|
|
+ top.Add (win);
|
|
|
var iterations = -1;
|
|
|
|
|
|
Application.Iteration = () => {
|
|
|
iterations++;
|
|
|
if (iterations == 0) {
|
|
|
((FakeDriver)Application.Driver).SetBufferSize (40, 15);
|
|
|
- MessageBox.Query ("About", "Hello Word", "Ok");
|
|
|
+ MessageBox.Query ("", "Hello Word", "Ok");
|
|
|
|
|
|
- } else if (iterations == 1) TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-┌┤Window├──────────────────────────────┐
|
|
|
+ } else if (iterations == 1) {
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
+┌──────────────────────────────────────┐
|
|
|
│ │
|
|
|
│ │
|
|
|
│ │
|
|
|
-│ ┌┤About├───────────────┐ │
|
|
|
+│ │
|
|
|
+│ ┌──────────────────────┐ │
|
|
|
│ │ Hello Word │ │
|
|
|
│ │ │ │
|
|
|
│ │ [◦ Ok ◦] │ │
|
|
@@ -719,9 +707,10 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
│ │
|
|
|
│ │
|
|
|
│ │
|
|
|
+│ │
|
|
|
└──────────────────────────────────────┘
|
|
|
- CTRL-N New ", output);
|
|
|
- else if (iterations == 2) {
|
|
|
+", output);
|
|
|
+ } else if (iterations == 2) {
|
|
|
Assert.Null (Application.MouseGrabView);
|
|
|
// Grab the mouse
|
|
|
ReflectionTools.InvokePrivate (
|
|
@@ -738,7 +727,7 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
|
|
|
} else if (iterations == 3) {
|
|
|
Assert.Equal (Application.Current, Application.MouseGrabView);
|
|
|
- // Grab to left
|
|
|
+ // Drag to left
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
@@ -755,12 +744,12 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
Assert.Equal (Application.Current, Application.MouseGrabView);
|
|
|
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-┌┤Window├──────────────────────────────┐
|
|
|
+┌──────────────────────────────────────┐
|
|
|
│ │
|
|
|
│ │
|
|
|
│ │
|
|
|
-│ ┌┤About├───────────────┐ │
|
|
|
+│ │
|
|
|
+│ ┌──────────────────────┐ │
|
|
|
│ │ Hello Word │ │
|
|
|
│ │ │ │
|
|
|
│ │ [◦ Ok ◦] │ │
|
|
@@ -768,13 +757,13 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
│ │
|
|
|
│ │
|
|
|
│ │
|
|
|
-└──────────────────────────────────────┘
|
|
|
- CTRL-N New ", output);
|
|
|
+│ │
|
|
|
+└──────────────────────────────────────┘", output);
|
|
|
|
|
|
Assert.Equal (Application.Current, Application.MouseGrabView);
|
|
|
} else if (iterations == 5) {
|
|
|
Assert.Equal (Application.Current, Application.MouseGrabView);
|
|
|
- // Grab to top
|
|
|
+ // Drag up
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
@@ -791,11 +780,11 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
Assert.Equal (Application.Current, Application.MouseGrabView);
|
|
|
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-┌┤Window├──────────────────────────────┐
|
|
|
+┌──────────────────────────────────────┐
|
|
|
│ │
|
|
|
│ │
|
|
|
-│ ┌┤About├───────────────┐ │
|
|
|
+│ │
|
|
|
+│ ┌──────────────────────┐ │
|
|
|
│ │ Hello Word │ │
|
|
|
│ │ │ │
|
|
|
│ │ [◦ Ok ◦] │ │
|
|
@@ -804,8 +793,8 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
│ │
|
|
|
│ │
|
|
|
│ │
|
|
|
-└──────────────────────────────────────┘
|
|
|
- CTRL-N New ", output);
|
|
|
+│ │
|
|
|
+└──────────────────────────────────────┘", output);
|
|
|
|
|
|
Assert.Equal (Application.Current, Application.MouseGrabView);
|
|
|
Assert.Equal (new Rect (7, 4, 24, 5), Application.MouseGrabView.Frame);
|
|
@@ -834,27 +823,22 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void Mouse_Drag_On_Top_With_Superview_Not_Null ()
|
|
|
{
|
|
|
- var menu = new MenuBar (new MenuBarItem [] {
|
|
|
- new MenuBarItem("File", new MenuItem [] {
|
|
|
- new MenuItem("New", "", null)
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- var sbar = new StatusBar (new StatusItem [] {
|
|
|
- new StatusItem(Key.N, "~CTRL-N~ New", null)
|
|
|
- });
|
|
|
-
|
|
|
- var win = new Window ("Window") {
|
|
|
+ var win = new Window () {
|
|
|
X = 3,
|
|
|
Y = 2,
|
|
|
Width = Dim.Fill (10),
|
|
|
Height = Dim.Fill (5)
|
|
|
};
|
|
|
var top = Application.Top;
|
|
|
- top.Add (menu, sbar, win);
|
|
|
+ top.Add (win);
|
|
|
|
|
|
var iterations = -1;
|
|
|
|
|
|
+ int movex = 0;
|
|
|
+ int movey = 0;
|
|
|
+
|
|
|
+ var location = new Rect (win.Frame.X, win.Frame.Y, 7, 3);
|
|
|
+
|
|
|
Application.Iteration = () => {
|
|
|
iterations++;
|
|
|
if (iterations == 0) {
|
|
@@ -866,106 +850,77 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
|
new MouseEvent () {
|
|
|
- X = 4,
|
|
|
- Y = 2,
|
|
|
+ X = win.Frame.X,
|
|
|
+ Y = win.Frame.Y,
|
|
|
Flags = MouseFlags.Button1Pressed
|
|
|
});
|
|
|
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
- Assert.Equal (new Rect (3, 2, 7, 3), Application.MouseGrabView.Frame);
|
|
|
-
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-
|
|
|
- ┌─────┐
|
|
|
- │ │
|
|
|
- └─────┘
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CTRL-N New", output);
|
|
|
-
|
|
|
+ Assert.Equal (location, Application.MouseGrabView.Frame);
|
|
|
|
|
|
} else if (iterations == 1) {
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
- // Grab to left
|
|
|
+ // Drag to left
|
|
|
+ movex = 1;
|
|
|
+ movey = 0;
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
|
new MouseEvent () {
|
|
|
- X = 5,
|
|
|
- Y = 2,
|
|
|
+ X = win.Frame.X + movex,
|
|
|
+ Y = win.Frame.Y + movey,
|
|
|
Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
|
|
|
});
|
|
|
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
|
|
|
} else if (iterations == 2) {
|
|
|
+ // we should have moved +1, +0
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
-
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-
|
|
|
- ┌────┐
|
|
|
- │ │
|
|
|
- └────┘
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CTRL-N New", output);
|
|
|
-
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
- Assert.Equal (new Rect (4, 2, 6, 3), Application.MouseGrabView.Frame);
|
|
|
+ location.Offset (movex, movey);
|
|
|
+ Assert.Equal (location, Application.MouseGrabView.Frame);
|
|
|
|
|
|
} else if (iterations == 3) {
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
- // Grab to top
|
|
|
+ // Drag up
|
|
|
+ movex = 0;
|
|
|
+ movey = -1;
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
|
new MouseEvent () {
|
|
|
- X = 5,
|
|
|
- Y = 1,
|
|
|
+ X = win.Frame.X + movex,
|
|
|
+ Y = win.Frame.Y + movey,
|
|
|
Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
|
|
|
});
|
|
|
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
|
|
|
} else if (iterations == 4) {
|
|
|
+ // we should have moved +0, -1
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
-
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
- ┌────┐
|
|
|
- │ │
|
|
|
- │ │
|
|
|
- └────┘
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CTRL-N New", output);
|
|
|
-
|
|
|
- Assert.Equal (win, Application.MouseGrabView);
|
|
|
- Assert.Equal (new Rect (4, 1, 6, 4), Application.MouseGrabView.Frame);
|
|
|
+ location.Offset (movex, movey);
|
|
|
+ Assert.Equal (location, Application.MouseGrabView.Frame);
|
|
|
|
|
|
} else if (iterations == 5) {
|
|
|
Assert.Equal (win, Application.MouseGrabView);
|
|
|
// Ungrab the mouse
|
|
|
+ movex = 0;
|
|
|
+ movey = 0;
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
|
new MouseEvent () {
|
|
|
- X = 7,
|
|
|
- Y = 4,
|
|
|
+ X = win.Frame.X + movex,
|
|
|
+ Y = win.Frame.Y + movey,
|
|
|
Flags = MouseFlags.Button1Released
|
|
|
});
|
|
|
|
|
|
Assert.Null (Application.MouseGrabView);
|
|
|
-
|
|
|
- } else if (iterations == 8) Application.RequestStop ();
|
|
|
+ } else if (iterations == 8) {
|
|
|
+ Application.RequestStop ();
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
Application.Run ();
|
|
@@ -1224,18 +1179,8 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
[Fact, AutoInitShutdown]
|
|
|
public void Dialog_Bounds_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom ()
|
|
|
{
|
|
|
- var menu = new MenuBar (new MenuBarItem [] {
|
|
|
- new MenuBarItem("File", new MenuItem [] {
|
|
|
- new MenuItem("New", "", null)
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- var sb = new StatusBar (new StatusItem [] {
|
|
|
- new StatusItem(Key.N, "~CTRL-N~ New", null)
|
|
|
- });
|
|
|
var top = Application.Top;
|
|
|
- top.Add (menu, sb);
|
|
|
- var dialog = new Dialog ("Dialog", 20, 3, new Button ("Ok"));
|
|
|
+ var dialog = new Dialog ("", 20, 3, new Button ("Ok"));
|
|
|
Application.Begin (top);
|
|
|
((FakeDriver)Application.Driver).SetBufferSize (40, 10);
|
|
|
Application.Begin (dialog);
|
|
@@ -1243,16 +1188,10 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
|
|
|
Assert.Equal (new Rect (10, 3, 20, 3), dialog.Frame);
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-
|
|
|
-
|
|
|
- ┌┤Dialog├──────────┐
|
|
|
+ ┌──────────────────┐
|
|
|
│ [ Ok ] │
|
|
|
└──────────────────┘
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CTRL-N New ", output);
|
|
|
+", output);
|
|
|
|
|
|
Assert.Null (Application.MouseGrabView);
|
|
|
|
|
@@ -1278,21 +1217,15 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
|
|
|
Application.Refresh ();
|
|
|
Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
|
|
|
- Assert.Equal (new Rect (0, 1, 20, 3), dialog.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, 20, 3), dialog.Frame);
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-┌┤Dialog├──────────┐
|
|
|
+┌──────────────────┐
|
|
|
│ [ Ok ] │
|
|
|
└──────────────────┘
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CTRL-N New ", output);
|
|
|
+", output);
|
|
|
|
|
|
// Changes Top size to same size as Dialog more menu and scroll bar
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (20, 5);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (20, 3);
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
@@ -1303,17 +1236,16 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
});
|
|
|
|
|
|
Application.Refresh ();
|
|
|
- Assert.Equal (new Rect (0, 0, 20, 5), top.Frame);
|
|
|
- Assert.Equal (new Rect (0, 1, 20, 3), dialog.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, 20, 3), top.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, 20, 3), dialog.Frame);
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-┌┤Dialog├──────────┐
|
|
|
+┌──────────────────┐
|
|
|
│ [ Ok ] │
|
|
|
└──────────────────┘
|
|
|
- CTRL-N New ", output);
|
|
|
+", output);
|
|
|
|
|
|
// Changes Top size smaller than Dialog size
|
|
|
- ((FakeDriver)Application.Driver).SetBufferSize (19, 3);
|
|
|
+ ((FakeDriver)Application.Driver).SetBufferSize (19, 2);
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
@@ -1324,29 +1256,27 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
});
|
|
|
|
|
|
Application.Refresh ();
|
|
|
- Assert.Equal (new Rect (0, 0, 19, 3), top.Frame);
|
|
|
- Assert.Equal (new Rect (-1, 1, 20, 3), dialog.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
|
|
+ Assert.Equal (new Rect (-1, 0, 20, 3), dialog.Frame);
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
- Dialog ──────────┐
|
|
|
- [ Ok ] │", output);
|
|
|
+──────────────────┐
|
|
|
+ [ Ok ] │
|
|
|
+", output);
|
|
|
|
|
|
ReflectionTools.InvokePrivate (
|
|
|
typeof (Application),
|
|
|
"ProcessMouseEvent",
|
|
|
new MouseEvent () {
|
|
|
X = 18,
|
|
|
- Y = 3,
|
|
|
+ Y = 1,
|
|
|
Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
|
|
|
});
|
|
|
|
|
|
Application.Refresh ();
|
|
|
- Assert.Equal (new Rect (0, 0, 19, 3), top.Frame);
|
|
|
- Assert.Equal (new Rect (18, 2, 20, 3), dialog.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
|
|
+ Assert.Equal (new Rect (18, 1, 20, 3), dialog.Frame);
|
|
|
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-
|
|
|
- CTRL-N New ┌", output);
|
|
|
+ ┌", output);
|
|
|
|
|
|
// On a real app we can't go beyond the SuperView bounds
|
|
|
ReflectionTools.InvokePrivate (
|
|
@@ -1354,17 +1284,14 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
"ProcessMouseEvent",
|
|
|
new MouseEvent () {
|
|
|
X = 19,
|
|
|
- Y = 4,
|
|
|
+ Y = 2,
|
|
|
Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
|
|
|
});
|
|
|
|
|
|
Application.Refresh ();
|
|
|
- Assert.Equal (new Rect (0, 0, 19, 3), top.Frame);
|
|
|
+ Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
|
|
|
Assert.Equal (new Rect (19, 2, 20, 3), dialog.Frame);
|
|
|
- TestHelpers.AssertDriverContentsWithFrameAre (@"
|
|
|
- File
|
|
|
-
|
|
|
- CTRL-N New", output);
|
|
|
+ TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
|
|
|
}
|
|
|
|
|
|
[Fact, AutoInitShutdown]
|
|
@@ -1409,7 +1336,7 @@ namespace Terminal.Gui.TopLevelTests {
|
|
|
});
|
|
|
|
|
|
var firstIteration = false;
|
|
|
- Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
|
|
|
+ Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
|
|
|
Assert.Equal (dialog, Application.MouseGrabView);
|
|
|
|
|
|
Assert.Equal (new Rect (25, 7, 30, 10), dialog.Frame);
|